Commit f19e46f3bae4a8b652d39298cc9f42c9f27bdbeb

Ken Sharp 2010-01-27T10:04:50

Fix Savannah bug #28678. * src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c (cid_load_glyph): Handle vertical metrics correctly. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Handle vertical metrics correctly. (T1_Load_Glyph): Don't synthesize vertical metrics.

diff --git a/ChangeLog b/ChangeLog
index ae13bf6..0d80490 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-01-27  Ken Sharp  <ken.sharp@artifex.com>
+
+	Fix Savannah bug #28678.
+
+	* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
+	(cid_load_glyph): Handle vertical metrics correctly.
+
+	* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Handle
+	vertical metrics correctly.
+	(T1_Load_Glyph): Don't synthesize vertical metrics.
+
 2010-01-14  Werner Lemberg  <wl@gnu.org>
 
 	Make FT_Set_Transform work if no renderer is available.
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 64515b9..9643242 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -315,7 +315,7 @@ FT_BEGIN_HEADER
   /* contain no glyph data, but supply it via a callback function.         */
   /* This is required by clients supporting document formats which         */
   /* supply font data incrementally as the document is parsed, such        */
-  /* as the Ghostscript interpreter for the PostScript language.	   */
+  /* as the Ghostscript interpreter for the PostScript language.           */
   /*                                                                       */
 #define FT_CONFIG_OPTION_INCREMENTAL
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 8f64060..d598f84 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -4,7 +4,8 @@
 /*                                                                         */
 /*    OpenType Glyph Loader (body).                                        */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,   */
+/*            2010 by                                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -694,7 +695,7 @@
       data.length  = length;
 
       face->root.internal->incremental_interface->funcs->free_glyph_data(
-        face->root.internal->incremental_interface->object,&data );
+        face->root.internal->incremental_interface->object, &data );
     }
     else
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -2771,15 +2772,29 @@
 
 
       metrics.bearing_x = decoder.builder.left_bearing.x;
-      metrics.bearing_y = decoder.builder.left_bearing.y;
+      metrics.bearing_y = 0;
       metrics.advance   = decoder.builder.advance.x;
+
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
                 face->root.internal->incremental_interface->object,
                 glyph_index, FALSE, &metrics );
+
       decoder.builder.left_bearing.x = metrics.bearing_x;
-      decoder.builder.left_bearing.y = metrics.bearing_y;
       decoder.builder.advance.x      = metrics.advance;
-      decoder.builder.advance.y      = 0;
+
+      if ( !error )
+      {
+        metrics.bearing_x = 0;
+        metrics.bearing_y = decoder.builder.left_bearing.y;
+        metrics.advance   = decoder.builder.advance.y;
+
+        error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+                  face->root.internal->incremental_interface->object,
+                  glyph_index, TRUE, &metrics );
+
+        decoder.builder.left_bearing.y = metrics.bearing_y;
+        decoder.builder.advance.y      = metrics.advance;
+      }
     }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 2700a41..6c81721 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    CID-keyed Type1 Glyph Loader (body).                                 */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by       */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -173,16 +173,27 @@
 
 
       metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
-      metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y );
+      metrics.bearing_y = 0;
       metrics.advance   = FIXED_TO_INT( decoder->builder.advance.x );
 
       error = inc->funcs->get_glyph_metrics( inc->object,
                                              glyph_index, FALSE, &metrics );
 
       decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
-      decoder->builder.left_bearing.y = INT_TO_FIXED( metrics.bearing_y );
       decoder->builder.advance.x      = INT_TO_FIXED( metrics.advance );
-      decoder->builder.advance.y      = 0;
+
+      if ( !error )
+      {
+        metrics.bearing_x = 0;
+        metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y );
+        metrics.advance   = FIXED_TO_INT( decoder->builder.advance.y );
+
+        error = inc->funcs->get_glyph_metrics( inc->object,
+                                               glyph_index, TRUE, &metrics );
+
+        decoder->builder.left_bearing.y = INT_TO_FIXED( metrics.bearing_y );
+        decoder->builder.advance.y      = INT_TO_FIXED( metrics.advance );
+      }
     }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 481e5af..f23936f 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -103,16 +103,27 @@
 
 
       metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
-      metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y );
+      metrics.bearing_y = 0;
       metrics.advance   = FIXED_TO_INT( decoder->builder.advance.x );
 
       error = inc->funcs->get_glyph_metrics( inc->object,
                                              glyph_index, FALSE, &metrics );
 
       decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
-      decoder->builder.left_bearing.y = INT_TO_FIXED( metrics.bearing_y );
       decoder->builder.advance.x      = INT_TO_FIXED( metrics.advance );
-      decoder->builder.advance.y      = 0;
+
+      if ( !error )
+      {
+        metrics.bearing_x = 0;
+        metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y );
+        metrics.advance   = FIXED_TO_INT( decoder->builder.advance.y );
+
+        error = inc->funcs->get_glyph_metrics( inc->object,
+                                               glyph_index, TRUE, &metrics );
+
+        decoder->builder.left_bearing.y = INT_TO_FIXED( metrics.bearing_y );
+        decoder->builder.advance.y      = INT_TO_FIXED( metrics.advance );
+      }
     }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -401,10 +412,17 @@
           FIXED_TO_INT( decoder.builder.advance.x );
         glyph->root.internal->glyph_transformed = 0;
 
+#if 0
         /* make up vertical ones */
         metrics->vertAdvance = ( face->type1.font_bbox.yMax -
                                  face->type1.font_bbox.yMin ) >> 16;
         glyph->root.linearVertAdvance = metrics->vertAdvance;
+#else
+        metrics->vertAdvance =
+          FIXED_TO_INT( decoder.builder.advance.y );
+        glyph->root.linearVertAdvance =
+          FIXED_TO_INT( decoder.builder.advance.y );
+#endif
 
         glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;