我正在尝试在我的 Windows Azure Web 应用程序上发布和使用一种字体。
字体文件是 bahnschrift.ttf。我可以在 Azure 上的正确位置看到该文件,因此我确定它已正确发布。
我想使用字体将文本绘制到图像上。
这段使用 PrivateFontCollection 的代码可以在我的 Windows 10 机器上的 Visual Studio 调试器中运行。它在发布到 Azure 时不起作用。
我还尝试在我的 web.config 文件中设置 MIME 类型,但这并没有改变任何东西。
private static FontFamily GetFontBahnschrift() {
PrivateFontCollection fonts = new PrivateFontCollection();
string file = HttpContext.Current.Server.MapPath("~/img/bahnschrift.ttf");
fonts.AddFontFile(file);
FontFamily fontBahnschrift = fonts.Families.First(p =>
p.Name.Equals("Bahnschrift Bold",
StringComparison.CurrentCultureIgnoreCase));
return fontBahnschrift;
}
<system.webServer>
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
</staticContent>
</system.webServer>
我希望能够在 Windows Azure 上使用 TTF 字体。
函数式编程
相关分类