I'm embedding a font in my windows forms application as embedded resource, and want to use it in a TextBox.
The help of AddMemoryFont() says I have to set compatible text rendering to true in order to use GDI+, and so my font can then be used. But somehow it just won't display the right font.
In Program.cs I explicitly state:
Application.SetCompatibleTextRenderingDefault(true);
So why is it not working? Anybody got a clue on how to set a custom font to a TextBox?
Okay, I figured it out thanks to the interwebs and Google.
For future reference, if anybody has this problem, the fix is : after getting your embedded font as a stream, and before calling AddMemoryFont, you have to call AddFontMemResourceEx ! (Not available in C# so you have to import it :
and then :
And presto, you'll be able to use the font. Without the AddFontMemResourceEx it wont work.