Obtain installed fonts as a list

早过忘川 提交于 2020-01-23 07:53:12

问题


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?


回答1:


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);
    }
}


来源:https://stackoverflow.com/questions/8657821/obtain-installed-fonts-as-a-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!