DOMPDF - Class 'Font' not found

2019-06-16 12:44发布

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.

标签: php dompdf
8条回答
Bombasti
2楼-- · 2019-06-16 13:34

I'm late to the party here, but working with dompdf in 2018 still seems to experience this issue when loading Google Fonts with CSS. The specific error I see is:

"Uncaught Error: Class 'FontLib\Font' not found"

With version 0.8.2 (July 2018) I solved by loading the php-font-lib library before loading dompdf using the following:

// Load DOMPDF library
require_once( 'composer/phenx/php-font-lib/src/FontLib/Autoloader.php' );
require_once( 'composer/dompdf/dompdf/src/Autoloader.php' );
Dompdf\Autoloader::register();

You'll need to make sure your composer path is correct here, I've removed a variable from the require_once() calls.

查看更多
相关推荐>>
3楼-- · 2019-06-16 13:36

I used dompdf-master V.0.6.1, I solved it by

require_once "../lib/php-font-lib/classes/Autoloader.php"; use FontLib\Font; to font_metrics.cls.php when I install new font

查看更多
登录 后发表回答