From 58f48f0ddcff3eec125e8a72bfc14e41c9da7c6f Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 16 Apr 2015 20:11:49 +0200 Subject: [PATCH] [autofit] Add debugging hook to disable warper. * src/autofit/afmodule.c (_af_debug_disable_warper) [FT_DEBUG_AUTOFIT]: New global variable. * src/autofit/aftypes.h: Updated. (AF_SCALER_FLAG_NO_WARPER): New macro (not actively used yet). * src/autofit/afhints.h (AF_HINTS_DO_WARP): New macro. * src/autofi/aflatin.c (af_latin_hints_apply) [AF_CONFIG_OPTION_USE_WARPER]: Use `AF_HINTS_DO_WARP' to control use of warper. * src/autofit/afcjk.c (af_cjk_hints_init, af_cjk_hints_apply) [AF_CONFIG_OPTION_USE_WARPER]: Synchronize with `aflatin.c'. * src/autofit/aflatin2.c (af_latin2_hints_apply) [AF_CONFIG_OPTION_USE_WARPER]: Synchronize with `aflatin.c'. --- ChangeLog | 22 ++++++++++++++++++++++ src/autofit/afcjk.c | 13 ++++++++++--- src/autofit/afhints.h | 7 +++++++ src/autofit/aflatin.c | 13 +++++++++---- src/autofit/aflatin2.c | 14 +++++++------- src/autofit/afmodule.c | 1 + src/autofit/aftypes.h | 2 ++ 7 files changed, 58 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad0c031e0..8c37e9bfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2015-04-16 Werner Lemberg + + [autofit] Add debugging hook to disable warper. + + * src/autofit/afmodule.c (_af_debug_disable_warper) + [FT_DEBUG_AUTOFIT]: New global variable. + + * src/autofit/aftypes.h: Updated. + (AF_SCALER_FLAG_NO_WARPER): New macro (not actively used yet). + + * src/autofit/afhints.h (AF_HINTS_DO_WARP): New macro. + + * src/autofi/aflatin.c (af_latin_hints_apply) + [AF_CONFIG_OPTION_USE_WARPER]: Use `AF_HINTS_DO_WARP' to control use + of warper. + + * src/autofit/afcjk.c (af_cjk_hints_init, af_cjk_hints_apply) + [AF_CONFIG_OPTION_USE_WARPER]: Synchronize with `aflatin.c'. + + * src/autofit/aflatin2.c (af_latin2_hints_apply) + [AF_CONFIG_OPTION_USE_WARPER]: Synchronize with `aflatin.c'. + 2015-04-10 Werner Lemberg [cff] Update advance width handling to OpenType 1.7. diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c index 4792c203d..31fe2cc9f 100644 --- a/src/autofit/afcjk.c +++ b/src/autofit/afcjk.c @@ -1301,7 +1301,7 @@ /* compute flags depending on render mode, etc. */ mode = metrics->root.scaler.render_mode; -#ifdef AF_CONFIG_OPTION_USE_WARPER +#if 0 /* AF_CONFIG_OPTION_USE_WARPER */ if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V ) metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL; #endif @@ -2190,7 +2190,13 @@ goto Exit; /* analyze glyph outline */ +#ifdef AF_CONFIG_OPTION_USE_WARPER + if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && + AF_HINTS_DO_WARP( hints ) ) || + AF_HINTS_DO_HORIZONTAL( hints ) ) +#else if ( AF_HINTS_DO_HORIZONTAL( hints ) ) +#endif { error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ ); if ( error ) @@ -2216,8 +2222,9 @@ { #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( dim == AF_DIMENSION_HORZ && - metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL ) + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && + AF_HINTS_DO_WARP( hints ) ) { AF_WarperRec warper; FT_Fixed scale; diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h index cfb107d01..3a6dc6c15 100644 --- a/src/autofit/afhints.h +++ b/src/autofit/afhints.h @@ -387,6 +387,10 @@ FT_BEGIN_HEADER #define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints ) +#define AF_HINTS_DO_WARP( h ) \ + ( !_af_debug_disable_warper && \ + !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER ) ) + #else /* !FT_DEBUG_AUTOFIT */ #define AF_HINTS_DO_HORIZONTAL( h ) \ @@ -400,6 +404,9 @@ FT_BEGIN_HEADER #define AF_HINTS_DO_BLUES( h ) 1 +#define AF_HINTS_DO_WARP( h ) \ + !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER ) + #endif /* !FT_DEBUG_AUTOFIT */ diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index a6e25414b..61d8724e9 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -1996,6 +1996,9 @@ /* * In `light' hinting mode we disable horizontal hinting completely. * We also do it if the face is italic. + * + * However, if warping is enabled (which only works in `light' hinting + * mode), advance widths get adjusted, too. */ if ( mode == FT_RENDER_MODE_LIGHT || ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) @@ -2812,8 +2815,9 @@ /* analyze glyph outline */ #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT || - AF_HINTS_DO_HORIZONTAL( hints ) ) + if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && + AF_HINTS_DO_WARP( hints ) ) || + AF_HINTS_DO_HORIZONTAL( hints ) ) #else if ( AF_HINTS_DO_HORIZONTAL( hints ) ) #endif @@ -2845,7 +2849,8 @@ { #ifdef AF_CONFIG_OPTION_USE_WARPER if ( dim == AF_DIMENSION_HORZ && - metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ) + metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && + AF_HINTS_DO_WARP( hints ) ) { AF_WarperRec warper; FT_Fixed scale; @@ -2858,7 +2863,7 @@ scale, delta ); continue; } -#endif +#endif /* AF_CONFIG_OPTION_USE_WARPER */ if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) || ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) ) diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c index 3e9360d2b..d23c65a73 100644 --- a/src/autofit/aflatin2.c +++ b/src/autofit/aflatin2.c @@ -1513,9 +1513,7 @@ #if 0 /* #ifdef AF_CONFIG_OPTION_USE_WARPER */ if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V ) - { metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL; - } #endif scaler_flags = hints->scaler_flags; @@ -2310,8 +2308,9 @@ /* analyze glyph outline */ #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT || - AF_HINTS_DO_HORIZONTAL( hints ) ) + if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && + AF_HINTS_DO_WARP( hints ) ) || + AF_HINTS_DO_HORIZONTAL( hints ) ) #else if ( AF_HINTS_DO_HORIZONTAL( hints ) ) #endif @@ -2334,8 +2333,9 @@ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) { #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( ( dim == AF_DIMENSION_HORZ && - metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ) ) + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && + AF_HINTS_DO_WARP( hints ) ) { AF_WarperRec warper; FT_Fixed scale; @@ -2346,7 +2346,7 @@ af_glyph_hints_scale_dim( hints, dim, scale, delta ); continue; } -#endif +#endif /* AF_CONFIG_OPTION_USE_WARPER */ if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) || ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) ) diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c index 5b82f662d..06b05ce1f 100644 --- a/src/autofit/afmodule.c +++ b/src/autofit/afmodule.c @@ -26,6 +26,7 @@ int _af_debug_disable_horz_hints; int _af_debug_disable_vert_hints; int _af_debug_disable_blue_hints; + int _af_debug_disable_warper; /* we use a global object instead of a local one for debugging */ AF_GlyphHintsRec _af_debug_hints_rec[1]; diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h index e105dc83d..0a4086076 100644 --- a/src/autofit/aftypes.h +++ b/src/autofit/aftypes.h @@ -59,6 +59,7 @@ FT_BEGIN_HEADER extern int _af_debug_disable_horz_hints; extern int _af_debug_disable_vert_hints; extern int _af_debug_disable_blue_hints; +extern int _af_debug_disable_warper; extern void* _af_debug_hints; #endif /* FT_DEBUG_AUTOFIT */ @@ -170,6 +171,7 @@ extern void* _af_debug_hints; #define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */ #define AF_SCALER_FLAG_NO_VERTICAL 2U /* disable vertical hinting */ #define AF_SCALER_FLAG_NO_ADVANCE 4U /* disable advance hinting */ +#define AF_SCALER_FLAG_NO_WARPER 8U /* disable warper */ typedef struct AF_ScalerRec_