Commit 5e225b7c15e6c6ff8b4b7059597319b26271bc67

Werner Lemberg 2013-11-06T08:41:59

[truetype] Fix handling of phantom points in composite glyphs. Problem reported by Nigel Tao <nigeltao@golang.org>. This is a follow-up commit to the previous one. * src/truetype/ttgload.c (load_truetype_glyph): Call `tt_get_metrics' after loading the glyph header.

diff --git a/ChangeLog b/ChangeLog
index 115333d..8b9d276 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2013-11-06  Werner Lemberg  <wl@gnu.org>
 
+	[truetype] Fix handling of phantom points in composite glyphs.
+	Problem reported by Nigel Tao <nigeltao@golang.org>.
+
+	This is a follow-up commit to the previous one.
+
+	* src/truetype/ttgload.c (load_truetype_glyph): Call
+	`tt_get_metrics' after loading the glyph header.
+
+2013-11-06  Werner Lemberg  <wl@gnu.org>
+
 	[truetype] Improve emulation of vertical metrics.
 
 	This commit also improves the start values of vertical phantom
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 0c3c7bd..5497562 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1387,8 +1387,6 @@
       y_scale = 0x10000L;
     }
 
-    tt_get_metrics( loader, glyph_index );
-
     /* Set `offset' to the start of the glyph relative to the start of */
     /* the `glyf' table, and `byte_len' to the length of the glyph in  */
     /* bytes.                                                          */
@@ -1448,7 +1446,15 @@
 
       /* read glyph header first */
       error = face->read_glyph_header( loader );
-      if ( error || header_only )
+      if ( error )
+        goto Exit;
+
+      /* the metrics must be computed after loading the glyph header */
+      /* since we need the glyph's `yMax' value in case the vertical */
+      /* metrics must be emulated                                    */
+      tt_get_metrics( loader, glyph_index );
+
+      if ( header_only )
         goto Exit;
     }
 
@@ -1459,6 +1465,8 @@
       loader->bbox.yMin = 0;
       loader->bbox.yMax = 0;
 
+      tt_get_metrics( loader, glyph_index );
+
       if ( header_only )
         goto Exit;