我正在使用以下代码将字体加载到内存中,以便使用 GDI+ 生成图像:
var fontCollection = new PrivateFontCollection();
fontCollection.AddFontFile(Server.MapPath("~/fonts/abraham-webfont.ttf"));
fontCollection.Families.Count(); // => This line tells me, that the collection has 0 items.
没有异常,但是在AddFontFile
方法运行后 fontCollection Families 属性为空,没有任何异常。
我已验证路径有效(File.Exists
返回true
):
Response.Write(System.IO.File.Exists(Server.MapPath("~/fonts/abraham-webfont.ttf"))); // # => Renders "True"
当我打开文件时,TTF 文件似乎工作正常,所以它不是无效的 TTF 文件:
有什么建议么?