PdfBundle icon indicating copy to clipboard operation
PdfBundle copied to clipboard

Unable to import custom fonts

Open badB00l opened this issue 11 years ago • 4 comments

I was trying to import a custom font (Calibri) in this directory app/Resources/PHPPdf/Resources/fonts/Calibri

so I create a custom fonts.xml in app/Resources/PHPPdf/Resources/config/

and change my config.yml inserting these two optional lines, as explained in the guide

ps_pdf: fonts_file: "%kernel.root_dir%/Resources/PHPPdf/Resources/config/fonts.xml"

but it isn't seen at all because when it load my just modified detail.pdf.twig an error occur

Font "/Applications/XAMPP/xamppfiles/htdocs/myProject/vendor/psliwa/php-pdf/lib/PHPPdf/Resources/fonts/Calibri/bold.ttf" not found.

It's still trying to find the font in the old directory. How can I solve this?

badB00l avatar May 21 '13 16:05 badB00l

What symfony2 version do you use?

psliwa avatar May 22 '13 18:05 psliwa

i'm using 2.2.1. Thanks for your help

badB00l avatar May 22 '13 19:05 badB00l

%resources% pattern is replaced by path to Resources directory in PHPPdf library, so it works ok. In fonts.xml file you should user relative path, for example: "%resources%/../../../../../../app/Resources/PHPPdf/Resources/fonts/somefont.ttf". This solution is not elegant, but it should work.

psliwa avatar May 23 '13 18:05 psliwa

I know this is an issue from 2 years ago ...sry

I got the same problem and it was not a problem if the specified path.

The problem in my case seems to be that the Zend-Framework component loading/opening the fonts does not support all fonts

CorruptedFontException: Unable to read version 4 table - in vendor/zendframework/zendpdf/library/ZendPdf/BinaryParser/Font/OpenType/AbstractOpenType.php at line 534 -

so i guess it's a limitation due to the class used which fonts can be included as "custom" font right ?

EDIT: it seems be a problem with my ttf font, i tried antother one and that one worked it was just irritating that the error was the same "could not load ... font"

nixoschu avatar Jul 01 '15 20:07 nixoschu