|
-
Jan 2nd, 2019, 07:26 PM
#1
Thread Starter
Hyperactive Member
Using Custom Fonts
In my forms load event I placed the following code to load and use a custom font I purchased (all licensed and good to go for projects):
IO.File.WriteAllBytes("test.ttf", My.Resources.RaintreeBold)
Dim pfc As New PrivateFontCollection()
pfc.AddFontFile("test.ttf")
MyLabel.Font = New Font(pfc.Families(0), 14)
When I run the program I get a "Parameter is not Valid" general error, but not as the code above is executed. It happens on an Update() or .ShowDialog() call right before the window is displayed.
What is truly odd is that sometimes the code works; I see my label with the correct font. Then I run the program again and it doesn't having changed nothing. Then I run it again and the error occurs again.
From what I have researched the "Parameter is not Valid" error is happening during the GDI drawing of the form. Is the font somehow lost after it is initially loaded in the Load event? What am I doing wrong here for what should be a basic task?
Thanks in advance.
Intermediate Level Programmer Extraordinaire 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|