我已经上传了一个名为 Kodin 的自定义字体,所有字体都可以在 IE、Chrome 和 Safari 中使用,但不能在 Firefox 中使用。
我已经将所有自定义字体上传到 app/assets/fonts
包含的文件是....
Kodin-Regular.otf
Kodin-Regular.eot
Kodin-Regular.woff
Kodin-Regular.ttf
我的 application.css 文件包括...
@font-face {
font-family: "KODIN";
src: url('/assets/Kodin-Regular.otf') format("truetype");
src: url('/assets/Kodin-Regular.eot') format('embedded-opentype'),
url('/assets/Kodin-Regular.woff') format('woff'),
url('/assets/Kodin-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
一切都很好。但是字体不会在 Firefox 网站上的任何地方呈现。我已经看到一些关于如何解决此问题的堆栈溢出线程,但没有一个是针对 Rails 的特定建议。
谢谢!
更新
在 Firefox 中发现了一些控制台错误。路径不对?
downloadable font: download failed (font-family: "KODIN" style:normal weight:normal stretch:normal src index:0): status=2147746065 source: http://localhost:3000/assets/Kodin-Regular.otf application.css:25:12
downloadable font: download failed (font-family: "KODIN" style:normal weight:normal stretch:normal src index:2): status=2147746065 source: http://localhost:3000/assets/Kodin-Regular.woff application.css:25:12
downloadable font: download failed (font-family: "KODIN" style:normal weight:normal stretch:normal src index:3): status=2147746065 source: http://localhost:3000/assets/Kodin-Regular.ttf application.css
最佳答案
如图所示尝试使用 Assets 路径,希望它有效。
src:url(asset-path('Kodin-Regular.otf')) format('truetype');
关于css - 自定义字体不会在 Firefox for Rails 4 应用程序中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28992616/