troubleshooting the installation of certain fonts in 0.7.0

1,237 views
Skip to first unread message

Dan Steeby

unread,
Jan 8, 2016, 12:24:33 PM1/8/16
to dompdf
In setting up our installation of dompdf 0.7.0 using the provided load_font.php file, some fonts did not install properly using the the script, and were throwing the following error:


Warning:  unpack(): Type n: not enough input, need 2, have 0 in /home/rpgbardc/public_html/dompdf_070/lib/php-font-lib/src/FontLib/BinaryStream.php on line 183

I have done some looking into this, and it looks like as the font setup occurs, during the Adobe Font Metrics generation step, problematic fonts are not returning any records in the AdobeFontMetrics::write method AdobeFontMetrics.php line 65, causing the foreach loop immediately after to fail.  In my case, the $font variable is an instance of the class declared in /FontLib/TrueType/File.php, and in looking at the getData method of that class, it looks like the instance's $this->data[ 'name' ] property is unset, so the method returns null. In inspecting the $this->data array on these fonts, it is empty.

$this->data seems to come from the getData method, which calls the parseTableEntries method, which calls parseHeader.  In this method, sometimes $this->header is already set up, but if so $this->header->data is empty, and other times $this->header is not set up, so it is setup in the method, but inspecting the header after it is created, the header has NULL set for its data property.  This is as far as I have tracked it down so far, and I have not looked into the inner workings of the /FontLib/TrueType/File::parseHeader method to figure out why the data array is not being set up.

Let me know if you have any ideas why this would be problematic for certain fonts, and if it is helpful we have been able to install these fonts successfully in dompdf 0.6.2, so this appears to be unique to the beta at this time.  I'm happy to help if I'm able, and will try to continue to troubleshoot things on my end.

thanks,

Dan Steeby

BrianS

unread,
Jan 11, 2016, 3:06:24 PM1/11/16
to dompdf
That's some fine investigation. It might be instructive to compare the version of php-font-lib included with 0.6.x and the one included with 0.7.x. Something I might be inclined to do given a few moments. There have been some updates to the code since the last release of php-font-lib (currently v0.4) and so you might try downloading the current code from the master branch since it should be compatible with dompdf 0.7.x.

BrianS

unread,
Feb 17, 2016, 6:11:49 PM2/17/16
to dompdf
A related issue is now open for php-font-lib: https://github.com/PhenX/php-font-lib/issues/47
Reply all
Reply to author
Forward
0 new messages