From 98d185c79428feb25c57fd187cd4f8d0e464527e Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 7 Dec 2013 09:26:55 +0100 Subject: [PATCH] [truetype] Next round in phantom point handling. Greg Hitchcock provided very interesting insights into the complicated history of the horizontal positions of the TSB and BSB phantom points. * src/truetype/ttgload.c (TT_LOADER_SET_PP) [TT_CONFIG_OPTION_SUBPIXEL_HINTING]: Use `subpixel_hinting' and `grayscale_hinting' flags as conditionals for the x position of TSB and BSB. --- ChangeLog | 13 +++++++++++++ src/truetype/ttgload.c | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4390639e1..df8f9cefd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2013-12-07 Werner Lemberg + + [truetype] Next round in phantom point handling. + + Greg Hitchcock provided very interesting insights into the + complicated history of the horizontal positions of the TSB and BSB + phantom points. + + * src/truetype/ttgload.c (TT_LOADER_SET_PP) + [TT_CONFIG_OPTION_SUBPIXEL_HINTING]: Use `subpixel_hinting' and + `grayscale_hinting' flags as conditionals for the x position of TSB + and BSB. + 2013-12-05 Werner Lemberg * builds/freetype.mk (FT_CC): Removed. Unused. diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 2c2bea5a4..0d74248b8 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -1329,14 +1329,30 @@ * * Usually we have * - * x = aw / 2 , + * x = aw / 2 , (1) * - * but there is a compatibility case where it can be set to + * but there is one compatibility case where it can be set to * * x = -DefaultDescender - - * ((DefaultAscender - DefaultDescender - aw) / 2) . + * ((DefaultAscender - DefaultDescender - aw) / 2) . (2) * - * For (old) non-ClearType hinting, `x' is set to zero. + * and another one with + * + * x = 0 . (3) + * + * In Windows, the history of those values is quite complicated, + * depending on the hinting engine (that is, the graphics framework). + * + * framework from to formula + * ---------------------------------------------------------- + * GDI Windows 98 current (1) + * (Windows 2000 for NT) + * GDI+ Windows XP Windows 7 (2) + * GDI+ Windows 8 current (3) + * DWrite Windows 7 current (3) + * + * For simplicity, FreeType uses (1) for grayscale subpixel hinting and + * (3) for everything else. * */ #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING @@ -1344,20 +1360,22 @@ #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 ); \ + FT_Bool subpixel_ = loader->exec \ + ? loader->exec->subpixel_hinting \ + : 0; \ + FT_Bool grayscale_ = loader->exec \ + ? loader->exec->grayscale_hinting \ + : 0; \ + FT_Bool use_aw_2_ = (FT_Bool)( subpixel_ && grayscale_ ); \ \ \ (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.x = use_aw_2_ ? (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.x = use_aw_2_ ? (loader)->advance / 2 : 0; \ (loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \ } while ( 0 )