Mime type for WOFF fonts?

2019-01-01 16:20发布

What mime type should WOFF fonts be served as?

I am serving truetype (ttf) fonts as font/truetype and opentype (otf) as font/opentype, but I cannot find the correct format for WOFF fonts.

I have tried font/woff, font/webopen, and font/webopentype, but Chrome still complains:

"Resource interpreted as font but transferred with MIME type application/octet-stream."

Anybody know?

17条回答
听够珍惜
2楼-- · 2019-01-01 17:21

I have had the same problem, font/opentype worked for me

查看更多
梦该遗忘
3楼-- · 2019-01-01 17:23

It will be application/font-woff.

see http://www.w3.org/TR/WOFF/#appendix-b (W3C Candidate Recommendation 04 August 2011)

and http://www.w3.org/2002/06/registering-mediatype.html

From Mozilla css font-face notes

In Gecko, web fonts are subject to the same domain restriction (font files must be on the same domain as the page using them), unless HTTP access controls are used to relax this restriction. Note: Because there are no defined MIME types for TrueType, OpenType, and WOFF fonts, the MIME type of the file specified is not considered.

source: https://developer.mozilla.org/en/CSS/@font-face#Notes

查看更多
回忆,回不去的记忆
4楼-- · 2019-01-01 17:25

Update from Keith Shaw's comment on Jun 22, 2017:

As of February 2017, RFC8081 is the proposed standard. It defines a top-level media type for fonts, therefore the standard media type for WOFF and WOFF2 are as follows:

font/woff

font/woff2


In January 2011 it was announced that in the meantime Chromium will recognize

application/x-font-woff

as the mime-type for WOFF. I know this change is now in Chrome beta and if not in stable yet, it shouldn't be too far away.

查看更多
倾城一夜雪
5楼-- · 2019-01-01 17:25

Add the following to your .htaccess

AddType font/woff woff

good luck

查看更多
皆成旧梦
6楼-- · 2019-01-01 17:27

Maybe this will help someone. I saw that on IIS 7 .ttf is already a known mime-type. It's configured as:

application/octet-stream

So I just added that for all the CSS font types (.oet, .svg, .ttf, .woff) and IIS started serving them. Chrome dev tools also do not complain about re-interpreting the type.

Cheers, Michael

查看更多
登录 后发表回答