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

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

问题描述

我正在尝试将设计师的 html 和 css 文件集成到 rails 应用程序中.他有大约四个 @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)

我只使用过谷歌字体,我在 application.html.erb 文件中包含了一个指向谷歌的链接.

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) 像 javascript 和 styesheets 一样链接到 application.html.erb 文件中?例如,像这样:

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 资产管道中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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