Typicons字体不显示在heroku中 [英] Typicons font not showing in heroku
问题描述
我在我的Rails应用程序中使用了typicons和heroku,并且在本地工作但未在生产中,我没有在heroku中发现任何路由错误,我不确定我错过了什么。我在assets文件夹中有一个字体文件夹,我正在使用
config.assets.paths<< Rails.root.join(app,assets,fonts)
.application.rb文件在应用程序类下。
在typicons.css.scss(它位于stylesheets文件夹中)中,我有
@ font-face {
font-family:'typicons';
src:font-url('typicons.eot');
src:font-url('typicons.eot?#iefix')格式('embedded-opentype'),
font-url('typicons.woff')格式('woff'),
font-url('typicons.ttf')格式('truetype'),
font-url('typicons.svg#typicons')格式('svg');
font-weight:normal;
font-style:normal;
}
同样的问题。以下是我的工作:
$ b
在 assets / fonts中放置字体文件
在typicons.css.scss(它位于stylesheets文件夹中)内部:
/ * @ FONT-FACE将字体加载到浏览器中* /
@ font-face {
font-family:'typicons';
font-weight:normal;
font-style:normal;
src:font-url(asset-path('typicons.eot'));
src:font-url(asset-path('typicons.eot?#iefix'))format('embedded-opentype'),
font-url(asset-path('typicons.woff' ))格式('woff'),
font-url(资产路径('typicons.ttf'))格式('truetype'),
font-url(资产路径('typicons。 svg#typicons'))format('svg');
}
在application.rb中,我添加了:
config.assets.precompile<< /\.(?:svg|eot|woff|ttf)$/
最后,我跑了在提交并推送到Heroku之前:
RAILS_ENV =生产捆绑包exec rake资产:预编译
I 没有将以下行添加到application.rb:
config.assets.paths<< Rails.root.join(app,assets,fonts)
如果您运行Rails控制台中的 Rails.application.class.config.assets.paths
,您应该能够看到Rails是否正在拾取assets / fonts目录。在Rails 4.2.5中,字体目录被自动添加到资产路径。
希望这可以节省一些时间。
I'm using typicons and heroku in my rails app and its working locally but not in production, I'm not getting any routing error in heroku and I'm not sure what I'm missing. I have a fonts folder in the assets folder and I'm using
config.assets.paths << Rails.root.join("app", "assets", "fonts")
inside my config.application.rb file under the application class.
Inside the typicons.css.scss (which is in the stylesheets folder) I have
@font-face {
font-family: 'typicons';
src: font-url('typicons.eot');
src: font-url('typicons.eot?#iefix') format('embedded-opentype'),
font-url('typicons.woff') format('woff'),
font-url('typicons.ttf') format('truetype'),
font-url('typicons.svg#typicons') format('svg');
font-weight: normal;
font-style: normal;
}
I spent a few hours on the same issue. The following is what worked for me:
Placed font files in assets/fonts
Inside the typicons.css.scss (which is in the stylesheets folder) I have:
/* @FONT-FACE loads font into browser */
@font-face {
font-family: 'typicons';
font-weight: normal;
font-style: normal;
src: font-url(asset-path('typicons.eot'));
src: font-url(asset-path('typicons.eot?#iefix')) format('embedded-opentype'),
font-url(asset-path('typicons.woff')) format('woff'),
font-url(asset-path('typicons.ttf')) format('truetype'),
font-url(asset-path('typicons.svg#typicons')) format('svg');
}
In application.rb, I added:
config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
Finally, I ran the following before committing and pushing to Heroku:
RAILS_ENV=production bundle exec rake assets:precompile
I did not add the following line to application.rb:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
If you run Rails.application.class.config.assets.paths
in the Rails console, you should be able to see whether Rails is picking up the assets/fonts directory. In Rails 4.2.5, the fonts directory was added automatically to assets paths.
Hope this saves someone some time.
这篇关于Typicons字体不显示在heroku中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!