R
R
rootssl2016-01-01 16:42:39
css
rootssl, 2016-01-01 16:42:39

How to include icon fonts in rails?

there is an assets / fonts folder
in the scss file, I write:

@font-face {
  font-family: 'glyphicons-halflings-regular';
  src: font-url('glyphicons-halflings-regular.eot');
  src: font-url('glyphicons-halflings-regular.eot?iefix') format('eot'),
  font-url('glyphicons-halflings-regular.woff') format('woff'),
  font-url('glyphicons-halflings-regular.ttf') format('truetype'),
  font-url('glyphicons-halflings-regular.svg#webfont') format('svg');
}

application.rb says:
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')

it is written in initialize/assets.rb
Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/

The pictures still won't load.
There are no errors, nothing. I don't know where to drop

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Kostin, 2017-01-05
@anton9

Try this:
add the (optional) ending .erb (i.e. file_name.scss.erb) to the file
next

@font-face {
  font-family: 'glyphicons-halflings-regular';
  src: url(<%= font_path 'glyphicons-halflings-regular.eot' %>);
  src: url(<%= font_path 'glyphicons-halflings-regular.eot?iefix' %>) format('eot'),
  url(<%= font_path 'glyphicons-halflings-regular.woff' %>) format('woff'),
  url(<%= font_path 'glyphicons-halflings-regular.ttf' %>) format('truetype'),
  url(<%= font_path 'glyphicons-halflings-regular.svg#webfont' %>) format('svg');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question