bug 799869 - [harfbuzz] improve heuristic for choosing between shapers for khmer fonts. r=behdad
authorJonathan Kew <jkew@mozilla.com>
Wed, 21 Nov 2012 19:31:35 +0000
changeset 113920 31a649d3f7314be4b569d559e8f36efc650cdb78
parent 113919 216a514344ea05e13053d55295b5e1d77095952b
child 113921 69f0f4812e2cf5dc0c0e707b5f4ef5ed8c3af99b
push id18455
push userjkew@mozilla.com
push dateWed, 21 Nov 2012 19:33:09 +0000
treeherdermozilla-inbound@31a649d3f731 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbehdad
bugs799869
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 799869 - [harfbuzz] improve heuristic for choosing between shapers for khmer fonts. r=behdad
gfx/harfbuzz/src/hb-ot-shape-complex-private.hh
--- a/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh
+++ b/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh
@@ -278,26 +278,32 @@ hb_ot_shape_complex_categorize (const hb
     case HB_SCRIPT_TAKRI:
 
       /* Only use Indic shaper if the font has Indic tables. */
       if (planner->map.found_script[0])
 	return &_hb_ot_complex_shaper_indic;
       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))
+					      HB_TAG ('p','r','e','f'), NULL))
+	return &_hb_ot_complex_shaper_indic;
+      else
 	return &_hb_ot_complex_shaper_default;
-      else
-	return &_hb_ot_complex_shaper_indic;
 
 
     case HB_SCRIPT_MYANMAR:
       /* For Myanmar, we only want to use the Indic shaper if the "new" script
        * tag is found.  For "old" script tag we want to use the default shaper. */
       if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2'))
 	return &_hb_ot_complex_shaper_indic;
       else