Silverlight: How to obfuscate a font and use it in a Silverlight Application

You have your design almost in the bag, you have a font that you want to use but how can you use that font in Silverlight. Without distributing a font (which would be illegal unless you had a license to do this) requires you to obfuscate the font. Obfuscating the font means taking the font and converting it into an un-usable format outside your application.

So to convert you font follow this simple steps:

  1. Open up Word 2007
  2. Type every character, digit and symbol that you might need.
  3. Then select all the copy in the word document and change the font to the desired font.
  4. Save the document as an XPS file.
  5. Now close word and find the XPS file you have just created.
  6. Rename the file from .xps to .zip
  7. Now open that zip file and look inside the ‘Resources’ directory and you should see a file with the extension .odttf
  8. Copy the .odttf file into your Silverlight Application and set it’s build action to ‘Resource‘ (see our tutorial on Silverlight Build Actions)
  9. Now on a TextBlock in your page set the FontFamily location to your .odttf file

This is how you set the FontFamily on your TextBlock

The font name (the bold bit!) ‘Segoe UI‘ you see in the FontFamily path after the # needs to be exactly the same as what appears in your Word document dropdown list. This selects the font with the .odttf as you could have multiple fonts within the same .odttf file.

If you have any questions or need any help simply create a post at Silverlight Forums in the Fonts section.