How do I embed my own fonts in a WinForms app?

Viewed 44194

I want to embed fonts in my WinForms application so that I don't have to worry about them being installed on the machine. I've searched a bit on the MSDN site and found a few hints about using native Windows API calls, for instance Michael Caplan's (sp?) tutorial linked to by Scott Hanselman. Now, do I really have to go through all that trouble? Can't I just use the resource part of my app?

If not I'll probably go the installing route. In that case, can I do that programmatically? By just copying the font file to the Windows\Fonts folder?

I am aware of licensing issues.

5 Answers

Can't I just use the resource part of my app?

Yes, but need to be native resources rather than .NET resources (i.e. using rc.exe, the native resource compiler).

i will go with knighter's way of embedding a font but when it comes to changing your font I choose this code:

YourLabel.Font = new Font("Arial", 24,FontStyle.Bold);

for more information: Easiest way to change font and font size

Related