我尝试在标签、文本框和绘画事件中使用开放式字体,但都无法生效。是否有办法让开放式字体正常工作?
我尝试在标签、文本框和绘画事件中使用开放式字体,但都无法生效。是否有办法让开放式字体正常工作?
在Winforms中不可能实现,因为GDI+仅支持TrueType字体。您需要转向WPF以获得OpenType支持。
System.Windows.Media
命名空间,这里有一个例子:public static string GetFontList(String ElementSeparator)
{
string r = "";
// WPF incl Adobe and OpenType
foreach (System.Windows.Media.FontFamily fontFam in System.Windows.Media.Fonts.SystemFontFamilies)
{
r += fontFam.Source;
r += ElementSeparator;
}
// True type, incl Type face names e.g. Arial Rounded MT Bold
foreach (System.Drawing.FontFamily f in System.Drawing.FontFamily.Families)
{
if(!r.Contains(f.Name))
{
r += f.Name;
r += ElementSeparator;
}
}
return r;
}