Tuesday, 10 June 2008

Font Embedding in Silverlight 2 beta 2

I added a font to my SilverNibbles game this weekend as part of converting to beta 2. You can see it in action here.

The way to do this is relatively straightforward:

1. Add your font to the project. The build action should be Resource. You do not need to copy to the output directory. Visual Studio will put it into your DLL file at compile time. (n.b. If you choose Content instead, it will go into your XAP file which also works, but apparently loading fonts from the XAP will not be supported after beta 2 so this method is not recommended)

2. Now whenever you need to use the font, simply use the syntax FontFamily="Font Name.ttf#FontName".

Font Embedding in Silverlight

And that is all there is to it. 

Post a Comment