Rails 3, @font-face failing in production with fir

2019-01-31 08:29发布

I'm using font-awesome in a rails 3 app, and everything is ok in development mode, but when I push to Heroku, Firefox fails to render the icons, and instead, I see this:

enter image description here

  • Chrome renders the icons fine in development and production
  • This just affects FireFox (although I've not tried IE)
  • The app is here, I'd appreciate if someone could confirm that this is not just happening on my machine (to help me rule out a localhost caching issue).
  • All assets, including fonts and stylesheets, are hosted on S3, using the asset_sync gem.

Here's what I've done:

Added the following to the top of font-awesome.css.scss:**

// font-awesome.css.scss
@font-face {
  font-family: 'FontAwesome';
  src: font-url("fontawesome-webfont.eot");
  src: font-url("fontawesome-webfont.eot?#iefix") format("eot"),
       font-url("fontawesome-webfont.woff") format("woff"),
       font-url("fontawesome-webfont.ttf") format("truetype"),
       font-url("fontawesome-webfont.svg#FontAwesome") format("svg");
  font-weight: normal;
  font-style: normal;
}

Then I put this in application.rb:

# application.rb
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.precompile += %w( .svg .eot .woff .ttf )

Finaly I placed all 4 font files in app/assets/fonts.

I would really like to know what I'm doing wrong here.

7条回答
趁早两清
2楼-- · 2019-01-31 09:10

You can use the following site to Base64 Encode a font. Tried using FontSquirel but it does not let you encrypt copyright / bought fonts.

http://base64fonts.com/convert.php

查看更多
登录 后发表回答