I am using Wicked pdf to generate pdf in rails 4 application. I need to render urdu fonts in pdf. Following these two answers by Nikhil and Ashitaka, I downloaded Jameel Noori Nastaleeq font from here, installed them on my local and added them in assets/fonts
folder. After precompiling assets, defined font-family in my pdf.scss
@font-face {
font-family:"Jameel Noori Nastaleeq";
src:url("Jameel Noori Nastaleeq/Jameel Noori Nastaleeq.ttf");
font-weight: bold;
}
.urdu-font {
font-family: 'Jameel Noori Nastaleeq';
}
My pdf view file looks like this
%head
%meta{:charset => "utf-8"}
= wicked_pdf_stylesheet_link_tag 'pdf'
%body.urdu-font
= render "custom_form"
where _custom_form.pdf.haml partial contains input field containing urdu text.
Urdu font works fine on local in both pdf and debug mode but when deployed, it don't render correctly in pdf file whereas it renders fine in debug mode.
In debug mode I checked the path of font asset i.e src:url(file:////home/deploy/<remote-location>/releases/20180622133137/public/assets/Jameel Noori Nastaleeq/Jameel Noori Nastaleeq-39c54f1646a6a4f68408f3a26400e457cb1e52226c284d8c4ab36a3363520e0f.ttf)
which appears to be fine and font actually renders fine in this html debug mode.
P.S. I have also seen this post which is using remote fonts provided by googleapi
. I have tried this and it works but I want to use local font resource.