WOFF字体应该作为什么mime类型?

我正在服务truetype (ttf)字体作为字体/truetype和opentype (otf)作为字体/opentype,但我找不到WOFF字体的正确格式。

我已经尝试了字体/woff,字体/webopen,和字体/webopentype,但Chrome仍然抱怨:

资源解释为字体,但使用MIME类型应用程序/字节流传输。

有人知道吗?


当前回答

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

这是一个有用的mime类型列表

其他回答

@Nico,

目前还没有woff字体mime类型的定义标准。我使用字体交付cdn服务,它使用字体/woff,我在chrome中得到相同的警告。

参考:互联网号码分配机构

WOFF:

网页开放字体格式 它可以用TrueType或PostScript (CFF)概要进行编译 目前FireFox 3.6+支持它

试着补充一下:

AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf

对我来说,接下来就是在.htaccess文件中工作。

AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
AddType font/woff2 .woff2   

向.NET/IIS添加字体mime类型的参考

通过web . config

<system.webServer>
  <staticContent>
     <!-- remove first in case they are defined in IIS already, which would cause a runtime error -->
     <remove fileExtension=".woff" />
     <remove fileExtension=".woff2" />
     <mimeMap fileExtension=".woff" mimeType="font/woff" />
     <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
  </staticContent>
</system.webServer>

通过IIS管理器

NGINX溶液

file

/etc/nginx/mime.types

or

/usr/local/nginx/conf/mime.types

add

font/ttf                      ttf;
font/opentype                 otf;
font/woff                     woff;
font/woff2                    woff2;
application/vnd.ms-fontobject eot;

删除

application/octet-stream        eot;

参考文献

RFC @02.2017

https://www.rfc-editor.org/rfc/rfc8081#page-15

https://www.iana.org/assignments/media-types/media-types.xhtml

感谢迈克·富尔彻

http://drawingablank.me/blog/font-mime-types-in-nginx.html