Nic*_*rns 548 embedded-fonts woff
什么mime类型应该作为WOFF字体?
我服务truetype(ttf)字体as font/truetype和opentype(otf)as font/opentype,但我找不到WOFF字体的正确格式.
我曾尝试font/woff,font/webopen和font/webopentype,但Chrome仍然会抱怨:
"资源被解释为字体,但使用MIME类型application/octet-stream进行传输."
有人知道吗?
Mar*_*cel 729
2017年6月22日Keith Shaw的评论更新:
截至2017年2月,RFC8081是建议的标准.它定义了字体的顶级媒体类型,因此WOFF和WOFF2的标准媒体类型如下:
font/woff
font/woff2
2011年1月,宣布 Chromium将承认
application/x-font-woff
作为WOFF的哑剧型.我知道这个变化现在已经在Chrome测试版中,如果还没有稳定,那么它应该不会太远.
小智 135
对我来说,下一个是在.htaccess文件中工作.
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
AddType font/woff2 .woff2
Run Code Online (Sandbox Code Playgroud)
jfl*_*mme 55
它会application/font-woff.
见http://www.w3.org/TR/WOFF/#appendix-b(W3C候选人推荐2011年8月4日)
和http://www.w3.org/2002/06/registering-mediatype.html
来自Mozilla css字体笔记
在Gecko中,Web字体受到相同的域限制(字体文件必须与使用它们的页面位于同一域中),除非使用HTTP访问控制来放宽此限制.注意:由于TrueType,OpenType和WOFF字体没有定义的MIME类型,因此不考虑指定文件的MIME类型.
来源:https://developer.mozilla.org/en/CSS/@font-face#Notes
Jer*_*eir 25
将字体mime类型添加到.NET/IIS的参考
通过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>
Run Code Online (Sandbox Code Playgroud)
通过IIS管理器

BG *_*uno 22
NGINX解决方案
文件
/etc/nginx/mime.types
Run Code Online (Sandbox Code Playgroud)
要么
/usr/local/nginx/conf/mime.types
Run Code Online (Sandbox Code Playgroud)
加
font/ttf ttf;
font/opentype otf;
font/woff woff;
font/woff2 woff2;
application/vnd.ms-fontobject eot;
Run Code Online (Sandbox Code Playgroud)
去掉
application/octet-stream eot;
Run Code Online (Sandbox Code Playgroud)
参考
RFC @ 02.2017
https://tools.ietf.org/html/rfc8081#page-15
https://www.iana.org/assignments/media-types/media-types.xhtml
感谢Mike Fulcher
http://drawingablank.me/blog/font-mime-types-in-nginx.html
Kei*_*haw 18
截至2017年2月,RFC8081是建议的标准.它定义了字体的顶级媒体类型,因此WOFF和WOFF2的标准媒体类型如下:
font/woff
font/woff2
Run Code Online (Sandbox Code Playgroud)
对我这样做的事情是将它添加到我的mime_types.rb初始化器:
Rack::Mime::MIME_TYPES['.woff'] = 'font/woff'
Run Code Online (Sandbox Code Playgroud)
并清除缓存
rake tmp:cache:clear
Run Code Online (Sandbox Code Playgroud)
在重新启动服务器之前.
资料来源:https://github.com/sstephenson/sprockets/issues/366#issuecomment-9085509
| 归档时间: |
|
| 查看次数: |
322236 次 |
| 最近记录: |