以下是2中c#读取系统字体列表的方式
第一种:
public void ReadOne()
{
this.zlist.Items.Clear();
RegistryKey rkey = Registry.LocalMachine;
RegistryKey rkeyInfo = rkey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts");
foreach (string strFonts in rkeyInfo.GetValueNames())
{
if (strFonts.LastIndexOf("(") == 0)
this.zlist.Items.Add(strFonts);
else
{
try
{
this.zlist.Items.Add(strFonts.Substring(0, strFonts.LastIndexOf("(")));
}
catch { }
}
}
}
第二种:
public void ReadTwo()
{
this.zlist.Items.Clear();
InstalledFontCollection fontcol = new InstalledFontCollection();
FontFamily[] fontFamilies = fontcol.Families;
foreach (FontFamily fontFamily in fontFamilies)
{
//打印字体名字
this.zlist.Items.Add(fontFamily.Name);
}
}