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.
This commit is contained in:
Ken Sharp 2010-02-10 07:02:43 +01:00 committed by Werner Lemberg
parent db9a41e81b
commit 980b76ea5e
6 changed files with 40 additions and 47 deletions

View File

@ -1,3 +1,25 @@
2010-01-27 Ken Sharp <ken.sharp@artifex.com>
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 <wl@gnu.org>
* devel/ftoption.h [FT_CONFIG_OPTION_PIC]: Define.

View File

@ -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,7 +101,10 @@ FT_BEGIN_HEADER
* 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
@ -114,6 +117,7 @@ FT_BEGIN_HEADER
FT_Long bearing_x;
FT_Long bearing_y;
FT_Long advance;
FT_Long advance_v;
} FT_Incremental_MetricsRec;

View File

@ -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 */

View File

@ -175,25 +175,14 @@
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 );
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 */

View File

@ -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,

View File

@ -105,25 +105,14 @@
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 );
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 */