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.
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 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;
<?php
class Font extends FontLib\Font {
//this is a namespace fix:
}
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');
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
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With