Question

I want to install new font on my DOMPDF but when I run

http://www.spanskeboliger.dk/wp-content/themes/rttheme17/dompdf/load_font.php

it has an error:

Unable to locate the ttf2afm / ttf2pt1 executable (checked /usr/bin/ttf2pt1).

How can I fix this and able to run the load_font.php .

Was it helpful?

Solution

First a note: load_font.php should be run from the command line/shell and not via your web server.

In order to load fonts into versions of dompdf prior to 0.6.0 you first have to install a copy of ttf2ufm (aka ttf2pt1 / ttf2afm) onto your system. This is a binary executable that extracts the character metrics from the font file. dompdf uses the metrics when laying out the text.

The error is telling you what you need to know, that dompdf can't find the ttf2ufm program. If you have a copy of ttf2ufm on your system you should update the value of the TTF2AFM configuration constant in dompdf/domdpf_config.inc.php.

That being said, dompdf 0.6.0 includes a PHP-based font parser (php-font-lib) and no longer requires ttf2ufm. This release is, for most people, a drop in replacement for earlier versions. You can get a copy of the newer release via github.

In addition to no longer requiring ttf2ufm dompdf 0.6.0 also includes the following font-related features:

  • Full UTF-8 support (Unicode in the PDF)
  • web-based font installation (via dompdf/www/fonts.php)
  • support for @font-face
  • font subsetting
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top