rposborne/wkhtmltopdf-heroku

Custom fonts aren't working

pelargir opened this issue · 3 comments

Custom fonts appear to be broken in v2.12.2.1

I'm setting a custom font in my document:

<style type="text/css">
body, table tr td, table tr th {
  font-family: 'Times New Roman, 'sans-serif';
}
</style>

When rendered as a PDF, the font appears as Verdana. No matter what font I specify in my stylesheet, it consistently renders as Verdana.

When I render with wkhtmltopdf on my MacBook, the font displays correctly. This only happens on Heroku.

I'll post more information as I dig deeper into this problem.

Hello,

It's most likely a wkthmltopdf issue. It seems it will always use the fallback font if one is provided. Could you try to remove sans-serif from the css?
Also, please make sure 'Times New Roman' is installed on the host machine. (heroku)

More here: http://stackoverflow.com/questions/24724712/rails4-pdfkit-fonts-heroku-not-working/24744183#24744183

I tried removing the fallback. No luck.

Something must have changed on Heroku because these fonts were working properly for a long time.

Any idea where to find font files that can be uploaded to Heroku? I tried using the Times New Roman font installed on my Mac but it looked pretty bad on the resulting PDF.

include the fonts file in your application's repo, and move them (or symlink them) to ~/.fonts