使用@ font-face与Rails 3.1应用程序? [英] Using @font-face with Rails 3.1 app?

查看:150
本文介绍了使用@ font-face与Rails 3.1应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用下面的 @ font-face 声明来处理我的Rails 3.1应用程序。我把Asset Pipeline中的字体放在自己的文件夹中,名为Fonts的图像样式表 javascripts



这是我使用的声明(由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;任何人都可以在他们的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 ),请参阅 Rails指南

  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" alongside images and stylesheets and javascripts

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 to font-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 Guides

config.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆