Commit 555258fffe183fb2da2b2e84981d9284b505d6c7

Werner Lemberg 2007-01-21T09:46:37

* docs/CHANGES: Document SHZ fix. * src/truetype/ttinterp.c (Ins_SHZ): SHZ doesn't move phantom points.

diff --git a/ChangeLog b/ChangeLog
index b2da9cd..43f368f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2007-01-21  Werner Lemberg  <wl@gnu.org>
 
+	* docs/CHANGES: Document SHZ fix.
+
+2007-01-21  George Williams  <gww@silcom.com>
+
+	* src/truetype/ttinterp.c (Ins_SHZ): SHZ doesn't move phantom
+	points.
+
+2007-01-21  Werner Lemberg  <wl@gnu.org>
+
 	* src/sfnt/ttmtx.c (tt_face_get_metrics)
 	[!FT_CONFIG_OPTION_OLD_INTERNALS]: Fix limit check.
 
diff --git a/docs/CHANGES b/docs/CHANGES
index 0fe209f..f5be848 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -1,3 +1,13 @@
+CHANGES BETWEEN 2.3.0 and 2.3.1
+
+  I. IMPORTANT BUG FIXES
+
+    - The TrueType interpreter sometimes returned incorrect horizontal
+      metrics due to a bug in the handling of the SHZ instruction.
+
+
+======================================================================
+
 CHANGES BETWEEN 2.3.0 and 2.2.1
 
   I. IMPORTANT BUG FIXES
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 640001b..f6bcec1 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -2769,12 +2769,12 @@
     CUR.GS.single_width_cutin = (FT_F26Dot6)args[0];
 
 
-    /* XXX: UNDOCUMENTED! or bug in the Windows engine? */
-    /*                                                  */
-    /* It seems that the value that is read here is     */
-    /* expressed in 16.16 format rather than in font    */
-    /* units.                                           */
-    /*                                                  */
+    /* XXX: UNDOCUMENTED! or bug in the Windows engine?   */
+    /*                                                    */
+    /*      It seems that the value that is read here is  */
+    /*      expressed in 16.16 format rather than in font */
+    /*      units.                                        */
+    /*                                                    */
 #define DO_SSW                                                 \
     CUR.GS.single_width_value = (FT_F26Dot6)( args[0] >> 10 );
 
@@ -5430,7 +5430,7 @@
         last_point = 0;
     }
 
-    /* XXX: UNDOCUMENTED! SHC does touch the points */
+    /* XXX: UNDOCUMENTED! SHC touches the points */
     for ( i = first_point; i <= last_point; i++ )
     {
       if ( zp.cur != CUR.zp2.cur || refp != i )
@@ -5466,8 +5466,14 @@
     if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
       return;
 
-    if ( CUR.zp2.n_points > 0 )
-      last_point = (FT_UShort)(CUR.zp2.n_points - 1);
+    /* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points.  */
+    /*      Twilight zone has no contours, so use `n_points'.   */
+    /*      Normal zone's `n_points' includes phantoms, so must */
+    /*      use end of last contour.                            */
+    if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
+      last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
+    else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+      last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
     else
       last_point = 0;