82579

Can Visual Studio XAML designer handle font family names with spaces as a resource?

This probably seems like a strange question, but I'm having trouble seeing a custom true-type font that I've loaded as a resource in my WPF application, and I'm wondering if it may have to do with the space in the font name.

As described elsewhere (one of hundreds of examples), I've added the font to a folder Fonts in my application, and set it to Build Action = Resource. I'm able to reference the font (e.g., in a TextBlock) with a simple FontFamily="Fonts\#My Font".

Unfortunately, the font only shows up at run time, not in the XAML designer (contrary to most people's problems). However, as explained here, this author had a similar problem with the font Open Sans, and if I install the font on my system, as he did, I can see it at design time.

But I'd rather not force developers to install the font on their system. I noticed that, like the author above, I don't have this problem with a few custom fonts that have names without spaces. So I'm wonder if this is perhaps a bug in Visual Studio (I'm using Community 2013). Has anyone been able to get this to work with a font whose name contains a space? Or has anyone found a more satisfying workaround (e.g., way to reference the font without the space akin to Windows short files names)?

Answer1:

I had this very same problem. The solution is taking out the spaces, although you can't just edit the file name. Here's how I did it:

    <li>Download FontForge - http://fontforge.github.io/en-US/.</li> <li>Open the font file</li> <li>Go to Elements -> Font Info</li> <li>In there look for xyz Names, mine was TTF Names due to it being Wingdings</li> <li>Edit them to remove the spaces, I'm pretty sure the only one that matters is the "UniqueID" but I did them all.</li> <li>Go to File -> Generate Fonts and save the font as the proper type.</li> <li>Re-add the file and reference the font without spaces</li> </ul>

    This was the only way I could get it to work but it ended up working without a hitch. Best of luck.

Recommend

  • Objective C Communicating to one view controller that another has changed
  • Python property and method override issue: why subclass property still calls the base class's m
  • How to change TextBlock default properties for a ContentPresenter in a template
  • WP 7.1 app shows thich Black header while running in WP8 emulator
  • Aliasing in Fortran function
  • How can I bind a string to double in WPF?
  • Draw Line chart on top of Bar chart in SSRS?
  • Can I include a Generic type parameter in a lamba expression? (VB.NET 2010)
  • python datetime.astimezone behavior incorrect?
  • Silverlight DataGrid validation show validation error for all objects|properties
  • Can I use PropertyChanged and LostFocus together?
  • Windows phone 8.1 Flyout hide with behaviour issue
  • Is it possible to have space between cells in iTextPdf?
  • How to add a resource file to Visual Studios so that it's visible in “Select Resource” dialog?
  • How to work with Master Page that is attached to the page via the page's basepage?
  • Multibinding Multiselection ListView
  • Updating one element of a bound Observable collection
  • How to convert WPF project so it can be used as a class library by a separate exe
  • Android Lock Screen C# .NET Replica
  • Separate ID and Class for JS and CSS
  • WP8.1 AppBarButton holding event
  • Not able to aggregate on nested fields in elasticsearch
  • Unable to install Git-core+svn by MacPorts
  • Django simple Captcha “No module named fields” error
  • Installing iPhone App to iPhone
  • Abort upload large uploads after reading headers
  • Could not find rake using whenever rails
  • Problems to linebreak with an int in JLabel
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Controls, properties, events and timers running in design time
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Perl system calls when running as another user using sudo
  • Updated Ionic CLI but shows previous version (Windows)
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Data Validation Drop Down Box Arrow Disappearing
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]