Windows Phone 7 Custom Fonts

20 June 2011

I found a blog post on adding custom font support to Windows Phone 7, but it didn’t quite work for me so I’m posting up the steps i took to get this working.

Step 1 - Ensure you have the right font

Windows Phone requires you to have your font in TrueType format (.ttf). If you have an Open Type Format (.otf) font they will not work, and you will need to get help converting them to ttf format.

Step 2 - Add the font to your project

Add the font files to your project, i’d recommend somewhere like /Resources/Fonts/CustomBold.ttf for example.

In Visual Studio, right click on the font file and select Properties. Ensure the Build Action is set to Content.

Step 3 - Add a FontFamily element to App.xaml

Open up your App.xaml file and add a FontFamily reference for the font you have just added as follows. You can then easily include your custom font in other custom styles across your application.

<FontFamily x:Key="CustomBold">/Resources/Fonts/custombold.ttf#Custom Bold</FontFamily>

That bit after the hash is the font name. You can view this by opening the font and it will be displayed at the top left as ‘Font name: Custom Bold’.

Step 4 - Use your custom font

You are then free to use the custom font. Below shows how to do this directly but you would more commonly have the FontFamily used within some other custom style.

<TextBlock FontFamily="{StaticResource CustomBold}" Text="Custom Bold Oh My!" />
Want to get started?

We would love to help with your next app or game, please do get in touch.