I am trying to publish and use a font on my Windows Azure web app.
The font file is bahnschrift.ttf. I can see the file at the correct location on Azure so I’m sure it was published correctly.
I want to use the font to draw text onto an image.
This code using PrivateFontCollection works in the Visual Studio debugger on my Windows 10 machine. It does not work when published to Azure.
I also tried setting the MIME type in my web.config file but that didn’t change anything.
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>
I want to be able to use the TTF font on Windows Azure.