@ font-face导轨3.2 [英] @font-face rails 3.2
问题描述
我当时正在考虑尝试使用@ font-face在我的Rails应用程序中使用字体松鼠字体.希望这是正确的解释方式.我对此还比较陌生,所以希望有人可以建议我如何使它在Rails应用程序中工作
I was thinking of trying to use font-squirrels fonts in my rails app using @font-face. Hope this is the correct way of explaining it. I'm relatively new to this so was hoping someone could advise on how I would get this to work within the rails app
谢谢
推荐答案
好的,以为我会给出答案,这样可以帮助其他人解决我的情况.我只是用谷歌搜索并把所有的部分放在一起,我对此感到很懒惰/害怕未知,为此深表歉意.只是尝试一下真的有助于理解
OK so thought I would give the answer so it may help other people out in my situation. I just googled it and put all the pieces together, I was being lazy/afraid of the unknown on this one so apologies for that.Just trying it really helps understanding
反正
1)在应用程序/资产中创建一个名为fonts的文件夹
2)将所有svg .eot .woff .ttf放入此文件夹中
3)在config/application.rb文件中输入以下内容
1) Create a folder called fonts in app/assets
2)Put all svg .eot .woff .ttf within this folder
3)In config/application.rb put the following
# 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样式
4)In your application stylesheets you place your @font-face styles, for example
@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)哦,然后重新启动服务器以将它们组合在一起:)
5) Then wherever you want to use the font just use font-family as normal 6) Oh and restart the server to bring it all together :)
这篇关于@ font-face导轨3.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!