Add font at run time .Net Or Font VB Net Or Install Font run time You could install or add font at run time for particularly use in your project. This sample code is for installing font to project at run time in Vb.Net. Solution: Namespace required:
Imports System Global Declaration:
Dim PFC As
Drawing.Text.PrivateFontCollection
Dim
NewFont_FF As Drawing.FontFamily Function Call:
CreateFont(Application.StartupPath
& "\font.ttf", 20, FontStyle.Regular, GraphicsUnit.Point) Function Defination:
Private Function
CreateFont(ByVal name As String, ByVal size As Single, ByVal style As
Drawing.FontStyle, ByVal unit As Drawing.GraphicsUnit) As Drawing.Font
PFC = New
Drawing.Text.PrivateFontCollection
PFC.AddFontFile(name)
NewFont_FF =
PFC.Families(0)
Return New
Drawing.Font(NewFont_FF, size, style, unit)
End Function Eplanation:
You need to have font file in your Debug folder for this. And you must edit Fontname in argument of CreateFont function If want to check live project example download this project. Here you would find installation of font run time using Vb.Net.
|