wicked_pdf_stylesheet_link_tag seems to incorrectly handle urls when executed locally.
Given following original style (rails scss):
@font-face {
font-family: 'MyFont';
src: font-url('my-font/my-font.eot') format('eot')
}
which sprockets renders as:
@font-face {
font-family: 'MyFont';
src: url(/assets/my-font/my-font-<digest>.eof) format('eot')
}
wicket_pdf_stylesheet_link_tag renders:
@font-face {
font-family: 'MyFont';
src: url(file://<Rails.root>/public/assets/my-font/my-font-<digest>.eof) format('eot')
}
Which is incorrect as assets has not been precompiled in development.
I'd expect it to use the source file instead:
@font-face {
font-family: 'MyFont';
src: url(file://<Rails.root>/app/assets/my-font/my-font.eof) format('eot')
}
wicked_pdf gem version: 1.2.2
wkhtmltopdf version: 0.12.3
whtmltopdf provider gem and version if one is used:
platform/distribution and version: Ubuntu 18.04.2 LTS
I think that the cause of your problem is mentioned here.
I manage to use Google's custom font poppins with the help of Issue #334 this is what I did:
1) I have the font in OTF format located in assets/fonts/poppins/Poppins-Regular.otf
2) I declared the font-face in the CSS I am importing in my pdf.
pdf.scss.erb
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 300;
src: url('<%= asset_data_uri('poppins/Poppins-Regular.otf') %>')
}
body {
font-family: 'Poppins';
}
I am using ERB to get the URI of the asset automatically with the helper asset_data_uri
You need to add the fonts path to the assets path to avoid adding "fonts" to the asset_data_uri path
Application.rb
config.assets.paths << Rails.root.join("app", "assets", "fonts")
Hope this helps.
Most helpful comment
I think that the cause of your problem is mentioned here.
I manage to use Google's custom font poppins with the help of Issue #334 this is what I did:
1) I have the font in OTF format located in assets/fonts/poppins/Poppins-Regular.otf
2) I declared the font-face in the CSS I am importing in my pdf.
pdf.scss.erb
I am using ERB to get the URI of the asset automatically with the helper asset_data_uri
You need to add the fonts path to the assets path to avoid adding "fonts" to the asset_data_uri path
Application.rb
Hope this helps.