以下是如何在C#中执行此操作的示例:
System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection(); privateFonts.AddFontFile("C:\\Documents and Settings\\somefont.ttf"); System.Drawing.Font font = new Font(privateFonts.Families[0],12); label1.Font = font;
或者,在VB.NET中:
Dim privateFonts As New System.Drawing.Text.PrivateFontCollection() privateFonts.AddFontFile("C:\Documents and Settings\somefont.ttf") Dim font As New System.Drawing.Font(privateFonts.Families(0),12) label1.Font = font
查看THIS了解更多详情.