gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:35:45 32 4
gpt4 key购买 nike

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

最佳答案

Known issue for all PDF generators based on wkhtmltopdf or phantomjs: custom fonts are not rendered (system-installed font is used instead) because of sandbox GDI API limitations that present even in VM-based Azure Apps plans (Basic or higher).

引用此document更多细节。

您可以使用应用服务中的 Windows 容器来应用自定义字体: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-windows-containers-custom-fonts

请查看这个类似的反馈帖子 here .

关于c# - 如何在 Windows Azure Web Apps 中发布和使用字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56721468/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com