Rails 3 web font (woff) mime type

ε祈祈猫儿з 提交于 2019-12-04 05:45:27

Until Rack fixes its MIME-type list to a correct woff, the interim hack is indeed your config/initializers/mime_types.rb line:

# tell Rack (and Sprockets) about modern font MIME types:
Rack::Mime::MIME_TYPES['.woff'] = 'application/x-font-woff'

To have it actually take effect, though, you have to wipe tmp/cache and restart your server.

While I also didn't figure out some hack solution to it, I researched this a few days ago (on my rails 3.2 dev server running WEBRick, for reference), and it's Sprockets that sets the bad MIME type on the response, maybe by delegating the choice to Rack, which has a dumb notion of what MIME type to pass for fonts (as of this ravinggenious commit).

I filed a (detailed) ticket on Sprockets and a pull request on Rack, hoping it'd get fixed upstream where it makes the most sense instead, but neither has seen much action yet. I probably should have paid more attention to ttf and eof too, but it was late and I didn't think of it at the time.

(Commenting on either might raise awareness of the problem – one issue is no issue, a people pile is a problem worth fixing? :-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!