I got this working for version 0.3.1 / 0.4 pdf-font-lib (commit: b8af0ca) and DomPDF v6.1.0 (commit: c3527d9) by creating a Font class that extends FontLib \ Font;
<?php class Font extends FontLib\Font {
And in the class where I use DomPDF:
require_once('lib/dompdf/include/autoload.inc.php'); require_once('lib/dompdf/lib/php-font-lib/src/FontLib/Autoloader.php'); require_once('dir/where/you/placed/the/file/Font.php');
The Font class is now available in the global namespace.
I choose this approach because I am a little more dynamic and do not want to change / edit the source library, since it is in the main branch, and this is the LGPL license.
However, note that the beta version of DomPDF 0.7.0 released on May 1 is not compatible with the latest version of pdf-font-lib. Check this out: https://github.com/dompdf/dompdf/releases/tag/v0.7.0-beta
Daniel van der Garde
source share