Thu 13 Dec 2007 07:18:04 PM UTC, original submission:
The CFF parser incorrectly assembles its return value into 16.16 form, which can lead to significant rendering errors depending on the values used in the font.
The attached PDF "aprob.pdf" demonstrates the problem when displayed with a FreeType-based viewer such as Evince. The 4 lines of Arabic text should all have similar glyph sizes, but the glyphs in the 3rd of these lines are rendered much too small.
Analysis: the PDF contains an embedded CFF font, AdobeArabic-Regular, which uses unusual FontMatrix values [0.000488281 0 0 0.000488281 0 0], where the real-valued entries are encoded as 1e 4a 88 28 1c 4f in the CFF stream.
The FreeType function cff_parse_real (in src/cffparse.c) applies "power_ten" division to the integer part of the value too early; this can cause the most significant digit(s) of the final result to be lost as the value is truncated to an integer. Subsequently shifting it into the high 16 bits of the final result does not restore the lost bits.
A proposed patch is attached; this corrects the behavior by converting the value to 16.16 format before applying any necessary power_ten adjustment. With this patch applied to FreeType, the sample PDF displays correctly in Evince (or other viewers that rely on FT for font rendering).
(Aside: it seems that Adobe Reader 8 also has a problem with this PDF, though in a different way. It renders the glyphs too large, as if assumes a standard FontMatrix of [0.001 0 0 0.001 0 0]. Earlier versions (tested both 5.0 and 7.0) displayed the glyphs correctly scaled.)
|