Integrating @font-face files into rails asset pipe

2019-01-24 18:14发布

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

1条回答
神经病院院长
2楼-- · 2019-01-24 18:37

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.

查看更多
登录 后发表回答