Issue Type: Patch Created: 2007-09-25T11:51:39.000+0000 Last Updated: 2008-03-31T16:12:01.000+0000 Status: Resolved Fix version(s): Reporter: Logan Buesching (ljbuesch) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Pdf
Related issues: - ZF-313
Attachments: - ZendFontWidthPatch.txt
When looking through the Zend_Pdf library, I noticed that the font width's for glyphs used synthetic numbers and not the actual widths. I recently looked up the numbers on Adobe's site: http://www.adobe.com/devnet/font/ (In particular I used the UNIX specs), and changed the values accordingly. This aids in doing things such as centering and positioning text.
Attached is the corresponding patch.
This patch is against Zend Framework Release 1.0.1 (build 5906).
Thanks, Logan Buesching
Posted by Logan Buesching (ljbuesch) on 2007-09-25T11:52:32.000+0000
Corresponding patch which updates the glyph width values.
Posted by Logan Buesching (ljbuesch) on 2007-09-25T11:53:40.000+0000
Posted by Willie Alberty (willie) on 2007-09-25T16:15:24.000+0000
The glyph widths themselves are not synthetic -- they are taken directly from the same Adobe core 14 AFM (Adobe Font Metrics) files you were looking at.
What is synthesized are the glyph numbers. If you look a bit farther down in these classes, you'll see an array called $cmapData, which is the character code-to-glyph mapping array. This array translates Unicode code points (characters) to the appropriate glyph numbers for the font.
For custom fonts (currently only OpenType, though Type 1 support is on the roadmap), the glyph widths and character-to-glyph map are read from the font itself. These metrics data are then included in the generated PDF document.
Since every PDF viewer is required to support the standard 14 PDF fonts (Helvetica, Times, Courier, Symbol, and Zapf Dingbats), none of the metrics data needs to be written to the PDF, so the glyph numbers that are used by the framework are for internal-use only and so the specific numbers used are not important.
Look at the $cmapData values: you will see that character code U+0020 SPACE (0x20) is mapped to glyph number 0x01, which has a width is 0x0116. Character code U+003F QUESTION MARK 0x3f is mapped to glpyh number 0x20, with a width of 0x0263.
You were probably getting incorrect width calculations because you were asking for the wrong widths. In your patch, you have confused character codes with glyph numbers. Characters and glyphs are related, but totally distinct concepts. A good primer can be found here: http://developer.apple.com/documentation/Cocoa/…
Calculating the width of a string requires two steps. You must first convert the abstract characters to concrete glyphs (the typesetting phase), then calculate the widths of those glyphs. There is a function in ZF-313 which shows you how to do this.
Posted by Wil Sinclair (wil) on 2008-03-31T16:12:00.000+0000
Please evaluate and categorize as necessary.
Have you found an issue?
See the Overview section for more details.