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:
- Open up Word 2007
- Type every character, digit and symbol that you might need.
- Then select all the copy in the word document and change the font to the desired font.
- Save the document as an XPS file.
- Now close word and find the XPS file you have just created.
- Rename the file from .xps to .zip
- Now open that zip file and look inside the ‘Resources’ directory and you should see a file with the extension .odttf
- Copy the .odttf file into your Silverlight Application and set it’s build action to ‘Resource‘ (see our tutorial on Silverlight Build Actions)
- 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.