Rails 3.2.18, Unable to get font-family

46 Views Asked by At

I created a fonts.css.scss file in fonts folder and given below format

@font-face {
  font-family: 'amandaregular';
  src: url(font-path('amanda-webfont.eot'));
}

it's generating with compiled fonts, but unable to load font-family

@font-face {
  font-family: 'amandaregular';
  src: url("http://localhost:3000/assets/amanda-webfont.eot");
}
1

There are 1 best solutions below

2
rlarcombe On

First make sure you add the fonts folder to the Asset pipeline load path in config/application.rb, and then restart your server:

config.assets.paths << Rails.root.join("app", "assets", "fonts")

Then place fonts.css.scss in app/assets/stylesheets and make sure it is included in your application.scss manifest. It should look like:

@font-face {
  font-family: 'amandaregular';
  src: url(font-path('amanda-webfont.eot?#iefix')) format('embedded-opentype');
}

Notice the above uses the Fontspring @font-face syntax.

Finally, make sure that the file amanda-webfont.eot is saved in app/assets/fonts