如何在 Windows Azure Web Apps 中发布和使用字体?

我正在尝试在我的 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 字体。


人到中年有点甜
浏览 130回答 1
1回答

函数式编程

所有基于 wkhtmltopdf 或 phantomjs 的 PDF 生成器的已知问题:自定义字体未呈现(使用系统安装的字体代替),因为即使在基于 VM 的 Azure 应用程序计划(基本或更高版本)中也存在沙盒 GDI API 限制。
打开App,查看更多内容
随时随地看视频慕课网APP