【问题标题】:How do I get fonts to download on web when the exist?存在字体时如何在网络上下载字体?
【发布时间】:2014-12-08 04:02:21
【问题描述】:

由于某种原因,我的字形图标没有显示。当我在检查器中查看文件时,它们显示为红色,因为它们是字节 0。但是我可以成功访问链接:

http://admin.packagezen.com/assets/glyphicons-halflings-regular.woff

任何想法,发生了什么?也许是heroku?还是铁轨?我将字体放在 /public/assets 中,当我 ssh 进入服务器时该文件存在。

【问题讨论】:

标签: ruby-on-rails fonts webfonts


【解决方案1】:

您可以配置 Rails 资产管道来为您服务。执行以下操作:

将该字体放入(不在公共/资产中):

/assets/fonts/glyphicons-halflings-regular.woff

在您的 application.css 中添加使用此字体/url 的字体,这将引用此字体的指纹版本:

@font-face {
  font-family: 'Glyphicons';
  src: font-url("/assets/fonts/glyphicons-halflings-regular.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

然后随意在任何地方使用该名称来引用该字体。试试看。

【讨论】:

    【解决方案2】:

    您是否在 config/application.rb 文件中添加了以下内容(在 Application

    config.assets.paths << "#{Rails}/vendor/assets/fonts"
    

    例如来源:http://www.erikminkel.com/2013/09/01/twitter-bootstrap-3-in-a-rails-4-application/

    【讨论】:

      猜你喜欢
      • 2013-05-16
      • 2016-03-13
      • 2012-11-03
      • 2011-06-13
      • 1970-01-01
      • 2011-07-01
      • 2011-10-17
      • 2011-12-08
      相关资源
      最近更新 更多