Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating @font-face files into rails asset pipeline

I'm trying to integrate a designer's html and css files into a rails app. He's got about four @font-face files that are currently linked to in the application.css file. I've stored the fonts in an assets/fonts folder and added that folder to the asset pipeline (in config/application.rb)

I've only ever used Google fonts, where I included the a link to google in the application.html.erb file.

How should I include these font files? Should they (1) stay in the application.css file or (2) be linked to in the application.html.erb file just like javascript and styesheets? For example, something like this:

<%= asset_path('my_webfont.eot') %>
like image 815
Ben Downey Avatar asked Oct 11 '12 22:10

Ben Downey


1 Answers

Start by putting your fonts into app/assets/fonts. After that, you can include your fonts in a sass / scss file via the font_url('font.eot') helper.

Otherwise, asset_path should still find the fonts there if you're determined to use it.

like image 122
John Avatar answered Sep 21 '22 23:09

John