[RESOLVED] Font Sized Headache
I am getting an error on this code:
Code:
Dim fntfam As String = ComboBox1.Text
Dim fntSize As Single = CInt(ComboBox2.Text)
Label1.Font = New System.Drawing.Font(fntfam, fntSize!, Label1.Font.Style, GraphicsUnit.Point)
The error is:
Code:
Font 'Vivaldi' does not support style 'Regular'
I am not finding anything related to visual studio 2005 relating to this question, google gives me all results that are system wide. This only does this in my program when I run it. Vivaldi works in all other office programs. What am I doing incorrectly?? :confused:
As always, thank you all for you assistance...
D
Re: [RESOLVED] Font Sized Headache
FYI, the FontFamily object has a function called .IsStyleAvailable. You can use that to check if the font family supports your proposed style.
Re: [RESOLVED] Font Sized Headache
Funny you mention that because I was just implementing that very thing!!!
Final code that works with NO issues. NONE, NADA, NIL, Zip, zilch ok you get the idea.....:lol:
Code:
'get font selected
Dim fntfam As String = cboHeaderFontType.Text
'get font size
Dim fntSize As Single = CInt(cboHeaderFontSize.Text)
'declare new font and set it to what was selected
Dim myfontfamily As New FontFamily(fntfam)
'Test
Dim fnt As New Font(fntfam, fntSize, _
(IIf(myfontfamily.IsStyleAvailable(FontStyle.Regular), FontStyle.Regular, FontStyle.Italic)), GraphicsUnit.Point)
'Set font
Label1.Font = fnt
'Applaud for it has worked and all is well with the world once again.
Thank you all again for your assistance!!
D