Tuesday, May 14, 2013

#817 – Embedding a Font into Your Application

Inline image 2

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.

...
...

Finally, set the FontFamily property to the font's name, prefixing the name with "./#".

Inline image 1


QR: Inline image 3