css - 自定义字体不会在 Firefox for Rails 4 应用程序中呈现

标签 css ruby-on-rails firefox ruby-on-rails-4 custom-font

我已经上传了一个名为 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/

相关文章:

css - 中心和右侧 div 定位

android - android 上的垂直对齐 ionic 标题

ruby-on-rails - 在 where 子句中将字符串转换为数字

ruby-on-rails - 算法 ruby​​ (rails) 最佳分数数组

html - 隐藏 MS Edge 和 Firefox 中的滚动条?

javascript - 如何使用 ng-class 比较自调用值

html - 如何限制我的 <style type ="text/css"> 标签的应用位置

javascript - AJAX提交后如何验证表单?

javascript - 在 Firefox 中设置 FileInput 的 FileList

javascript - jQuery 加入 location.hash 无尽清爽 Firefox