Results 1 to 8 of 8

Thread: [RESOLVED] Font Sized Headache

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Resolved [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

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    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:
    1. Label1.Font = New System.Drawing.Font(fntfam, fntSize!, FontStyle.Regular, GraphicsUnit.Point)

    which also worked for me.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: Font Sized Headache

    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
    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

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Font Sized Headache

    Quote 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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: Font Sized Headache

    Well quick update, I got it to work by doing this:

    Code:
    Label1.Font = New System.Drawing.Font(fntfam, fntSize, Label1.Font.Style Xor FontStyle.Italic, GraphicsUnit.Point)
    I am having some other issues, but I need to figure out what is happening before I just go runnin my mouth. Funny how you can work on something for like an hour and then once you say something about needing help the answer just kind of "pops" up.

    Thanks you guys, I will check back later if I still have issues.....well programming ones anyways cause you cannot help me with my mental...nm

    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

  7. #7
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    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
  •  



Click Here to Expand Forum to Full Width