【发布时间】:2016-05-30 16:58:10
【问题描述】:
我在我的 ruby on rails 应用程序中使用 Montserrat 字体。在我的桌面上出现了字体,但我在其他电脑上检查过,它是新罗马时代的。
我在 application.rb 中添加了这个:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
我的字体在 assets/fonts/montserrat:
这是我的 font.scss
@font-face {
font-family: 'Montserrat';
font-weight: normal;
font-style: normal;
src: font-url('montserrat/montserrat-regular-webfont.eot');
src: font-url('montserrat/montserrat-regular-webfont.eot?#iefix') format('embedded-opentype'),
font-url('montserrat/montserrat-regular-webfont.woff') format('woff'),
font-url('montserrat/montserrat-regular-webfont.ttf') format('truetype'),
font-url('montserrat/montserrat-regular-webfont.svg') format('svg');
}
我这样称呼字体:
.welcome{
font-family: 'Montserrat';
color: #333;
text-align: center;
}
我做错了什么?
【问题讨论】:
-
旁注:如果您使用的是 WOFF,则不需要 ttf/otf; SVG 字体已被废弃,因为它们很糟糕,
eot已被 WOFF 弃用,因此您不需要所有这些不同的格式(幸好不再是 2012 年),只需使用 WOFF 并降低复杂性。有关详细信息,请参阅stackoverflow.com/a/37091681/740553 -
我只需要 woff url 吗?
-
至少在支持当前的web方面,你只需要WOFF资源,其他的不需要。然后在你的
scss中你只需要 woff 的 url。 -
我已删除,但无法正常工作
-
我知道,我并不是要解决你的问题,只是解释一下,今天你不需要所有这些字体格式,只需要一种格式。
标签: css ruby-on-rails fonts