2017-04-20 63 views
0

工作在我的Rails應用程序5,我有這個在我的application.sass文件...引導Glyphicons不是on Rails的

/* 
*= require bootstrap-sass-official 
... 
*/ 

@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') 

...按建議在Ruby on Rails Bootstrap Glyphicons not working。我得到這個錯誤在我的Chrome控制檯:Failed to decode downloaded font: http://localhost:3000/assets/glyphicons-halflings-regular.woffetc..的各種字體格式。

我需要將任何東西放入我的Rails資產fonts文件夾?如果是這樣,具體是什麼?非常感謝你的幫助。

回答

1

由於應用Rails的5,更好的辦法 - 把你的字體的文件夾app/assets/fonts英寸

如果你想外面把他們fonts文件夾,你需要添加以下配置:

config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/

然後可以使用網址作爲提及

@font-face { 
    font-family: 'Glyphicons Halflings'; 
    src: url('/assets/glyphicons-halflings-regular.eot'); 
    src: url('/assets/glyphicons-halflings-regular.eot?iefix') format('eot'), 
     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'); 
} 
+0

好吧,謝謝非常!有效! – Matt

+0

@Matt樂於幫忙!所謂的感謝 - 標記,猶如它的工作原理回答的答案;) – idej

+0

你知道,如果有與glyphicons工作是在軌道4,5什麼不同嗎? – Matt