PrivateFontCollection fails on appharbor
Posted
by
grennis
on Stack Overflow
See other posts from Stack Overflow
or by grennis
Published on 2012-11-29T14:28:08Z
Indexed on
2012/11/29
17:04 UTC
Read the original article
Hit count: 183
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?
© Stack Overflow or respective owner