将@ font-face文件集成到rails asset pipeline中 [英] Integrating @font-face files into rails asset pipeline

查看:137
本文介绍了将@ font-face文件集成到rails asset pipeline中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将设计师的html和css文件集成到rails应用程序中。他有大约4个@ font-face文件,这些文件当前链接到application.css文件中。我已将字体存储在assets / fonts文件夹中,并将该文件夹添加到资产管道(在config / application.rb中)

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)

我只使用过Google字体,其中我在application.html.erb文件中包含一个指向google的链接。

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

如何包含这些字体文件?应该他们(1)留在application.css文件或(2)链接到application.html.erb文件,就像javascript和styesheets?例如,像这样:

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


推荐答案

首先将字体放入 app / assets / fonts 。之后,您可以通过 font-url('font.eot')帮助程序将您的字体包含在sass / scss文件中。

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.

否则, asset_path 如果你决定使用它,仍然会在那里找到字体。

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

这篇关于将@ font-face文件集成到rails asset pipeline中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆