简体   繁体   中英

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') %>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM