如何在 rails 5 中设置资产管道以使用自定义字体?

Imr*_*Ali 5 css fonts asset-pipeline ruby-on-rails-5

我必须在 rails 5 应用程序中使用自定义字体Jameel Noori Nastaleeq。我以前从未在 Rails 中使用过资产管道。以下是我采取的一些步骤:

  1. 在 中创建fonts文件夹app/assets,并将提取的ttf字体文件放入其中
  2. 添加config.assets.paths << Rails.root.join("app", "assets", "fonts")config/application.rb
  3. 添加以下内容app/assets/stylesheets/couplets.scss

    @font-face {
    font-family: 'Jameel Noori Nastaleeq';
    src:asset-url('JameelNooriNastaleeq.ttf') 格式("truetype");
    }
    虽然没有错误/警告,上述步骤没有任何效果。我是不是错过了什么。

我已经看到类似的问题Custom Font not working in Rails Asset Pipeline Integrating @font-face files into rails asset pipeline, 但他们的回答没有帮助。

我的github repo 中的完整代码

Imr*_*Ali 1

我已经使用脚手架生成了资源。添加所需的解决font-familyapp/assets/stylesheets/scaffold.scss该问题。我已经更新了github 存储库