我使用 @font-face 来嵌入字体(感谢 Paul Irish )。在尝试修复 Chrome 关于 woff 字体 MIME 类型错误的警告时,我发现了大量相互矛盾的建议。
每个人似乎都同意 .eot 字体(适用于 IE 6-8?)应该使用
AddType application/vnd.ms-fontobject .eot
对于 .ttf 字体(较旧的非 IE 浏览器?)我见过
AddType application/x-font-ttf .ttf
AddType application/octet-stream .ttf
AddType font/truetype .ttf
AddType font/ttf .ttf
对于 .woff 字体(新标准?)我见过
AddType application/font-wof .woff
AddType application/x-font-woff .woff
AddType application/x-woff .woff
我了解 correct MIME type对于 woff 将是 application/font-woff,但在标准正式发布之前,application/x-font-woff is understood by Chrome .
我意识到我在问这个问题时已经回答了一半,但问题确实是:关于字体应该使用哪些 MIME 类型,有没有权威的指导或进一步的建议?
更新(如果对其他人有任何帮助):由于似乎没有什么权威性,我决定在我的 .htaccess 中使用以下字体 MIME 类型(这至少让 Chrome 满意):
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-woff .woff
最佳答案
我意识到这个问题已经很老了,但是对于任何寻求快速复制/粘贴以将字体 MIME 类型添加到其 .htaccess 的人来说:
<IfModule mod_mime.c>
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-opentype .otf
AddType image/svg+xml .svg
AddType application/x-font-ttf .ttf
AddType application/font-woff .woff
AddType application/font-woff2 .woff2
</IfModule>
关于apache - 字体 MIME 类型的正确 Apache AddType 指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7415640/