ZF-1874: Zend_Pdf fails with some freware TTF fonts


Zend_Pdf fails with some freware barcode fonts ([]).

It throws an exception:

Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Glyph number is out of range: 81' in /home/cawa/ZendFramework/trunk/library/Zend/Pdf/Resource/Font.php:477
Stack trace:
#0 /home/cawa/ZendFramework/trunk/library/Zend/Pdf/Resource/Font/OpenType.php(147): Zend_Pdf_Resource_Font->widthsForGlyphs(Array)
#1 /home/cawa/ZendFramework/trunk/library/Zend/Pdf/Resource/Font/OpenType/TrueType.php(53): Zend_Pdf_Resource_Font_OpenType->__construct(Object(Zend_Pdf_FileParser_Font_OpenType_TrueType), 0)
#2 /home/cawa/ZendFramework/trunk/library/Zend/Pdf/Font.php(720): Zend_Pdf_Resource_Font_OpenType_TrueType->__construct(Object(Zend_Pdf_FileParser_Font_OpenType_TrueType), 0)
#3 /home/cawa/ZendFramework/trunk/library/Zend/Pdf/Font.php(637): Zend_Pdf_Font::_extractTrueTypeFont(Object(Zend_Pdf_FileParserDataSource_File), 0)
#4 /home/cawa/ZendFramework/laboratory/Pdf/BarCodeFonts/test1.php(15): Zend_Pdf_Font::fontWithPath('./FRE3OF9X.TTF')
#5 {main}
  thrown in /home/cawa/ZendFramework/trunk/library/Zend/Pdf/Resource/Font.php on line 477

The interesting thing is that if this font is converted to another format and then back to the TTF, then it works proper.


An example of converted font

Interestingly enough, I've been hanging out to post the same issue regarding 'Courier New'. (COUR.TTF)

Aug 28 11:36:34 www3 httpd: PHP Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Glyph number is out of range: 3' in /usr/local/www/ Stack trace:

0 /usr/local/www/ Zend_Pdf_Resource_Font->widthsForGlyphs(Array)

1 /usr/local/www/ Zend_Pdf_Resource_Font_OpenType->__construct(Object(Zend_Pdf_FileParser_Font_OpenType_

(Trace truncated thanks to syslog)

I'll try converting it to pfa and back and see if it helps; sadly I'm not sufficiently familiar with TTF and company to know where to start for a patch.

Much as I'd love to post a copy of the font, I don't think Microsoft class it as freeware just yet.



Thanks for the info Mike!

Could you also attach font to the issue (if it's allowed by font license)?


It would seem they are available for download from… (As I understand it, the license does not allow distribution other than in their original form.)

The file can be extracted using cabextract on non-Windows platforms.

cour.ttf in that particular package is 2.82, which exhibits the behavior; as does 2.9, which I tried from one of the local Windows XP installations.

Hope that helps,


I'm encountering the same issue with the freeware OCR-B font from Any solution to this problem so far? If not, is there any other freeware OCR font that works with Zend_Pdf_Resource_Font?

There was a problem in glyph width array processing. It may contain less elements than glyphs are presented in the font. Last element contains width for the rest of glyphs list.