From ce41259372f73c7e77a7970f8a0465873742498d Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Mon, 14 Dec 2009 22:32:32 +0100 Subject: [PATCH] Ignore invalid `setcurrentpoint' operations in Type 1 fonts. This fixes Savannah bug #28226. At least two wild PostScript files of unknown provenance contain Type 1 fonts, apparently converted from TrueType fonts in earlier PDF versions of the files, which use the `setcurrentpoint' operator inappropriately. FreeType currently throws an error in this case, but Ghostscript and Adobe Distiller both accept the fonts and ignore the problem. This commit #ifdefs out the check so PostScript interpreters using FreeType can render these files. The specification says `setcurrentpoint' should only be used to set the point after a `Subr' call, but these fonts use it to set the initial point to (0,0). Unnecessarily so, as they correctly use an `hsbw' operation which implicitly sets the initial point. --- ChangeLog | 20 ++++++++++++++++++++ src/psaux/t1decode.c | 13 +++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 454d73b3a..b8b209fff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2009-12-14 Ken Sharp + + Ignore invalid `setcurrentpoint' operations in Type 1 fonts. + This fixes Savannah bug #28226. + + At least two wild PostScript files of unknown provenance contain + Type 1 fonts, apparently converted from TrueType fonts in earlier + PDF versions of the files, which use the `setcurrentpoint' operator + inappropriately. + + FreeType currently throws an error in this case, but Ghostscript and + Adobe Distiller both accept the fonts and ignore the problem. This + commit #ifdefs out the check so PostScript interpreters using + FreeType can render these files. + + The specification says `setcurrentpoint' should only be used to set + the point after a `Subr' call, but these fonts use it to set the + initial point to (0,0). Unnecessarily so, as they correctly use an + `hsbw' operation which implicitly sets the initial point. + 2009-12-14 Bram Tassyns Fix parsing of /CIDFontVersion. diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index b3245a678..7c6a7871a 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -1453,12 +1453,20 @@ case op_setcurrentpoint: FT_TRACE4(( " setcurrentpoint" )); - /* From the T1 specs, section 6.4: */ +#if 0 + /* From the T1 specification, section 6.4: */ /* */ /* The setcurrentpoint command is used only in */ /* conjunction with results from OtherSubrs procedures. */ - /* known_othersubr_result_cnt != 0 is already handled above */ + /* known_othersubr_result_cnt != 0 is already handled */ + /* above. */ + + /* Note, however, that both Ghostscript and Adobe */ + /* Distiller handle this situation by silently ignoring */ + /* the inappropriate `setcurrentpoint' instruction. So */ + /* we do the same. */ + if ( decoder->flex_state != 1 ) { FT_ERROR(( "t1_decoder_parse_charstrings:" @@ -1467,6 +1475,7 @@ } else decoder->flex_state = 0; +#endif break; case op_unknown15: