shithub: freetype+ttf2subf

Download patch

ref: ce41259372f73c7e77a7970f8a0465873742498d
parent: 2db97838697050f2d25e18947f8d419e5bf31234
author: Ken Sharp <[email protected]>
date: Mon Dec 14 17:32:32 EST 2009

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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2009-12-14  Ken Sharp  <[email protected]>
+
+	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  <[email protected]>
 
 	Fix parsing of /CIDFontVersion.
--- 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: