Skip to main content

Wkhtmltopdf doesn't support displaying multiple fonts that aren't google font. This problem would be due to incorrect properties set when creating fonts. Here is how to insert a non google font in wkhtmltopdf.

First, your font name must have a maximum of 8 characters. (e.g: American.ttf)
If you want to integrate a font with its variations (light, regular, bold, extrabold), each of these must be a separate file with a name not exceeding 8 characters (e.g: AmeBold.ttf for the Bold variation of the American typo).

Install FontForge

After that, go to the FontForge website to download the software and install it on your computer. 

  1. Open the software and select your font to modify
  2. Go to 'Elements' > "Infos fonte" (ctrl + shift + F)
  3. Modify this fields : "font name", "font family name", "current name" with the same name of 8 charactere maximum (e.g: American)
  4. Click on "OK"

Insert a non google font in wkhtmltopdf

Finally, integrate the following code in your CSS :

@font-face {
   font-family: 'American';
   src: url('../fonts/american.ttf') format('truetype');
   font-weight: normal;
   font-style: normal;
}

Étiquettes
Let's discuss your project

Contact us

  •  + 32 (0) 10 49 51 00
  •  info@expert-it.com