I have been working on a few projects lately, one of them requiring a custom font to be embedded into the Silverlight application. It’s really simple to do.

Open your project in Visual Studio. First thing is to add the new font to your project.

Right click your project in the tree > Add > New Item and select the font from the browser. (Note: You can’t add a font while it sits within your windows folder, copy the font out of the folder to your desktop or something to add it.)

once the font is in the tree, right click it and go to properties.

Build action = Content
Copy to Output Directory = Copy if newer

So they should now include your font into the project when you build it.

Next up is to put it into the XAML.


FontFamily=”./GOTHIC.TTF#Century Gothic”

and TADAHHH! Custom font in your Silverlight app.

So that was pretty simple hey, but there is a problem with it.

If you use Expression Blend to make your Silverlight apps you will run into some issues with using custom fonts. Its a bug that seems to cause a lot of trouble when using custom fonts in your application.

If you try to edit your project in Blend you will probably get this error

You can simply get rid of this error by building the project, but you will notice that when it was loaded in blend, it was loaded as a WPF application and not Silverlight, so you don’t have the state manager and your project tree is empty. So you can edit your current application, but you cannot add new items to it.

The only way around this is to remove the references to the new font in your application until you have finished your application, then add the font references (or you can just comment them out).

So now you can have all your completely outlandish fonts in your applications and its still real text, not pictures!!! Totally sweet.