使用@ font-face与Rails 3.1应用程序? [英] Using @font-face with Rails 3.1 app?
问题描述
我无法使用下面的 @ font-face
声明来处理我的Rails 3.1应用程序。我把Asset Pipeline中的字体放在自己的文件夹中,名为Fonts的图像
和样式表
和 javascripts
这是我使用的声明(由Font Squirrel生成)
@ font-face {
),请参阅 Rails指南
font-family:'ChunkFiveRegular';
src:url('Chunkfive-webfont.eot');
src:url('Chunkfive-webfont.eot?#iefix')format('embedded-opentype'),
url('Chunkfive-webfont.woff')format('woff'),
url('Chunkfive-webfont.ttf')format('truetype'),
url('Chunkfive-webfont.svg#ChunkFiveRegular')format('svg');
font-weight:normal;
font-style:normal;任何人都可以在他们的Rails 3.1应用程序上成功地使用@ font-face? >
更新
我只是读取此主题 http://spin.atomicobject.com/2011/09/26/serving-fonts-in-rails-3 -1 / 表示在声明中将
url
更改为font-url
。解决方案您必须将文件夹添加到资产路径c $ c> config / application.rb
config.assets.paths< #{Rails.root} / app / assets / fonts
c $ c> asset_path 帮助:
src:url('<%= asset_path Chunkfive-webfont.eot')%>');
I'm having trouble using the following
@font-face
declaration to work with my Rails 3.1 app. I put the fonts in the Asset Pipeline in its own folder called "Fonts" alongsideimages
andstylesheets
andjavascripts
Here is the declaration I used (generated by Font Squirrel.)
@font-face { font-family: 'ChunkFiveRegular'; src: url('Chunkfive-webfont.eot'); src: url('Chunkfive-webfont.eot?#iefix') format('embedded-opentype'), url('Chunkfive-webfont.woff') format('woff'), url('Chunkfive-webfont.ttf') format('truetype'), url('Chunkfive-webfont.svg#ChunkFiveRegular') format('svg'); font-weight: normal; font-style: normal; }
Anyone successfully utilize @font-face on their Rails 3.1 app?
Update
I just read this thread http://spin.atomicobject.com/2011/09/26/serving-fonts-in-rails-3-1/ that said to change
url
tofont-url
in the declarations. That didn't seem to work either unfortunately.解决方案You have to add the folder to the assets path (to file
config/application.rb
), see Rails Guidesconfig.assets.paths << "#{Rails.root}/app/assets/fonts"
And you should use the
asset_path
helper:src: url('<%= asset_path('Chunkfive-webfont.eot') %>');
这篇关于使用@ font-face与Rails 3.1应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!