获取已安装的字体作为列表

有没有办法我可以获得已安装的字体作为列表(或数组,但我更喜欢List)。

所以就像将所有已安装的字体排列到列表中的方法一样。 到目前为止,我创造了这个

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

有人可以提供更好的方法吗?

您想要InstalledFontCollection类:

 using System.Drawing.Text; using (InstalledFontCollection fontsCollection = new InstalledFontCollection()) { FontFamily[] fontFamilies = fontsCollection.Families; List fonts = new List(); foreach (FontFamily font in fontFamilies) { fonts.Add(font.Source); } }