部署完成后,Font awesome Rails将无法工作。它看起来像坏Unicode字符。为什么? [英] Font awesome Rails won't work after deploying. It looks like bad Unicode characters. Why?

查看:105
本文介绍了部署完成后,Font awesome Rails将无法工作。它看起来像坏Unicode字符。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的本地机器中,fontawesome完美运行(使用4.1 gem)。但是当上传到Heroku时,它停止工作。我看起来像不好的Unicode字符。我在配置和预编译资产中包含了以下行,但它不起作用:

  config.assets.paths<<<< ; Rails.root.join('app','assets','fonts')
config.assets.precompile + =%w(.svg .eot .woff .ttf)


i.stack.imgur.com/ARRk9.jpgalt =在这里输入图片描述>



左边是问题所在。在右边是正确的版本。可能是什么问题?以下是Heroku应用程序的链接: http://fast-garden-6871.herokuapp.com/



更新它看起来像 /assets/fontawesome-webfont.eot 在生产机器中丢失!

解决方案

最后修正了它!在custom.css中,我添加了以下几行:

pre $ font-family:'FontAwesome' ;
src:asset-url('fontawesome-webfont.eot');
src:asset-url('fontawesome-webfont.eot?#iefix')格式('embedded-opentype'),asset-url('fontawesome-webfont.woff')格式('woff'),资产-url('fontawesome-webfont.ttf')格式('truetype'),asset-url('fontawesome-webfont.svg#fontawesomeregular')格式('svg');
font-weight:normal;
font-style:normal;





$ b

问题是,rails会用生成的哈希字体生成字体文件css文件。但是,这个新生成的文件没有更新CSS。所以系统找不到字体。使用上面的代码,系统将分配正确的URL!


In my local machine fontawesome is working perfectly (Im using 4.1 gem). But when uploaded to Heroku it stops working. I looks like bad unicode characters. I have included the following line in config and precompiled assets but it didn't work :

config.assets.paths << Rails.root.join(‘app’, ‘assets’, ‘fonts’)
config.assets.precompile += %w( .svg .eot .woff .ttf )

Please look at this image :

On the left is the problem. On the right is the correct version. What might be the problem? Here's the link to the Heroku app : http://fast-garden-6871.herokuapp.com/

Update It looks like /assets/fontawesome-webfont.eot is missing in the production machine!

解决方案

Finally fixed it! In custom.css I added the following lines:

@font-face {
  font-family: 'FontAwesome';
  src: asset-url('fontawesome-webfont.eot');
  src: asset-url('fontawesome-webfont.eot?#iefix') format('embedded-opentype'), asset-url('fontawesome-webfont.woff') format('woff'), asset-url('fontawesome-webfont.ttf') format('truetype'), asset-url('fontawesome-webfont.svg#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

The problem was, rails will generate the font file with a hash like it generate css files. But the css is not updated with this new generated file. So the system can't find the font. With the above code, the system will assign the right url!

这篇关于部署完成后,Font awesome Rails将无法工作。它看起来像坏Unicode字符。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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