简体   繁体   English

rails / Heroku:自定义字体在本地运行,但不适用于Heroku

[英]rails/Heroku: custom fonts working in local but not on Heroku

I have a problem with my custom fonts on Rails 4. 我在Rails 4上的自定义字体有问题。

I put the fonts in /vendor/assets/fonts/ directory, and in my application.rb, I added: 我将字体放在/ vendor / assets / fonts /目录中,并在我的application.rb中添加:

config.assets.paths << "#{Rails}/vendor/assets/fonts"
config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

In addition, in my production.rb config file, I have: 另外,在我的production.rb配置文件中,我有:

config.serve_static_assets = true

I'm using sass so in my css, I added: 我正在使用sass,所以在我的CSS中,我添加了:

@font-face
  font-family: 'Raleway-Thin'
  src: url('Raleway-Thin.ttf')

....
font-family: "Raleway-Thin", sans-serif

In my application.css, I also added because i'm using font-awesome: 在我的application.css中,我还添加了因为我使用的是超棒的字体:

 *= require font-awesome.min

I'm pushing on Heroku, and my fonts are ot loaded, it's not working... 我正在推动Heroku,并且我的字体无法加载,因此无法正常工作...

Do you have any ideas what's the problem please, (or if there is any command to type before/after pushing)? 请问您有什么问题吗(或者在推送之前/之后是否有任何键入命令)?

Thanks by advance 预先感谢

Have you tried using the helper function and utilize the Rails asset pipeline? 您是否尝试过使用辅助功能并利用Rails资产管道?

@font-face
  font-family: 'Raleway-Thin'
  src: font-url('Raleway-Thin.ttf')

You can import font into folder assest/stylesheet/font and run bundle exec rake assets:precompile before deploy to heroku. 您可以将字体导入文件夹assest / stylesheet / font中,然后在将其部署到heroku之前运行bundle exec rake assets:precompile I has tried and it's work. 我已经尝试过了,而且行得通。 In addition, I have search font name that you have used, so I recommended you can using Google Web Font for this font: http://www.google.com/fonts#UsePlace:use/Collection:Raleway 此外,我还有您使用过的搜索字体名称,因此建议您使用Google Web字体作为该字体: http : //www.google.com/fonts#UsePlace : use/ Collection: Raleway

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM