From ebfd7ce52f6b3c81d522b03f8faf029b7ffb7cbc Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 26 Feb 2016 08:10:41 +0100 Subject: [PATCH] [autofit] Improve BOUND action. In complex glyph shapes, the original logic was too simple to cater for situations that would actually need something similar to PS Hint masks. This fix should alleviate the worst cases. * src/autofit/aflatin.c (af_latin_hint_edges): Don't allow complete disappearance of stems. --- ChangeLog | 11 +++++++++++ src/autofit/aflatin.c | 45 +++++++++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c58dc1696..a8d1c649f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2016-02-26 Werner Lemberg + + [autofit] Improve BOUND action. + + In complex glyph shapes, the original logic was too simple to cater + for situations that would actually need something similar to PS Hint + masks. This fix should alleviate the worst cases. + + * src/autofit/aflatin.c (af_latin_hint_edges): Don't allow + complete disappearance of stems. + 2016-02-25 Werner Lemberg [autofit] Add blue-zone support for Tamil script. diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 8a45116b5..8da6ce1c6 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -2885,14 +2885,21 @@ ( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos ) : ( edge->pos < edge[-1].pos ) ) ) { + /* don't move if stem would (almost) disappear otherwise; */ + /* the ad-hoc value 16 corresponds to 1/4px */ + if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 ) + { #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n", - edge - edges, edge->pos / 64.0, edge[-1].pos / 64.0 )); + FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n", + edge - edges, + edge->pos / 64.0, + edge[-1].pos / 64.0 )); - num_actions++; + num_actions++; #endif - edge->pos = edge[-1].pos; + edge->pos = edge[-1].pos; + } } } } @@ -3048,13 +3055,20 @@ ( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos ) : ( edge->pos < edge[-1].pos ) ) ) { + /* don't move if stem would (almost) disappear otherwise; */ + /* the ad-hoc value 16 corresponds to 1/4px */ + if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 ) + { #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n", - edge - edges, edge->pos / 64.0, edge[-1].pos / 64.0 )); + FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n", + edge - edges, + edge->pos / 64.0, + edge[-1].pos / 64.0 )); - num_actions++; + num_actions++; #endif - edge->pos = edge[-1].pos; + edge->pos = edge[-1].pos; + } } if ( edge + 1 < edge_limit && @@ -3062,14 +3076,21 @@ ( top_to_bottom_hinting ? ( edge->pos < edge[1].pos ) : ( edge->pos > edge[1].pos ) ) ) { + /* don't move if stem would (almost) disappear otherwise; */ + /* the ad-hoc value 16 corresponds to 1/4px */ + if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 ) + { #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n", - edge - edges, edge->pos / 64.0, edge[1].pos / 64.0 )); + FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n", + edge - edges, + edge->pos / 64.0, + edge[1].pos / 64.0 )); - num_actions++; + num_actions++; #endif - edge->pos = edge[1].pos; + edge->pos = edge[1].pos; + } } } }