tags:

views:

763

answers:

2

I would like to create a dropdown in which the available Font names are displayed, in addition to the styles in which the font is available. Can anyone provide me with some information or code examples that I might be able to use in order to get started?

+3  A: 

Call FontFamily.Families to get the collection of font families on the system, or FontFamily.GetFamilies(Graphics) to get the families for a given graphics context. Then for each font call FontFamily.IsStyleAvailable to determine support for bold, italic, etc.

itowlson
i want exact coding for that i don't have any idea regarding this code
Yagnesh84
+2  A: 
foreach (FontFamily fontFamily in FontFamily.Families)
{
    if (fontFamily.IsStyleAvailable(FontStyle.Regular))
    {
        fontComboBox.Items.Add(fontFamily.Name + " (Regular)");
    }

    if (fontFamily.IsStyleAvailable(FontStyle.Bold))
    {
        fontComboBox.Items.Add(fontFamily.Name + " (Bold)");
    }

    if (fontFamily.IsStyleAvailable(FontStyle.Italic))
    {
        fontComboBox.Items.Add(fontFamily.Name + " (Italic)");
    }

    if (fontFamily.IsStyleAvailable(FontStyle.Underline))
    {
        fontComboBox.Items.Add(fontFamily.Name + " (Underline)");
    }

    if (fontFamily.IsStyleAvailable(FontStyle.Strikeout))
    {
        fontComboBox.Items.Add(fontFamily.Name + " (Strikeout)");
    }
}
ICR
N.B. This doesn't take into account combined styles, like Bold+Underline.
ICR