Embedding fonts in Silverlight

Sun, Dec 27, 2009

Silverlight, Tutorials

In this tutorial I will show how to embed a font in Silverlight and show the increase in file size that will occur when doing so.

Placing a Textblock component on the stage and using a built-in Silverlight font such as “Arial” the xap file created will be 4 kb. However, if try to use a font such as “Myriad Pro” when you view the results panel you will see a message “The font, Myriad Pro, isn’t a built-in Silverlight font. You must embed this font for it to display in your Silverlight Application.”

silverlight-embedding-fonts

Embedding a font is as simple as selecting the “Embed” checkbox in the text properties panel.
One thing to note when embedding the font “Myriad Pro” the xap file size becomes 831 kb.

silverlight-embedding-fonts2

XAML code

<TextBlock FontFamily="Fonts/Fonts.zip#Myriad Pro" FontSize="16" Foreground="White" Text="TextBlock" TextAlignment="Center" TextWrapping="Wrap"/>
, , ,

2 Responses to “Embedding fonts in Silverlight”

  1. Koistya `Navin Says:

    Pixel Fonts for Silverlight and WPF at CodePlex.com

    http://pixelfonts.codeplex.com/


Trackbacks/Pingbacks

Leave a Reply