Embed custom font in rails 6 is a bit tricky, below are the steps in order to embed custom font in rails 6 project especially work it works fine for wicked pdf gem
- Include your prefer font in
app/assets/fonts/
- Update
app/assets/config/manifest.js
...
//= link_tree ../fonts
- I also create
app/assets/stylesheets/embeded_fonts.scss
@font-face {
font-family: "khmeros_battambang";
src: font-url("khmeros_battambang.ttf") format("truetype");
}
- Import to
app/assets/stylesheets/application.scss
@import "embeded_fonts";
- Import to
layouts/pdf.html.haml
= stylesheet_link_tag "embeded_fonts"
= wicked_pdf_stylesheet_link_tag "pdf"
= wicked_pdf_javascript_pack_tag "pdf"
- Call the embedded font
body {
font-family: 'khmeros_battambang'
}
Top comments (0)