shithub: freetype+ttf2subf

Download patch

ref: 980b76ea5e189f42259d559df19024cd4fe22aca
parent: db9a41e81baafe5e87cfe73e9bdb247a7e27638b
author: Ken Sharp <[email protected]>
date: Wed Feb 10 02:02:43 EST 2010

Really fix Savannah bug #28678 (part 1).

After long discussion, we now consider the character width vector
(wx,wy) returned by the `sbw' Type 1 operator as being part of *one*
direction only.  For example, if you are using the horizontal
writing direction, you get the horizontal and vertical components of
the advance width for this direction.  Note that OpenType and CFF fonts
don't have such a vertical component; instead, the GPOS table can be
used to generate two-dimensional advance widths (but this isn't
handled by FreeType).

* include/freetype/ftincrem.h (FT_Incremental_MetricsRec): Add
`advance_v' field to hold the vertical component of the advance
value.

* src/truetype/ttgload.c (tt_get_metrics), src/cff/cffgload.c
(cff_slot_load), src/type1/t1gload.c
(T1_Parse_Glyph_And_Get_Char_String), src/cid/cidgload.c
(cid_load_glyph): Use it.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-27  Ken Sharp  <[email protected]>
+
+	Really fix Savannah bug #28678 (part 1).
+
+	After long discussion, we now consider the character width vector
+	(wx,wy) returned by the `sbw' Type 1 operator as being part of *one*
+	direction only.  For example, if you are using the horizontal
+	writing direction, you get the horizontal and vertical components of
+	the advance width for this direction.  Note that OpenType and CFF fonts
+	don't have such a vertical component; instead, the GPOS table can be
+	used to generate two-dimensional advance widths (but this isn't
+	handled by FreeType).
+
+	* include/freetype/ftincrem.h (FT_Incremental_MetricsRec): Add
+	`advance_v' field to hold the vertical component of the advance
+	value.
+
+	* src/truetype/ttgload.c (tt_get_metrics), src/cff/cffgload.c
+	(cff_slot_load), src/type1/t1gload.c
+	(T1_Parse_Glyph_And_Get_Char_String), src/cid/cidgload.c
+	(cid_load_glyph): Use it.
+
 2010-02-08  Werner Lemberg  <[email protected]>
 
 	* devel/ftoption.h [FT_CONFIG_OPTION_PIC]: Define.
--- a/include/freetype/ftincrem.h
+++ b/include/freetype/ftincrem.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType incremental loading (specification).                        */
 /*                                                                         */
-/*  Copyright 2002, 2003, 2006, 2007, 2008 by                              */
+/*  Copyright 2002, 2003, 2006, 2007, 2008, 2010 by                        */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -101,8 +101,11 @@
    *     Top bearing, in font units.
    *
    *   advance ::
-   *     Glyph advance, in font units.
+   *     Horizontal component of glyph advance, in font units.
    *
+   *   advance_v ::
+   *     Vertical component of glyph advance, in font units.
+   *
    * @note:
    *   These correspond to horizontal or vertical metrics depending on the
    *   value of the `vertical' argument to the function
@@ -114,6 +117,7 @@
     FT_Long  bearing_x;
     FT_Long  bearing_y;
     FT_Long  advance;
+    FT_Long  advance_v;
 
   } FT_Incremental_MetricsRec;
 
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2764,8 +2764,8 @@
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
 
     /* Incremental fonts can optionally override the metrics. */
-    if ( !error                                                              &&
-         face->root.internal->incremental_interface                          &&
+    if ( !error                                                               &&
+         face->root.internal->incremental_interface                           &&
          face->root.internal->incremental_interface->funcs->get_glyph_metrics )
     {
       FT_Incremental_MetricsRec  metrics;
@@ -2774,6 +2774,7 @@
       metrics.bearing_x = decoder.builder.left_bearing.x;
       metrics.bearing_y = 0;
       metrics.advance   = decoder.builder.advance.x;
+      metrics.advance_v = decoder.builder.advance.y;
 
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
                 face->root.internal->incremental_interface->object,
@@ -2781,20 +2782,7 @@
 
       decoder.builder.left_bearing.x = metrics.bearing_x;
       decoder.builder.advance.x      = metrics.advance;
-
-      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;
-      }
+      decoder.builder.advance.y      = metrics.advance_v;
     }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -175,6 +175,7 @@
       metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
       metrics.bearing_y = 0;
       metrics.advance   = FIXED_TO_INT( decoder->builder.advance.x );
+      metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y );
 
       error = inc->funcs->get_glyph_metrics( inc->object,
                                              glyph_index, FALSE, &metrics );
@@ -181,19 +182,7 @@
 
       decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
       decoder->builder.advance.x      = INT_TO_FIXED( metrics.advance );
-
-      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 );
-      }
+      decoder->builder.advance.y      = INT_TO_FIXED( metrics.advance_v );
     }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -163,9 +163,9 @@
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
 
-    /* If this is an incrementally loaded font see if there are */
-    /* overriding metrics for this glyph.                       */
-    if ( face->root.internal->incremental_interface &&
+    /* If this is an incrementally loaded font check whether there are */
+    /* overriding metrics for this glyph.                              */
+    if ( face->root.internal->incremental_interface                           &&
          face->root.internal->incremental_interface->funcs->get_glyph_metrics )
     {
       FT_Incremental_MetricsRec  metrics;
@@ -175,6 +175,7 @@
       metrics.bearing_x = left_bearing;
       metrics.bearing_y = 0;
       metrics.advance   = advance_width;
+      metrics.advance_v = 0;
 
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
                 face->root.internal->incremental_interface->object,
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -105,6 +105,7 @@
       metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
       metrics.bearing_y = 0;
       metrics.advance   = FIXED_TO_INT( decoder->builder.advance.x );
+      metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y );
 
       error = inc->funcs->get_glyph_metrics( inc->object,
                                              glyph_index, FALSE, &metrics );
@@ -111,19 +112,7 @@
 
       decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
       decoder->builder.advance.x      = INT_TO_FIXED( metrics.advance );
-
-      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 );
-      }
+      decoder->builder.advance.y      = INT_TO_FIXED( metrics.advance_v );
     }
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */