New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails 4 with font-face #239
Comments
I wasn't able to get this working on Rails 4 either. In the end I've used my own modified mixin that seems to work ok. Instead of this format:
I used this instead...
Which allowed me to use /assets/fonts directory. Might be a useful workaround for someone. This link was quite helpful, though I didn't need to add anything to my config/application.rb Would be great to use bourbon for this instead though. :) |
@chrism that seems strange... Anyone on the Bourbon core team have any thoughts? Has the font-url helper gone south in the latest Sprockets/asset pipeline gems? |
@nybblr exactly - it should be. My guess would be that maybe it is an issue with the asset helpers from the sass-rails gem, but didn't have chance to investigate further. |
@nybblr OK great - glad you got it working. |
hm, I did a fresh install of Rails 4.0.0 and I cannot reproduce the error. The current @font-face mixin is working fine for me.
// SCSS
@include font-face(entypo, 'entypo/entypo', $asset-pipeline: true);
// CSS Output
@font-face {
font-family: entypo;
font-weight: normal;
font-style: normal;
src: url(/assets/entypo/entypo.eot);
src: url(/assets/entypo/entypo.eot?#iefix) format("embedded-opentype"), url(/assets/entypo/entypo.woff) format("woff"), url(/assets/entypo/entypo.ttf) format("truetype"), url(/assets/entypo/entypo.svg#entypo) format("svg"); }
|
Make sure you run |
@plapier I was having some issues with some fonts with Rails 4 on Heroku and the changes in this PR https://github.com/thoughtbot/bourbon/pull/250/files helped me fix them - + 1 for me on that guy! |
Update: Although this works, you should follow the guide below.Just an update. I recently pushed a project to heroku where the fonts failed. I have the fonts in I was able to get the fonts to precompile by adding the following to
I was then able to see that they successfully precompiled when I pushed to heroku. Resource: https://coderwall.com/p/1uqvkq |
After some extensive testing, here's what I've concluded.
Rails 3.1 & 4 @font-face setup1. All font files should be placed in
|
Closing this issue for now. |
@plapier epic how-to, thanks! |
@plapier thank you for all of your hard work and excellent screen-shot-ing! 🍌 |
I strongly believe that putting vendor fonts into
I'm also using that config for my icon font gem: https://github.com/railslove/fontello_rails_converter |
@jhilden could you elaborate a little bit on why this makes more sense? |
@dnlmzw any vendored assets (= an asset you take from a vendor without any modification) should go into the vendor directory if possible in my opionion. Only assets that you maintain yourself (e.g. svg icon fonts) should go into the app directory. |
@jhilden thanks. Had seen this pattern before, but just wanted to have a clear understanding. |
@plapier Thanks for the excellent how-to! It's remains super useful! |
@plapier I think this issue still exists in Proteus for Middleman. Any ideas how to fix? |
@plapier Thanks a bunch! This worked for me today. |
Using Rails 4 and Bourbon, and some issues have reared their ugly heads. I'm using the font-face mixin:
However, the path generated in the stylesheet is /fonts/opensans-regular... but Rails 4 claims it doesn't exist. I have put all my font files under app/assets/fonts and added:
to my application.rb. It seems the correct path in rails 4 is now /assets/opensans-regular. Is it possible to redirect fonts to assets, or should Bourbon be using asset-path in the font-face helper instead? Would this break Rails 3 compatibility?
~ Jonathan
The text was updated successfully, but these errors were encountered: