Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using custom fonts in my winform labels

I wonder if its possible to use a custom font for my form labels without installing it on the users machine? I would like to display a text using a font I have rights to, but its not installed on the potencial user machine.

Are there any solutions for this?

like image 368
Scott Avatar asked Jan 15 '23 22:01

Scott


2 Answers

Here is the extract (using PrivateFontCollection):

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

Converted from here: Load And Use Custom Font Without Installing It.

Also check this: Embedding/deploying custom font in .NET app

like image 121
Neolisk Avatar answered Feb 20 '23 17:02

Neolisk


Add this code in Top of your Code

Imports System.Drawing.Text

Add this code on Form1_Load() to change the Lablel1.Font

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

Tested on Visual Basic 2010 Enterprises Edition

like image 31
gfxdevelopers Avatar answered Feb 20 '23 19:02

gfxdevelopers