Fri 22 Jul 2011 12:55:18 PM UTC, original submission:
Attached is a font file extracted from a PDF. It contains a CID CFF font with a single sub font. The top dict contains no FontMatrix, the sub font dict does.
If the sub font dict specifies a FontMatrix, and the Top dict does not. The matrix from the sub font dict should be used (and not divided by 1000 by multiplying it with the default value of the FontMatrix for the Top dict).
There is already some fuzzy code present to fix this case (by checking if the scale factor is abnormally high), in cffobjs.c:691
...
if ( temp != 0x10000L )
{
upm = FT_DivFix( upm, temp );
/* if upm is larger than 1001000 we divide by 1000 -- */
/* this can happen if e.g. there is no top-font FontMatrix */
/* and the subfont FontMatrix already contains the complete */
/* scaling for the subfont (see section 5.11 of the PLRM) */
/* 100 is a heuristic value */
if ( upm > 100L 1000L )
upm = ( upm + 500 ) / 1000;
matrix->xx = FT_DivFix( matrix->xx, temp );
matrix->yx = FT_DivFix( matrix->yx, temp );
matrix->xy = FT_DivFix( matrix->xy, temp );
matrix->yy = FT_DivFix( matrix->yy, temp );
offset->x = FT_DivFix( offset->x, temp );
offset->y = FT_DivFix( offset->y, temp );
}
...
My problem is fixed by moving the lines:
if ( upm > 100L 1000L )
upm = ( upm + 500 ) / 1000;
outside of the if (together with the comments). I don't see a reason why this fix should only be applied for the case where FT_ABS( matrix->yy ) != 0x10000L.
This fixes my problem without changing too much in the underlying code. However I do have questions with the existing code. Why not check if the top dicts font matrix was present (or simply filled in by default) and have special code for that case in the if structure above it that combines the top font matrix and sub font matrix?
|