Commit ce41259372f73c7e77a7970f8a0465873742498d

Ken Sharp 2009-12-14T22:32:32

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.

diff --git a/ChangeLog b/ChangeLog
index 454d73b..b8b209f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2009-12-14  Ken Sharp  <ken.sharp@artifex.com>
+
+	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  <bramt@enfocus.be>
 
 	Fix parsing of /CIDFontVersion.
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index b3245a6..7c6a787 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: