在我的winform标签中使用自定义字体

时间:2012-11-26 22:02:43

标签: vb.net visual-studio-2010

我想知道是否可以在我的表单标签上使用自定义字体而无需在用户计算机上安装它?我想使用我有权使用的字体显示文本,但它没有安装在有用的用户机器上。

对此有什么解决方案吗?

2 个答案:

答案 0 :(得分:8)

以下是摘录(使用PrivateFontCollection):

Dim pfc As New PrivateFontCollection()
pfc.AddFontFile("C:\Path To\PALETX3.ttf")
label1.Font = New Font(pfc.Families(0), 16, FontStyle.Regular)

从此处转换:Load And Use Custom Font Without Installing It

同时检查:Embedding/deploying custom font in .NET app

答案 1 :(得分:1)

将此代码添加到您的代码顶部

Imports System.Drawing.Text

在Form1_Load()上添加此代码以更改Lablel1.Font

Dim customfont As PrivateFontCollection = New PrivateFontCollection
customfont.AddFontFile("C:\maven.ttf")
Label1.Font = New Font(customfont.Families(0), 10)

在Visual Basic 2010企业版上测试