6

Possible Duplicate:
How do I Embed a font with my C# application? (using Visual Studio 2005)

Hi,

I want to use my own font into a textbox without install it in client machine. I want it to reside into my program file application folder.[I know most of game applications use their own font like that]. How can I do it ?

Thanks.

Community
  • 1
  • 1
Barun
  • 1,885
  • 3
  • 27
  • 47

1 Answers1

13

I think that you need this:

// Be sure to dispose your PrivateFontCollection
// and Font to avoid an easy leak!
System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection();
privateFonts.AddFontFile("c:\myapplication\mycustomfont.ttf");
System.Drawing.Font font = new Font(privateFonts.Families[0], 12);
this.textBox1.Font = font;
Daniel Peñalba
  • 30,507
  • 32
  • 137
  • 219