0

i have two comboboxes combobox1 & combobox2 i am getting all system fonts in combobox1 i need to get fontstyles of a select font in combobox2

 Dim fc As New Drawing.Text.InstalledFontCollection
    Dim ff As FontFamily() = fc.Families()
    For Each family As FontFamily In ff
        Me.ComboBox1.Items.Add(family.Name)
    Next

when i select font name for eg. Monotype Corsiva font have only italic & italic bold font style

in brief i need to get fontstyles related to the font i select in combobox1 because fontstyles are different for different fonts

Dandy
  • 467
  • 1
  • 10
  • 33
  • Have a look at this related [SO Question](http://stackoverflow.com/questions/3633000/net-enumerate-winforms-font-styles) – Tim Lentine Nov 20 '12 at 12:59

1 Answers1

0

These font names are synthesized from the added font styles that are available in later typography, particularly the styles added in OpenType. They map back to the old GDI styles imperfectly. The trick your are seeing used is modifying the family name from Monotype to "Monotype Corsiva", a strong hint that only italic ("cursive") styles are available. The same kind of mapping trick is used for the various added bold styles and pitch, names like "Semibold" and "Condense".

Since you've only got the FontStyle enumeration available to pick a font in your code, using the FontFamily.IsStyleAvailable() method to check which styles are mapped should work just fine. You'll want to give the user a preview of what the font looks like, just like the FontDialog class does, so there's little confusion about the end result. Do favor FontDialog in general.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • but fonstyle enum in vb2005 has only 5 fonstyles: bold, regular, italic, underline, strikeout how do i check semibold and condense fonstyles – Dandy Nov 21 '12 at 09:35