0

我正在使用可以在本地正常加载的自定义字体,但是当我将其上传到我的 Web 服务器时,会使用默认的回退。不过没有例外,我觉得这很奇怪。

这是我用来加载字体的Application_Start内容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 什么也没记录。在我使用的大约 15 种字体中,大约有一半只是默默地失败了。我不确定要检查什么。

4

1 回答 1

0

这是由于尝试使用不受支持的字体变体引起的。例如:当 TTF 仅包含常规时,加粗。

于 2013-09-21T18:18:00.873 回答