Renegade
Renegade

Reputation: 233

Add Fonts to Rails 3.2 app

Added a font to my rails 3.2 Ruby 1.9 App that works on my local but not after i push it to heroku.

1- I made sure the font is not installed on my local machine. 2- added my font file to a fonts directory i created in the /app/assets directory 3- added the following code to my application.rb file

#precompile fonts
config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

#add fonts directory to assets pipeline
config.assets.paths << "#{Rails.root}/app/assets/fonts"

4- added the following to my application.css.scss file

 @font-face {
   font-family: Steinerlight;
   src: url('Steinerlight.ttf')format('truetype');
 }

5- called the font in my css file like so:

 font-family: "Steinerlight", sans-serif;

5- i made sure the font name in the css file is exactly the same as the file name in the app/assets/fonts directory

When i precompile restart server on my local the page shows up with the font style i added. (again the font is not installed on my computer).

Problem is when I precompile and push the app to heroku the page is styled with the secondary font (sans-serif) not the one i added. any suggestions on what may be the problem?

Upvotes: 0

Views: 89

Answers (1)

Renegade
Renegade

Reputation: 233

Solved it. It was a browser issue with IE the fonts load fine in firefox and chrome

added ie specific syntax and it works fine

  src: url('Steinerlight.eot'); /* IE9 Compat Modes */
  src: url('Steinerlight.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */

Upvotes: 1

Related Questions