[HarfBuzz] unbreaking mixed-up khmer fonts
Jonathan Kew
jfkthame at googlemail.com
Tue Nov 20 09:40:54 PST 2012
On 20/11/12 17:06, Behdad Esfahbod wrote:
> On 12-11-20 10:22 AM, Jonathan Kew wrote:
>>
>> I'm becoming increasingly convinced we need to bite the bullet and reintroduce
>> explicit Ra support for fonts that lack 'pref'. Sigh.
>
> Umm'k. Walking in this morning I was thinking that maybe checking for 'pref'
> would do it. But if not, then I'll bring back fallback 'pref'. May not get
> to it till the weekend though.
Yeah, I got to thinking the same thing, and so far it's looking
promising... instead of saying we *won't* use indic if there's liga,
let's say we'll *only* use indic if there's pref.
AFAICT, using the attached patch, all the fonts on my test page render
correctly (for the few sequences tested there, at least). I'll make a
test build of Firefox and we can ask people to try it on real sites and
let us know how it goes.
JK
-------------- next part --------------
From: Jonathan Kew <jkew at mozilla.com>
diff --git a/gfx/harfbuzz/src/hb-ot-shape-complex-private.hh b/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
@@ -279,26 +279,30 @@ hb_ot_shape_complex_categorize (const hb
/* 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] ||
- 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))
+ /* 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. */
+ 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 ('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
return &_hb_ot_complex_shaper_default;
More information about the HarfBuzz
mailing list