是否有可能在winforms上使用otf字体?

Bil*_*soe 4 c# opentype winforms

我尝试过使用Open Type Fonts作为标签,文本框以及在绘画事件中绘图时.但它不起作用.有没有办法让Open Type Font工作?

Han*_*ant 9

这在Winforms中是不可能的,GDI +仅支持TrueType字体.您必须转到WPF才能获得OpenType支持.


小智 5

System.Windows.Media您可以像在 WPF 中一样使用命名空间,这里有一个示例:

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;
    }  
Run Code Online (Sandbox Code Playgroud)