Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Font: Why are some characters missing?

Tags:

wpf

fonts

textbox

I'm writing a WPF app and the font that I am using only has problems running in WPF - it works fine using it in anything else (notepad, wordpad, etc.). The problem with WPF is that it falls back to another font sometimes. By "sometimes" I mean that only characters [a-zA-Z] appear to render correctly - everything else appears to be rendered as the default TextBox font.

Does anyone know if WPF has some sort of limitation for the fonts that it supports? It almost seems to be bug in WPF - the font works fine everywhere else.

The font that I'm trying to use is the "Scramble" TTF font (http://famousfonts.smackbomb.com/fonts/scrabble.php).

Numbers and spaces should be seen as a blank Scrabble/Scramble tile, but instead the number itself appears in the textbox I'm using.

The code I'm using:

<TextBox Text="Testing testing testing" FontFamily="Fonts/#Scramble" />

Has anyone else experienced something similar?

Any suggestions would rock!

Thanks!

like image 393
Charles Avatar asked May 07 '09 01:05

Charles


1 Answers

From MSDN:

Font Fallback

Font fallback refers to the automatic substitution of a font other than the font that is selected by the client application. There are two primary reasons why font fallback is invoked:

  • The font that is specified by the client application does not exist on the system.
  • The font that is specified by the client application does not contain the glyphs that are required to render text.

In WPF, the font fallback mechanism uses the default fallback font family, "Global User Interface", as the substitute font. This font is defined as a composite font, whose file name is "GlobalUserInterface.CompositeFont". For more information about composite fonts, see the Composite Fonts section in this topic.

The WPF font fallback mechanism replaces previous Win32 font substitution technologies.

My guess would be that the font doesn't support Unicode - the font itself was created in 1996, and since it's intended to emulate Scrabble pieces, I'm not sure that the font author even considered localization.

EDIT According to the font documentation, the font supports the letters, and any number is supposed to render a blank tile. Spaces don't render a tile.

like image 60
GalacticCowboy Avatar answered Oct 18 '22 15:10

GalacticCowboy