From ecdb0e35c323ece12a0882444891cfa80552af74 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 3 Jan 2014 20:49:31 +0100 Subject: [PATCH] [autofit] Thinko. * src/autofit/hbshim.c (af_get_char_index): Similar to `af_get_coverage', reject glyphs which are not substituted. --- ChangeLog | 7 +++++++ src/autofit/aflatin.c | 3 +++ src/autofit/hbshim.c | 22 +++++++++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 148e8d9f7..4a6829ab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-03 Werner Lemberg + + [autofit] Thinko. + + * src/autofit/hbshim.c (af_get_char_index): Similar to + `af_get_coverage', reject glyphs which are not substituted. + 2014-01-03 Werner Lemberg [autofit] Fix handling of default coverages. diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 8841d9482..4362bb7fe 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -89,6 +89,9 @@ [style_class->script]; + /* XXX: Extend this with a list of possible standard characters: */ + /* Especially in non-default coverages, a singe standard */ + /* character may not be available. */ af_get_char_index( &metrics->root, script_class->standard_char, &glyph_index, diff --git a/src/autofit/hbshim.c b/src/autofit/hbshim.c index 844c6bb2e..88c9e48e5 100644 --- a/src/autofit/hbshim.c +++ b/src/autofit/hbshim.c @@ -410,10 +410,14 @@ const hb_feature_t* feature; + FT_ULong in_idx, out_idx; + if ( !metrics ) return FT_THROW( Invalid_Argument ); + in_idx = FT_Get_Char_Index( metrics->globals->face, charcode ); + style_class = metrics->style_class; feature = features[style_class->coverage]; @@ -448,8 +452,20 @@ ginfo = hb_buffer_get_glyph_infos( buf, &gcount ); gpos = hb_buffer_get_glyph_positions( buf, &gcount ); - *codepoint = ginfo[0].codepoint; - *y_offset = gpos[0].y_offset; + out_idx = ginfo[0].codepoint; + + /* getting the same index indicates no substitution, */ + /* which means that the glyph isn't available in the feature */ + if ( in_idx == out_idx ) + { + *codepoint = 0; + *y_offset = 0; + } + else + { + *codepoint = out_idx; + *y_offset = gpos[0].y_offset; + } hb_buffer_destroy( buf ); @@ -461,7 +477,7 @@ } else { - *codepoint = FT_Get_Char_Index( metrics->globals->face, charcode ); + *codepoint = in_idx; *y_offset = 0; }