Commit 10cf38879521b7f16e7f0bc83183f32858de05a1

Chris Liddell 2010-02-18T17:09:30

Fix Savannah bug #28905. Initialize phantom points before calling the incremental interface to update glyph metrics. * src/truetype/ttgload.c (tt_get_metrics_incr_overrides) [FT_CONFIG_OPTION_INCREMENTAL]: New function, split off from... (tt_get_metrics): This. Updated. (load_truetype_glyph): Use tt_get_metrics_incr_overrides.

diff --git a/ChangeLog b/ChangeLog
index 83a7d53..bc81577 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-02-18  Chris Liddell  <chris.liddell@artifex.com>
+
+	Fix Savannah bug #28905.
+
+	Initialize phantom points before calling the incremental interface
+	to update glyph metrics.
+
+	* src/truetype/ttgload.c (tt_get_metrics_incr_overrides)
+	[FT_CONFIG_OPTION_INCREMENTAL]: New function, split off from...
+	(tt_get_metrics): This.
+	Updated.
+	(load_truetype_glyph): Use tt_get_metrics_incr_overrides.
+
 2010-02-13  Werner Lemberg  <wl@gnu.org>
 
 	* Version 2.3.12 released.
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 57ea0ba..2f03600 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -161,8 +161,31 @@
                      &top_bearing,
                      &advance_height );
 
+    loader->left_bearing = left_bearing;
+    loader->advance      = advance_width;
+    loader->top_bearing  = top_bearing;
+    loader->vadvance     = advance_height;
+
+    if ( !loader->linear_def )
+    {
+      loader->linear_def = 1;
+      loader->linear     = advance_width;
+    }
+  }
+
+
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
 
+  static void
+  tt_get_metrics_incr_overrides( TT_Loader  loader,
+                                 FT_UInt    glyph_index )
+  {
+    TT_Face  face = (TT_Face)loader->face;
+
+    FT_Short   left_bearing = 0, top_bearing = 0;
+    FT_UShort  advance_width = 0, advance_height = 0;
+
+
     /* If this is an incrementally loaded font check whether there are */
     /* overriding metrics for this glyph.                              */
     if ( face->root.internal->incremental_interface                           &&
@@ -172,9 +195,9 @@
       FT_Error                   error;
 
 
-      metrics.bearing_x = left_bearing;
+      metrics.bearing_x = loader->left_bearing;
       metrics.bearing_y = 0;
-      metrics.advance   = advance_width;
+      metrics.advance   = loader->advance;
       metrics.advance_v = 0;
 
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
@@ -190,8 +213,8 @@
 
       /* GWW: Do I do the same for vertical metrics? */
       metrics.bearing_x = 0;
-      metrics.bearing_y = top_bearing;
-      metrics.advance   = advance_height;
+      metrics.bearing_y = loader->top_bearing;
+      metrics.advance   = loader->vadvance;
 
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
                 face->root.internal->incremental_interface->object,
@@ -204,24 +227,24 @@
 
 #endif /* 0 */
 
+      loader->left_bearing = left_bearing;
+      loader->advance      = advance_width;
+      loader->top_bearing  = top_bearing;
+      loader->vadvance     = advance_height;
+
+      if ( !loader->linear_def )
+      {
+        loader->linear_def = 1;
+        loader->linear     = advance_width;
+      }
     }
 
   Exit:
+    return;
+  }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
 
-    loader->left_bearing = left_bearing;
-    loader->advance      = advance_width;
-    loader->top_bearing  = top_bearing;
-    loader->vadvance     = advance_height;
-
-    if ( !loader->linear_def )
-    {
-      loader->linear_def = 1;
-      loader->linear     = advance_width;
-    }
-  }
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -1316,8 +1339,14 @@
       if ( header_only )
         goto Exit;
 
+      /* must initialize points before (possibly) overriding */
+      /* glyph metrics from the incremental interface        */
       TT_LOADER_SET_PP( loader );
 
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+      tt_get_metrics_incr_overrides( loader, glyph_index );
+#endif
+
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 
       if ( ((TT_Face)(loader->face))->doblend )
@@ -1353,8 +1382,14 @@
       goto Exit;
     }
 
+    /* must initialize points before (possibly) overriding */
+    /* glyph metrics from the incremental interface        */
     TT_LOADER_SET_PP( loader );
 
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+    tt_get_metrics_incr_overrides( loader, glyph_index );
+#endif
+
     /***********************************************************************/
     /***********************************************************************/
     /***********************************************************************/