rposborne / wkhtmltopdf-heroku

wkhtmltopdf binary for heroku / amd64
MIT License
225 stars 92 forks source link

Times New Roman font is not supported #30

Closed fatuhoku closed 8 years ago

fatuhoku commented 8 years ago

By using wkhtmltopdf-heroku I was expecting it to help me install some very basic fonts. But everything appears as Verdana.

.mystyle
{
    font-size: 4pt;
    font-family: 'Times New Roman', 'Times', serif;
}

This may be a dupe of #20 but I was hoping for some guidance.

pallymore commented 8 years ago

first of all you have to make sure Times New Roman is installed in your system, then, (just my personal experience), I believe wkhtmltopdf always uses the fallback font when multiple fonts are specified. so please try to use one font in each font-family definition:

    font-family: 'Times New Roman';
fatuhoku commented 8 years ago

Okay, I've managed to get it working. Thanks!

niksosf commented 7 years ago

Hi @fatuhoku how did you manage to get it working?

fatuhoku commented 7 years ago

I put times-new-roman.ttf and times-new-roman-bold.ttf to /vendor/assets/fonts, and then also added:

// fonts.scss

// Times New Roman and Arial are included for PDF generation

@font-face {
  font-family: 'Times New Roman';
  src: font-url('times-new-roman.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Times New Roman';
  src: font-url('times-new-roman-bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

Now you can use font-family: 'Times New Roman' in your CSS and it'll be recognized!

BodikSilver commented 6 years ago

@pallymore Thanks! You help me with this problem. I`m all day search this solution)