#817 – Embedding a Font into Your Application

When you specify fonts that are to be used with your application, you typically specify font attributes, like FontFamily, and then let Windows look for a previously installed font that matches what you’re asking for.

If you have a non-standard font that you want to use and you have a copy of the TrueType (.ttf) file for the font, you can embed the font in your application, to make sure that your font gets used at run-time.

To embed a font, do the following:

Copy the font (.ttf file) into your project directory.  Add the font to your project by right-clicking on the project and selecting Add Existing Item.


Set the filter to All Files, find and select the .ttf file, and click Add.



Set the Build Action for the font to Resource.


Finally, set the FontFamily property to the font’s name, prefixing the name with “./#”.