我有一個TrueType字體,它是「Semibold」。我嘗試使用下面的方法:字體不支持'Regular'風格 - 在C#中使用Semibold字體
private FontFamily GetFontFamily(string name)
{
PrivateFontCollection pfc = new PrivateFontCollection();
var path = Server.MapPath("~/Static/webfont/" + name + ".ttf");
pfc.AddFontFile(path);
return pfc.Families[0];
}
private Font GetFont(string name, int size,FontStyle style)
{
return new Font(GetFontFamily(name), size, style);
}
我在哪裏我提供字體的名稱,它找到Sentinel-SemiboldItalic.ttf
字體。作爲FontStyle
,我試圖提供.NET框架(regulary,粗體,斜體,下劃線和刪除)中的任何選項。
不管是什麼,我得到以下錯誤:
Font 'Sentinel Semibold' does not support style 'Regular'.
我該怎麼辦?如何在C#中使用半角字體作爲字體?此外,我可以以某種方式將我的TrueType字體轉換爲常規字體(如果這可以解決問題)?