I have a Rails 4 application and I am trying to use a custom font.
I have followed many tutorials on this and somehow it\'s just not working for my application.
<Restart 'rails server' after creating the app/assets/fonts directory
In case if you guys have problem using fonts in Rails 5 you just need to edit app/assets/config/manifest.js
And then insert this //= link_tree ../fonts
How to use:
@font-face {
font-family: 'FontAwesome';
src: url('fontawesome-webfont.eot?v=4.6.3');
src: url('fontawesome-webfont.eot?#iefix&v=4.6.3') format('embedded-opentype'), url('fontawesome-webfont.woff2?v=4.6.3') format('woff2'), url('fontawesome-webfont.woff?v=4.6.3') format('woff'), url('fontawesome-webfont.ttf?v=4.6.3') format('truetype'), url('fontawesome-webfont.svg?v=4.6.3#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
And also dont forget to restart your server.
In Rails 4, there is a helper to set the path for the fonts.
If you have the font in /assets/fonts or vendor/assets/fonts, Rails 4 will find them! To take advantage of this, in the Bootstrap CSS file change the @font_face call to
@font-face {
font-family: 'Glyphicons Halflings';
src: font-url('glyphicons-halflings-regular.eot');
src: font-url('glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
font-url('glyphicons-halflings-regular.woff') format('woff'),
font-url('glyphicons-halflings-regular.ttf') format('truetype'),
font-url('glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
Note that there is no folder specification in front the font files. This is completed by the rails helper.