What is the best way to embed a truetype font within the application i'm developing? Basically i want to make sure a particular font is available to my application when installed on another machine. I have the *.ttf font file and just need a way of embedding it or automatically installing it when the application is run.
Do i need to set the installation program to install the font during installation or can i dynamically load the font during runtime of the application? In fact both would be nice to know.
The application is being developed in C# using .NET 2.0.
Its easier than this seems; you can embed the font as a resource in your app and access it as a strongly-typed property within the Properties namespace of your app. But the given link should be a good starting point.
For the VB-disabled:
Add the font as a resource in your application. Call the resource MyFontLol. You can access this resource (as a byte array) from Properties.Resources.MyFontLol.
I haven't tested the following, but it appears to be workable:
One last note. The PFC stores the font as a GDI+ font. These aren't compatible with some forms controls. From the docs:
it might not be the best way but couldn't you just include the font with your resources and then copy it to the font's folder on the windows dir?
Here's Will's answer, translated to C# (untested):
along with their Paint() method:
This blog post should help you.
Basically you add the font as an embedded resource then load it into a PrivateFontCollection object.