C#使用自己的字体而不安装它

Bar*_*run 4 c# fonts

可能重复:
如何在C#应用程序中嵌入字体?(使用Visual Studio 2005)

嗨,

我想将自己的字体用于文本框,而无需在客户端计算机中安装它.我希望它驻留在我的程序文件应用程序文件夹中.[我知道大多数游戏应用程序都使用自己的字体].我该怎么做 ?

谢谢.

Dan*_*lba 7

我想你需要这个:

// 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;
Run Code Online (Sandbox Code Playgroud)