カスタムフォント(ttfファイル)をロードして、Graphicsオブジェクトを使用して画像に描画しようとしています。このコードはローカルで正常に実行されます。
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);
ただし、appharborで実行すると、AddFontFileの呼び出しは次の例外を除いて失敗します。
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)
私はさまざまなフォントを試しましたが、それらはすべてローカルで機能しますが、appharborでは機能しません。
appharborでフォントを動的にロードすることは可能ですか?