C# Get all available FontFamily

Tom Gullen picture Tom Gullen · Mar 17, 2011 · Viewed 11.7k times · Source

I have an input box, and people type a font in and it saves what they type as a JPEG. All works fine. But when they type a font name like 'times new roman' it has to be capitalised properly to 'Times New Roman' or it wont work!

Can I just iterate all the available fonts somehow and present it to them as a dropdown list so there are no spelling problems and they definitely will only be using fonts on the system?

Answer

Kyrylo M picture Kyrylo M · Mar 17, 2011

Simply use next code:

FontFamily[] ffArray = FontFamily.Families;
foreach (FontFamily ff in ffArray)
{
    //Add ff.Name to your drop-down list
}