Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 可以在winforms上使用otf字体吗?_C#_Winforms_Opentype - Fatal编程技术网

C# 可以在winforms上使用otf字体吗?

C# 可以在winforms上使用otf字体吗?,c#,winforms,opentype,C#,Winforms,Opentype,我尝试过在标签、文本框和绘画活动中使用开放式字体。但它不起作用。有什么方法可以使开放式字体工作吗?这在Winforms中是不可能的,GDI+只支持TrueType字体。您必须移动到WPF以获得OpenType支持。您可以像在WPF中一样使用System.Windows.Media命名空间,这里有一个示例: public static string GetFontList(String ElementSeparator) { string r = "";

我尝试过在标签、文本框和绘画活动中使用开放式字体。但它不起作用。有什么方法可以使开放式字体工作吗?

这在Winforms中是不可能的,GDI+只支持TrueType字体。您必须移动到WPF以获得OpenType支持。

您可以像在WPF中一样使用
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;
    }  

Font textFont=新字体(“Arial粗体”,18F);g、 抽绳(“12”,textFont,solidbrush,109,40);你为什么不能这样使用呢?我可以,但我只能用真字体。也就是说,Myriad Pro不起作用。它以什么方式不起作用?@Frederik-屏幕上呈现的字体没有改变。它仍然是微软的无衬线。当尝试创建标签时,一个对话框告诉我标签只支持True Type字体。