D
deskcheck1
Guest
I'm developing a Windows desktop Form application using VS2019. I am using a Google True Type Font Family, "Federo-Regular.ttf". I want to use it for some controls on my Form1. The custom font is loaded via a method when Form1 loads:
Private Sub SetForm1CustomFont()
Dim privateFonts As New System.Drawing.Text.PrivateFontCollection()
Dim filePath As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Federo-Regular.ttf")
privateFonts.AddFontFile(filePath)
Dim font24 As New System.Drawing.Font(privateFonts.Families(0), 24)
Dim font12 As New System.Drawing.Font(privateFonts.Families(0), 12)
Me.LblLogo.Font = font24
Me.LblProjects.Font = font24
Me.BtnNew.Font = font12
Me.BtnOpen.Font = font12
Me.BtnCopy.Font = font12
Me.BtnRename.Font = font12
Me.BtnDelete.Font = font12
Me.BtnExitApp.Font = font12
End Sub
However, when the form loads, I get an error "Parameter is not valid" at System.Drawing.FontFamily.GetName(Int32 language) at System.Drawing.FontFamily.get_Name()
I placed the ttf file inside the Debug folder of the project. Another thing, the Labels and Buttons affected are placed inside a SplitContainer panel. I wonder if that's affecting this.
Appreciate any help.
Marilyn Gambone
Continue reading...
Private Sub SetForm1CustomFont()
Dim privateFonts As New System.Drawing.Text.PrivateFontCollection()
Dim filePath As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Federo-Regular.ttf")
privateFonts.AddFontFile(filePath)
Dim font24 As New System.Drawing.Font(privateFonts.Families(0), 24)
Dim font12 As New System.Drawing.Font(privateFonts.Families(0), 12)
Me.LblLogo.Font = font24
Me.LblProjects.Font = font24
Me.BtnNew.Font = font12
Me.BtnOpen.Font = font12
Me.BtnCopy.Font = font12
Me.BtnRename.Font = font12
Me.BtnDelete.Font = font12
Me.BtnExitApp.Font = font12
End Sub
However, when the form loads, I get an error "Parameter is not valid" at System.Drawing.FontFamily.GetName(Int32 language) at System.Drawing.FontFamily.get_Name()
I placed the ttf file inside the Debug folder of the project. Another thing, the Labels and Buttons affected are placed inside a SplitContainer panel. I wonder if that's affecting this.
Appreciate any help.
Marilyn Gambone
Continue reading...