Commit ffa496574ae715630a466a810986e212d2de59e0

Werner Lemberg 2008-05-25T12:43:57

* src/truetype/ttgload.c (load_truetype_glyph): Move initialization of the graphics state for subglyphs to... (TT_Hint_Glyph): This function. Hinting instructions for a composite glyph apparently refer to the just hinted subglyphs, not the unhinted, unscaled outline. This seems to fix Savannah bugs #20973 and (at least partially) #23310.

diff --git a/ChangeLog b/ChangeLog
index 056d205..a3460e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,13 @@
 	* src/raster/ftraster.c (fc_black_render): Return 0 when we are
 	trying to render into a zero-width/height bitmap, not an error code.
 
+	* src/truetype/ttgload.c (load_truetype_glyph): Move initialization
+	of the graphics state for subglyphs to...
+	(TT_Hint_Glyph): This function.
+	Hinting instructions for a composite glyph apparently refer to the
+	just hinted subglyphs, not the unhinted, unscaled outline.  This
+	seems to fix Savannah bugs #20973 and (at least partially) #23310.
+
 2008-05-20  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	* src/base/ftmac.c (FT_New_Face_From_Suitcase): Check if valid
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 8f1c61b..6e826f0 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -643,6 +643,24 @@
     /* save original point position in org */
     if ( n_ins > 0 )
       FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
+
+    /* Reset graphics state. */
+    loader->exec->GS = ((TT_Size)loader->size)->GS;
+
+    /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
+    /*      completely refer to the (already) hinted subglyphs.     */
+    if ( is_composite )
+    {
+      loader->exec->metrics.x_scale = 1 << 16;
+      loader->exec->metrics.y_scale = 1 << 16;
+
+      FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
+    }
+    else
+    {
+      loader->exec->metrics.x_scale = loader->size->metrics.x_scale;
+      loader->exec->metrics.y_scale = loader->size->metrics.y_scale;
+    }
 #endif
 
     /* round pp2 and pp4 */
@@ -1407,13 +1425,6 @@
 
         FT_Stream         old_stream     = loader->stream;
 
-#ifdef TT_USE_BYTECODE_INTERPRETER
-        TT_GraphicsState  saved_GS;
-
-
-        if ( loader->exec )
-          saved_GS = loader->exec->GS;
-#endif
 
         FT_GlyphLoader_Add( gloader );
 
@@ -1423,12 +1434,6 @@
           FT_Vector  pp[4];
 
 
-#ifdef TT_USE_BYTECODE_INTERPRETER
-          /* reinitialize graphics state */
-          if ( loader->exec )
-            loader->exec->GS = saved_GS;
-#endif
-
           /* Each time we call load_truetype_glyph in this loop, the   */
           /* value of `gloader.base.subglyphs' can change due to table */
           /* reallocations.  We thus need to recompute the subglyph    */