How do I use a custom .tff font file I have with my current windows.forms application? I read some where that I use it as an embedded resource, but how do I set it the System.Drawing.Font type?
+1
A:
Use the AddFontResourceEx API function through p/invoke, passing FR_PRIVATE to prevent installing a global font. Then you should be able to pass the font name to the Font constructor as usual.
Edit: If you use the PrivateFontCollection and load the font from an external file, you don't even need this. If you load the font from an embedded resource, use Ash's solution.
Thomas
2009-02-13 03:38:42
Is there an example some where? I can really understand the MSDN link. Thank you for you help.
kthakore
2009-02-13 03:43:57
+2
A:
This article: How to embed a true type font shows how to do what you ask in .NET.
See the Form1_Paint event handler, it shows specifically how to set the System.Drawing.Font type. It is based on using the System.Drawing.Text.PrivateFontCollection class.
Hope this helps.
Ash
2009-02-13 03:50:08