PrivateFontCollection fails on appharbor
- by grennis
I am trying to load a custom font (ttf file) and draw into an image with the Graphics object. This code runs fine locally:
PrivateFontCollection fonts = new PrivateFontCollection();
string path = context.Server.MapPath("~/App_Data/Futura LT Bold.ttf");
if (!System.IO.File.Exists(path))
{
throw new InvalidOperationException("Font file is not deployed: " + path);
}
fonts.AddFontFile(path);
However when run on appharbor, the call to AddFontFile fails with the exception:
System.ArgumentException: Font 'Futura LT Book' does not support style 'Regular'.
at System.Drawing.Font.CreateNativeFont()
at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font..ctor(FontFamily family, Single emSize)
at LumenboxWeb.Controllers.GalleryController.FontTest() in d:\temp\h5oqslma.udd\input\src\LumenboxWeb\Controllers\GalleryController.cs:line 59
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
I have tried different fonts, and they all work locally, but none work on appharbor.
Is it possible to load fonts dynamically on appharbor?