[truetype] Fix phantom point handling.

This is a further improvement to the changes from 2013-11-06.

* src/truetype/ttgload.c (TT_Hint_Glyph): Horizontal phantom points
are rounded horizontally, vertical ones are rounded vertically.
(TT_LOADER_SET_PP): The horizontal position of vertical phantom
points in pre-ClearType mode is zero, as shown in the OpenType
specification.
This commit is contained in:
Werner Lemberg 2013-12-03 06:57:02 +01:00
parent a44b784bca
commit bdd5e75e4e
2 changed files with 54 additions and 7 deletions

View File

@ -1,3 +1,15 @@
2013-12-03 Werner Lemberg <wl@gnu.org>
[truetype] Fix phantom point handling.
This is a further improvement to the changes from 2013-11-06.
* src/truetype/ttgload.c (TT_Hint_Glyph): Horizontal phantom points
are rounded horizontally, vertical ones are rounded vertically.
(TT_LOADER_SET_PP): The horizontal position of vertical phantom
points in pre-ClearType mode is zero, as shown in the OpenType
specification.
2013-12-02 Werner Lemberg <wl@gnu.org>
[truetype] Fix change from 2013-11-20.

View File

@ -788,9 +788,13 @@
}
#endif
/* round pp2 and pp4 */
/* round phantom points */
zone->cur[zone->n_points - 4].x =
FT_PIX_ROUND( zone->cur[zone->n_points - 4].x );
zone->cur[zone->n_points - 3].x =
FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
zone->cur[zone->n_points - 2].y =
FT_PIX_ROUND( zone->cur[zone->n_points - 2].y );
zone->cur[zone->n_points - 1].y =
FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
@ -1282,8 +1286,11 @@
* specification defines the initial position of horizontal phantom points
* as
*
* pp1 = (xmin - lsb, 0) ,
* pp2 = (pp1 + aw, 0) .
* pp1 = (round(xmin - lsb), 0) ,
* pp2 = (round(pp1 + aw), 0) .
*
* Note that the rounding to the grid is not documented currently in the
* specification.
*
* However, the specification lacks the precise definition of vertical
* phantom points. Greg Hitchcock provided the following explanation.
@ -1299,8 +1306,8 @@
*
* and the initial position of vertical phantom points is
*
* pp3 = (x, ymax + tsb) ,
* pp4 = (x, pp3 - ah) .
* pp3 = (x, round(ymax + tsb)) ,
* pp4 = (x, round(pp3 - ah)) .
*
* See below for value `x'.
*
@ -1332,7 +1339,33 @@
* x = -DefaultDescender -
* ((DefaultAscender - DefaultDescender - aw) / 2) .
*
* For (old) non-ClearType hinting, `x' is set to zero.
*
*/
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
#define TT_LOADER_SET_PP( loader ) \
do \
{ \
TT_Face face_ = (TT_Face)(loader)->face; \
TT_Driver driver_ = (TT_Driver)FT_FACE_DRIVER( face_ ); \
FT_Bool is_ver_38_ = (FT_Bool) \
( driver_->interpreter_version == \
TT_INTERPRETER_VERSION_38 ); \
\
\
(loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
(loader)->pp1.y = 0; \
(loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
(loader)->pp2.y = 0; \
(loader)->pp3.x = is_ver_38_ ? (loader)->advance / 2 : 0; \
(loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
(loader)->pp4.x = is_ver_38_ ? (loader)->advance / 2 : 0; \
(loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
} while ( 0 )
#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#define TT_LOADER_SET_PP( loader ) \
do \
{ \
@ -1340,12 +1373,14 @@
(loader)->pp1.y = 0; \
(loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
(loader)->pp2.y = 0; \
(loader)->pp3.x = (loader)->advance / 2; \
(loader)->pp3.x = 0; \
(loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
(loader)->pp4.x = (loader)->advance / 2; \
(loader)->pp4.x = 0; \
(loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
} while ( 0 )
#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/*************************************************************************/
/* */