Windows 8 XAML Tips – Custom Fonts

By Fons Sonnemans, 12-6-2012

It is time for me to write a series of blog items on writing XAML applications for Windows 8. I plan to write one every two weeks. I hope I can keep up the promise.

Custom Fonts

I have developed XAML applications in Silverlight (Browser and Phone) for a couple of years. I used custom fonts in those Apps using Expression Blend. It contains a Font Manager which you can use to embed a font into the application (project/assembly). Blend for Visual Studio doesn’t allow you to use the Font Manager. The menu option is disabled in this Release Candidate. I hope to get it back in a future version.

The default FontFamily in a Metro app is ‘Segoe UI’ which is called ‘Global User Interface’ in Blend. You can of course use Blend or Visual Studio to select another FontFamily. But if your user doesn’t have this font installed you will get the default font. That’s why you will have to add the font to the application.

Luckily it is possible to add it to the application manually. For this demo I will be using a free true type font called 123Sketch which I downloaded here: First I created a new folder in my project named ‘Fonts’. I added my font file to this folder. The Build Action for the file is set to ‘Content’ which is required.

123Sketch.ttf added to the Fonts folder

You reference the font file and font name in your XAML using the following format:
FontFamily="/<path to font file>/<font file>#<font name>"

So in my case a TextBlock would be defined like this.

    Text="Hello World"
    FontFamily="/Fonts/123Sketch.ttf#123Sketch" />

FontFamily Resource

It is smart to create a Resource for this FontFamily property. This will make it easier for you if you want to change the font for another one. In Blend you can convert the FontFamily by clicking on the white square next to the dropdown.

Convert FontFamily to New Resource

You will get a dialog in which you can set the name (key) of the resource and the location where it will be defined. In this demo I named it ‘MyCustomFont’ and defined it in ‘This Document’. Choosing the ‘Application’ or a ‘Resource Dictionary’ would make this resource reusable in other documents.

Create FontFamily Resource

You can now use the resource for the FontFamily property in other elements. Just pick it from the ‘Local Resource’.

Assign Local Resource


The XAML of the Page including the static resource and two TextBlock elements would look like this.


        <!-- TODO: Move the next line to App.xaml or a ResourceDictionary -->

        Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

            FontFamily="{StaticResource MyCustomFont}" />

            FontFamily="{StaticResource MyCustomFont}" />


If you start the application in the Simulator you get this result.

Simulator showing the result

I hope this helps you. Fonts often are copyright protected. So if you want to add one make sure you have the rights or use a free one.



Leave a Comment

Leave a Comment
8 + 7 =


  • Parth
    21 mei 2013 07:32
    Hi this is nice post and its working but i would like to apply this fonts in phone:browser control which is in windows phone. have you any idea ?

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.