我正在考虑尝试使用@font-face 在我的rails 应用程序中使用font-squirrels 字体。希望这是解释它的正确方法。我对此比较陌生,所以希望有人可以建议我如何让它在 rails 应用程序中工作
谢谢
我正在考虑尝试使用@font-face 在我的rails 应用程序中使用font-squirrels 字体。希望这是解释它的正确方法。我对此比较陌生,所以希望有人可以建议我如何让它在 rails 应用程序中工作
谢谢
好的,所以我想我会给出答案,这样它可以帮助其他人解决我的情况。我只是在谷歌上搜索并将所有部分放在一起,我很懒/害怕这个未知,所以为此道歉。尝试它真的有助于理解
反正
1)在 app/assets 中创建一个名为 fonts 的文件夹
2)将所有 svg .eot .woff .ttf 放入此文件夹中
3)在 config/application.rb 中放入以下内容
# Add the fonts path
config.assets.paths << "#{Rails.root}/app/assets/fonts"
# Precompile additional assets
config.assets.precompile += %w( .svg .eot .woff .ttf )
4)在您的应用程序样式表中,您可以放置 @font-face 样式,例如
@font-face {
font-family: 'DearestRegular';
src: url('Dearest-webfont.eot');
src: url('Dearest-webfont.eot?#iefix') format('embedded-opentype'),
url('Dearest-webfont.woff') format('woff'),
url('Dearest-webfont.ttf') format('truetype'),
url('Dearest-webfont.svg#DearestRegular') format('svg');
font-weight: normal;
font-style: normal;
}
5)然后无论你想在哪里使用字体,只需正常使用 font-family 6)哦,然后重新启动服务器以将它们组合在一起 :)