Ruby on Rails上でアイコンフォント(glyicons)が表示されない
ので調べた結果をまとめる。
- ファイルはvendor/assetsの下に置く
アプリケーション名/vendor/assets/fonts
の下に
glyphicons-halflings-regular.eot glyphicons-halflings-regular.svg glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff
を置く。
- pathとプリコンパイルの設定。
Assets Pipelineのパス指定でプリコンパイルの対象に入れないと読み込んでくれないようなので
下記のファイルに記述を追加
# config/application.rb config.assets.precompile += %w(*.eot *.svg *.ttf *.woff) config.assets.paths << "#{Rails}/vendor/assets/fonts"
- css内のパスも指定
上記の二つだけでできなかったのでcss側も記載したらできた。
アプリケーション名/app/assets/stylesheetsの配下にあるCSSに記述
@font-face { font-family: 'Glyphicons Halflings'; src: url('/assets/glyphicons-halflings-regular.eot'); src: url('/assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('/assets/glyphicons-halflings-regular.woff') format('woff'), url('/assets/glyphicons-halflings-regular.ttf') format('truetype'), url('/assets/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg'); }