I cannot figure out how to determine how to render a specific OpenType font correctly in WPF (.NET 4.5 / VS2012 / Windows 8). I have a font installed on my computer called "DINPro-BlackItalic".
The file name is: DINPro-BlackItalic.otf
Windows reports the font name is: DINPro-BlackItalic
In WPF, I do something simple, like this:
<TextBlock Text="This is a sample sentence in DINPro-BlackItalic"
FontFamily="DinPro-BlackItalic" FontSize="24" />
or FontFamily="#DinPro-BlackItalic"
This doesn't work (clearly not italic) and it falls back to the default font. I've tried lots of other variations which do work for other fonts in the font directory.
For example, Comic Sans works: FontFamily="Comic Sans MS"
(awesome...)
Now, this is why I am really confused: If I just guess at a different way to punctuate the font name, it renders correctly!
This works: FontFamily="Din Pro Black Italic"
In summary, here is a screen shot of different FontFamily settings in WPF:
Two questions:
1) How am I supposed to guess at the right way to tell WPF to render this font? It must have a canonical name registered somewhere but it isn't visible in the filename, file properties, or the Font Name that Windows reports after it has parsed the file.
2) What's worse is that if I'm attempting to render the same font in a desktop application and on the Web, browsers like Chrome on Windows and even IE expect "DINPro-BlackItalic" and will not render the spaced out version of the name. It seems that WPF and windows browsers make mutually exclusive decisions about which Font Name to use to index fonts. How do I work around this for arbitrary fonts?