Commit 03987bfdbf43a86c59702fdafe98c95cce1b208a

Werner Lemberg 2014-10-16T07:19:46

A better fix for Savannah bug #43392. Suggested by Doug Felt <dougfelt@gmail.com>. * src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics): Set `vertAdvance' to zero... * src/truetype/ttgload.c (TT_Load_Glyph): ... and set here a default value for `vertAdvance' based on `linearVertAdvance' in case `vertAdvance' is zero. Note that the previous computed ad-hoc value for `linearVertAdvance' was apparently not tested in a real-life situation.

diff --git a/ChangeLog b/ChangeLog
index a71b8f0..b94ec5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,20 @@
 	out of range.
 	(Ins_DELTAP, Ins_DELTAC): Optimize for legal delta_shift.
 
+2014-10-16  Werner Lemberg  <wl@gnu.org>
+
+	A better fix for Savannah bug #43392.
+	Suggested by Doug Felt <dougfelt@gmail.com>.
+
+	* src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics): Set 
+	`vertAdvance' to zero...
+
+	* src/truetype/ttgload.c (TT_Load_Glyph): ... and set here a default
+	value for `vertAdvance' based on `linearVertAdvance' in case
+	`vertAdvance' is zero.  Note that the previous computed ad-hoc value
+	for `linearVertAdvance' was apparently not tested in a real-life
+	situation.
+
 2014-10-14  David Weiß  <David.Weiss@ptvgroup.com>
 
 	[build] Better optimization settings for vc2010 solution file.
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 8899a03..7450b4b 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -510,7 +510,7 @@
       /* avoid uninitialized data in case there is no vertical info -- */
       metrics->vertBearingX = 0;
       metrics->vertBearingY = 0;
-      metrics->vertAdvance  = metrics->width;
+      metrics->vertAdvance  = 0;
     }
 
     decoder->metrics_loaded = 1;
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index ff2b339..2ab6f76 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -2373,15 +2373,18 @@
           (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
           (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
           glyph->linearHoriAdvance = loader.linear;
-          glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
-                                       loader.vadvance;
+          glyph->linearVertAdvance = loader.vadvance;
 
-          /* sanity check: if `horiAdvance' in the sbit metric */
-          /* structure isn't set, use `linearHoriAdvance'      */
+          /* sanity checks: if `xxxAdvance' in the sbit metric */
+          /* structure isn't set, use `linearXXXAdvance'      */
           if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
             glyph->metrics.horiAdvance =
               FT_MulFix( glyph->linearHoriAdvance,
                          size->root.metrics.x_scale );
+          if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
+            glyph->metrics.vertAdvance =
+              FT_MulFix( glyph->linearVertAdvance,
+                         size->root.metrics.y_scale );
         }
 
         return FT_Err_Ok;