Installed Font Name List Using Generator

Description: This is a simple function for generating a list of installed font names. Great for drop down menus that need to see the type of fonts installed and then used to select that font.
Tested Platform: .NET 4.5, Visual Studio 2012, Windows 7
Language: C#
// List installed font family names using a font generator list.

public static IEnumerable<string> listInstalledFonts()  {
    System.Drawing.Text.InstalledFontCollection InstalledFonts = new System.Drawing.Text.InstalledFontCollection();

    FontFamily[] families = InstalledFonts.Families;

    for (int i = 0; i < families.Length; i++) {
        yield return families[i].Name;
    }
}

Submitted: April 25, 2013

Return to the snippets listing