Using OTF fonts in a Windows 10 (WinRT) app

Universal windows 10 apps support OTF fonts but to use them you might have to change the generated XAML a bit.

This tutorial uses the beautiful Edmondsans font, created by James T.Edmondson, to demonstrate how to use OTF fonts in WinRT.



Open the font to inspect the Font name (Edmondsans Regular):

font info

XAML like this is created:

FontFamily="Edmondsans-Regular.otf#Edmondsans Regular"

Which strangely results in text rendered with the system font:


How to show the proper OTF font?



And this is how to show Edmond sans in regular, medium and bold weight:

<TextBlock Text="Edmondsans Regular" FontFamily="Edmondsans-Regular.otf#Edmondsans" />
<TextBlock Text="Edmondsans Medium" FontFamily="/Edmondsans-Medium.otf#Edmondsans" />
<TextBlock Text="Edmondsans Bold" FontFamily="/Edmondsans-Bold.otf#Edmondsans" />

all weights

Written by Loek van den Ouweland on May 20, 2015. Questions regarding this artice? You can send them to the address below.