문제

I'm using a custom font which loads fine locally, but whn I upload it to my web server, a default fallback is used. No exception is thrown though, which I fine bizarre.

Here's what I'm using to load the font in Application_Start in global.asax:

try {
        // Code that runs on application startup
        var fontNames = Directory.GetFiles(HostingEnvironment.MapPath("~/fonts/labels/"));
        var pfc = AppCache.GetCachedFonts(); // static class, returns PFC from the HttpContext's cache
        fontNames.ForEach(f =>{
                                  try {
                                      pfc.AddFontFile(f);
                                  } catch(Exception ex) {
                                      Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                                  }
        });
    } catch (Exception ex) {
        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
    }

Elmah logs nothing though. Out of maybe 15 fonts I'm using, around half just fail silently. I'm not sure what to check.

도움이 되었습니까?

해결책

This was caused by trying to use an unsupported variant of a font. Eg: Bold when the TTF only includes regular.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top