Imran Ali
Imran Ali

Reputation: 2279

How to setup assets pipeline in rails 5 to use a custom font?

I have to use a custom font Jameel Noori Nastaleeq in a rails 5 app. I have never worked with assets pipeline in rails before. Here are some of the steps I have taken:

  1. create fonts folder in app/assets, and place the extracted ttf font file in it
  2. add config.assets.paths << Rails.root.join("app", "assets", "fonts") in config/application.rb
  3. add the following in app/assets/stylesheets/couplets.scss:

    @font-face {
    font-family: 'Jameel Noori Nastaleeq';
    src:asset-url('JameelNooriNastaleeq.ttf') format("truetype");
    }
    Although there is no error/warnings, the above steps have no effect. Am I missing something.

I have already seen similar questions Custom Font not working in Rails Asset Pipeline Integrating @font-face files into rails asset pipeline but their answers were not helpful.

Complete code in my github repo

Upvotes: 5

Views: 1899

Answers (1)

Imran Ali
Imran Ali

Reputation: 2279

I had generated the resources using scaffold. Adding desired font-family in app/assets/stylesheets/scaffold.scss fixed the problem. I have updated the github repo.

Upvotes: 1

Related Questions