dompdf experiment pt2 – installing a font

The default fonts that come with pdf aren’t enough for me, so I want to install a new font. To do so you need to have ttf2pt1 installed on the webserver. Unfortunately that’s not the case for me. The dompdf manual says the following about having problems installing fonts:

Also, if you have problems installing the font files, you can try and use the distributed dompdf_font_family_cache.dist file in lib/fonts. Copy this file to lib/fonts/dompdf_font_family_cache and edit it directly to match the files present in your lib/fonts directory.

Let’s see if this will work…

EDIT: Ok, found a nice .afm font (serpentine), put it in the lib/fonts dir of dompdf 0.5.1 and edited the dompdf_font_family_cache file, the following has been added:

  1. 'serpentine' =>
  2. array (
  3. 'normal' => DOMPDF_FONT_DIR . 'SerpeMed',
  4. 'bold' => DOMPDF_FONT_DIR . 'SerpeBol',
  5. 'italic' => DOMPDF_FONT_DIR . 'SerpeMedObl',
  6. 'bold_italic' => DOMPDF_FONT_DIR . 'SerpeBolObl',
  7. )

When I try to make a pdf using this font with dompdf an error is thrown and no pdf is generated…

To be continued…

Edit: An .atm AND .pfa or .pfb file are required to make it work. So now it works great! 🙂

4 thoughts on “dompdf experiment pt2 – installing a font

Leave a Reply

Your email address will not be published. Required fields are marked *