Question

I need to use a OTF font in a Windows Phone 8 app. I have found an article about how to to this at http://blendrocks.com/otf-and-ttf-fonts-in-windows-phone-and-store-apps/. I followed the article but it strangely does not work with the font I have, but works with other fonts.

The font files is an Resources and I use it like this

<TextBlock Text="BRANDON GROTESQUE" Margin="9,-7,0,0" FontFamily="/FontProblem;component/Fonts/BrandonGrotesque-Regular.otf#BrandonGrotesque-Regular" FontSize="36"/>

I have also tried converting it to TTF and embeding it according to http://nicksnettravels.builttoroam.com/post/2013/06/22/TTF-Font-with-Windows-Phone-8.aspx but no luck.

Here is the whole solution to reproduce the problem: https://dl.dropboxusercontent.com/u/73642/FontProblem.zip

I guess the font is the problem.

Was it helpful?

Solution

If you set the Build Action to Content, you don't have to prepend your project name, so you can use:

/Fonts/BrandonGrotesque-Regular.otf

Just to let you know ;-)

Back to your problem:
The text after the # has to be the real font name (not the name in the file system). You can find this name by opening the font in the Windows Explorer (with Windows Font Viewer).
It will display "Brandon Grotesque Regular". The Font Viewer appends the font weight if it has one specified, but you have to omit that.
So your font name is Brandon Grotesque.

You can use it like this:

<TextBlock FontFamily="/FontProblem;component/Fonts/BrandonGrotesque-Regular.otf#Brandon Grotesque" />

Or with build action set to content:

<TextBlock FontFamily="/Fonts/BrandonGrotesque-Regular.otf#Brandon Grotesque" />

Tested with your attached solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top