|
-
May 4th, 2007, 10:35 AM
#1
Thread Starter
Fanatic Member
[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??
As always, thank you all for you assistance...
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
May 4th, 2007, 10:43 AM
#2
Re: Font Sized Headache
Like the error say, the font 'Vivaldi' does not support style 'Regular', it might only support Bold, Italic....I dont know, but it sure doesnt support regular
You'd need to put that code in a Try-Catch block, as you can not prevent these errors
-
May 4th, 2007, 10:44 AM
#3
Re: Font Sized Headache
That's weird though because the code works for me 'as is'.
Maybe try changing it to this as a test to see if it can work:
vb Code:
Label1.Font = New System.Drawing.Font(fntfam, fntSize!, FontStyle.Regular, GraphicsUnit.Point)
which also worked for me.
-
May 4th, 2007, 10:53 AM
#4
Thread Starter
Fanatic Member
-
May 4th, 2007, 11:01 AM
#5
Re: Font Sized Headache
 Originally Posted by dminder
LOL @ Atheist, yes I realize what the error meant....Poorly posted and duly noted.
Stimbo: for most fonts that has/will work, however with some fonts, specifically Vivaldi it does not. I am putting each font (over 300 on my system alone) to the test and see what works and what does not
Everyone: I have already put it into a try catch block, however any ideas on what I need to do to get these fonts available for use? If I default to italic it will work for vivaldi but some of these wont work with italic and I get a similar error. Anybody have any ideas as to how to get around this?
Thanks
D
What do you mean by 'get these fonts available for use'?
Vivaldi can not be used with regular, no matter how you do.
-
May 4th, 2007, 11:08 AM
#6
Thread Starter
Fanatic Member
-
May 4th, 2007, 11:54 AM
#7
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.
-
May 4th, 2007, 12:11 PM
#8
Thread Starter
Fanatic Member
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.....
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
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
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
|