Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 516
Imran Ali Avatar asked Nov 07 '22 22:11

Imran Ali


1 Answers

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.

like image 135
Imran Ali Avatar answered Nov 15 '22 12:11

Imran Ali