I'm trying to add a font via Command line.
Every time I try i get the following error.
Fatal error: Class 'Font' not found in
/home/scripts/public_html/MarketingPalv2/load_font.php on line 139
I also get a similar error when I try to use @font-face
Fatal error: Class 'Font' not found in
/home/scripts/public_html/MarketingPalv2/include/font_metrics.cls.php on line 346
Hope you guys can help.
Solved this for dompdf 0.6.1 using latest pdf-font-lib by editing load_font.php and making the header look like:
require_once "dompdf_config.inc.php";
require_once "lib/php-font-lib/classes/Autoloader.php"; use FontLib\Font;
I fixed the issue by change
dompdf/include/font_metrics.cls.php
file as bellowcopy past this code on top
I got this working for version 0.3.1 / 0.4 of pdf-font-lib (commit: b8af0ca) and DomPDF v6.1.0 (commit: c3527d9) by making a Font class that extends FontLib\Font;
And in the class where I use DomPDF:
Now the class Font is available in the global namespace.
I choose this approach because I'm in a bit more dynamic situation and didn't want to change/edit the original library since it is from the master branch and it is LGPL licensed.
However, note that DomPDF 0.7.0 beta, that is released on 1 May, is out of the box compatible with the latest pdf-font-lib. Check it out: https://github.com/dompdf/dompdf/releases/tag/v0.7.0-beta
I hope this will help someone.
In case you get this error,
You have to change
dompdf/include/font_metrics.cls.php
file as below. So it will look like;You need to add the second & third lines only. First one will be already there.
I figured out what it was.
I downloaded the newest version of php-font-lib but i needed a older version.
I got this working for version DomPDF v6.1 by adding
to the file font_metrics.cls.php above