【发布时间】:2017-11-17 03:46:00
【问题描述】:
我正在使用 Rails 3.2.22 并使用 .woff 和 .woff2 文件安装了新字体。但字体似乎无法仅在本地显示。在资产被预编译和捆绑后,当我部署到我们的暂存环境时,字体显示良好。我还可以按照我本地编译的 CSS 用来尝试显示字体的 url,该链接下载正确的文件。
字体文件包含在“app/assets/fonts”文件夹中,我的application.rb中有这个
config.assets.paths << Rails.root.join("app", "assets", "fonts")
我将字体拉入 Sass,如下所示:
// Custom Font Faces
@font-face {
font-family: 'Museo Sans Rounded';
src: font-url('MuseoSansRounded-500-webfont.woff2') format('woff2'),
font-url('MuseoSansRounded-500-webfont.woff') format('woff');
font-weight: 500;
font-style: normal;
}
@font-face {
font-family: 'Museo Sans Rounded';
src: font-url('MuseoSansRounded-700-webfont.woff2') format('woff2'),
font-url('MuseoSansRounded-700-webfont.woff') format('woff');
font-weight: 700;
font-style: normal;
}
任何线索为什么这不显示在本地?
【问题讨论】:
-
@font-face 在 Rails 中很棘手。根据我的经验,这很有效:stackoverflow.com/questions/20926234/…
标签: css ruby-on-rails ruby fonts