我正在使用可以在本地正常加载的自定义字体,但是当我将其上传到我的 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 种字体中,大约有一半只是默默地失败了。我不确定要检查什么。