更正字体 MIME 类型的 Apache AddType 指令 [英] Correct Apache AddType directives for font MIME types

查看:22
本文介绍了更正字体 MIME 类型的 Apache AddType 指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 @font-face 用于嵌入字体(感谢 Paul Irish).在尝试修复 Chrome 关于 woff 字体 MIME 类型错误的警告时,我发现了大量相互矛盾的建议.

I’m using @font-face for embedded fonts (thanks Paul Irish). In trying to fix Chrome’s warning about wrong MIME type for woff fonts, I’ve discovered a mass of conflicting suggestions.

似乎每个人都同意 .eot 字体(对于 IE 6-8?)应该使用

Everyone seems to agree that .eot fonts (for IE 6-8?) should be served using

AddType application/vnd.ms-fontobject .eot

对于 .ttf 字体(旧的非 IE 浏览器?)我见过

For .ttf fonts (older non-IE browsers?) I’ve seen

AddType application/x-font-ttf        .ttf
AddType application/octet-stream      .ttf
AddType font/truetype                 .ttf
AddType font/ttf                      .ttf

对于 .woff 字体(新标准?)我见过

And for .woff fonts (the new standard?) I’ve seen

AddType application/font-wof          .woff
AddType application/x-font-woff       .woff
AddType application/x-woff            .woff

我了解 woff 的正确的 MIME 类型将是 application/font-woff,但在标准正式发布之前, Chrome 可以识别 application/x-font-woff.

I understand the correct MIME type for woff will be application/font-woff, but until the standard is official, application/x-font-woff is understood by Chrome.

我意识到我在提问时已经回答了一半,但问题是:是否有任何权威指南或进一步的建议来说明应将哪些 MIME 类型用于字体?

I realise I’ve half answered my question in asking it, but the question is really: is there any authoritative guidance or further advice about what MIME types should be used for fonts?

更新(以防对其他人有任何帮助):由于似乎没有任何权威性,我决定在我的 .htaccess 中使用以下字体 MIME 类型(这至少让 Chrome 感到高兴):

Update (in case it’s of any help to anyone else): since there seems to be nothing authoritative, I’ve settled on using the following font MIME types in my .htaccess (which at least keeps Chrome happy):

AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf        .ttf
AddType application/x-font-woff       .woff

推荐答案

通常,MIME 类型来自 RFC.您在 IANA 网站 上有一份详尽的清单,但没有提到字体扩展名.此外,描述 WOFF 格式的文档 是草稿,并且不是指要使用的 MIME 类型.目前似乎没有关于该主题的可靠参考.

Usually, MIME types come from RFC. You have a exhaustive list on the IANA site but none refers to the font extensions. Moreover, document describing WOFF format is draft and does not refer to the mime type to use. No reliable reference on the subject seems to exist for now.

W3C 现已发布 WOFF 作为推荐,并在附录 B 将 MIME 类型定义为 application/font-woff.它也已添加到您现在提到的 IANA 站点.-GKFX

The W3C has now released WOFF as a recommendation, and in Appendix B defined the MIME type as application/font-woff. It's also been added to the IANA site that you mentioned now. -GKFX

这篇关于更正字体 MIME 类型的 Apache AddType 指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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