Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain installed fonts as a list

Tags:

c#

.net

fonts

is there any way I can obtain installed fonts as a list (or array, but I prefer a List).

So like a method that will out all installed fonts to a list. I have so far created this

List<string> fonts = new List<string>();
fonts.AddRange() //I don't know what to put in those brackets to obtain fonts.

Can someone provide a better way?

like image 737
Naufal Fikri Avatar asked Dec 28 '11 15:12

Naufal Fikri


1 Answers

You want the InstalledFontCollection class:

using System.Drawing.Text;
using (InstalledFontCollection fontsCollection = new InstalledFontCollection())
{
    FontFamily[] fontFamilies = fontsCollection.Families;
    List<string> fonts = new List<string>();   
    foreach (FontFamily font in fontFamilies)
    {
       fonts.Add(font.Source);
    }
}
like image 112
George Stocker Avatar answered Oct 03 '22 07:10

George Stocker