是否确定,如果我得到错误说,字体没有加载,但他们显示在网页上? [英] Is it ok if I get error saying that fonts aren't loaded but they are shown on the webpage?

查看:115
本文介绍了是否确定,如果我得到错误说,字体没有加载,但他们显示在网页上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 @ font-face

@font-face { // body font
    font-family: 'Sofia Pro Light';
    src: url('../library/fonts/Sofia Pro Light/SofiaProLight.eot');
    src: url('../library/fonts/Sofia Pro Light/SofiaProLight.eot?#iefix') format('embedded-opentype'),
         url('../library/fonts/Sofia Pro Light/SofiaProLight.woff') format('woff'),
         url('../library/fonts/Sofia Pro Light/SofiaProLight.ttf') format('truetype'),
         url('../library/fonts/Sofia Pro Light/SofiaProLight.otf') format('opentype'),
         url('../library/fonts/Sofia Pro Light/SofiaProLight.svg#font-name') format('svg');
    font-weight: normal;
    font-style: normal;
}

这里是Chrome开发工具给我的

我应该忽略它吗?

and here's what Chrome Dev tool gives me Should I ignore it? cuz everything seems to work fine.

推荐答案

我会打开 Fiddler ,看看一切是否真的很好。

I'd open up Fiddler and see if everything really is fine or not.

我假设文件真的是你说的。所以我怀疑你碰到了我做的同样的事情。 Chrome是挑剔的mime类型。但错误消息是误导。基本上,当你没有正确的MIME类型来自服务器的WOFF文件,那么Chrome会故障转移到另一种字体格式。在这种情况下,它将首先故障转移到TTF字体。这意味着Chrome中会下载两种不同的字体格式。只有,您似乎在使用TTF字体时出现错误,因此Chrome可能会在您的情况下下载3种不同的格式。

I'm assuming the files really are where you say they are. And so I suspect you've run into the same thing I did. Chrome is picky about the mime type. But the error message is misleading. Basically, when you don't have the proper mime type coming from the server for WOFF files, then Chrome will failover to another font format. In this case it's going to first failover to TTF fonts. This means that two different font formats will be downloaded in Chrome. Only, it looks like you're getting an error with TTF fonts as well so Chrome is probably downloading 3 different formats in your case.

这是值得修复的。所有你需要做的是配置你的服务器发送 application / x-font-woff 作为WOFF文件的MIME类型。

So this is worth fixing. All you need to do is configure your server to send application/x-font-woff as the MIME Type for WOFF files.

例如,在ASP.NET中,您可以将其添加到web.config ...

For example, in ASP.NET you'd add this to the web.config...

<system.webServer>
        <staticContent>
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
        </staticContent>
</system.webServer>

这篇关于是否确定,如果我得到错误说,字体没有加载,但他们显示在网页上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆