From 7fc1cd6f001f02fcf6915a1fed2edc5ceb250603 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Wed, 21 Nov 2012 19:31:35 +0000 Subject: [PATCH] bug 799869 - [harfbuzz] improve heuristic for choosing between shapers for khmer fonts. r=behdad --- gfx/harfbuzz/src/hb-ot-shape-complex-private.hh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh b/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh index 75dcc04650d..1ed2df78c31 100644 --- a/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh +++ b/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh @@ -283,16 +283,22 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner) else return &_hb_ot_complex_shaper_default; + case HB_SCRIPT_KHMER: - /* If the font has 'liga', let the generic shaper do it. */ - if (!planner->map.found_script[0] || + /* A number of Khmer fonts in the wild don't have a 'pref' feature, + * and as such won't shape properly via the Indic shaper; + * however, they typically have 'liga' / 'clig' features that implement + * the necessary "reordering" by means of ligature substitutions. + * So we send such pref-less fonts through the generic shaper instead; + * use Indic only if the 'khmr' script has the 'pref' feature. */ + if (planner->map.found_script[0] && hb_ot_layout_language_find_feature (planner->face, HB_OT_TAG_GSUB, planner->map.script_index[0], planner->map.language_index[0], - HB_TAG ('l','i','g','a'), NULL)) - return &_hb_ot_complex_shaper_default; - else + HB_TAG ('p','r','e','f'), NULL)) return &_hb_ot_complex_shaper_indic; + else + return &_hb_ot_complex_shaper_default; case HB_SCRIPT_MYANMAR: