From 04dc52fa15f5b7f9eb5f448ea43e7ef1b2269e88 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 6 Jun 2014 17:28:38 -0400 Subject: [PATCH] [indic] Recover OT_H undergone ligation and multiplication Sometimes font designers form half/pref/etc consonant forms unconditionally and then undo that conditionally. Try to recover the OT_H classification in those cases. No test number changes expected. --- src/hb-ot-layout-private.hh | 8 ++++++++ src/hb-ot-shape-complex-indic.cc | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 3ded92fec..e66e19c44 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -395,6 +395,14 @@ _hb_glyph_info_ligated_and_didnt_multiply (const hb_glyph_info_t *info) return _hb_glyph_info_ligated (info) && !_hb_glyph_info_multiplied (info); } +static inline void +_hb_glyph_info_clear_ligated_and_multiplied (hb_glyph_info_t *info) +{ + info->glyph_props() &= ~(HB_OT_LAYOUT_GLYPH_PROPS_LIGATED | + HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED); +} + + /* Allocation / deallocation. */ static inline void diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 81f4c6195..62f117273 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1336,6 +1336,27 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan, const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data; hb_glyph_info_t *info = buffer->info; + + /* This function relies heavily on halant glyphs. Lots of ligation + * and possibly multiplication substitutions happened prior to this + * phase, and that might have messed up our properties. Recover + * from a particular case of that where we're fairly sure that a + * class of OT_H is desired but has been lost. */ + if (indic_plan->virama_glyph) + { + unsigned int virama_glyph = indic_plan->virama_glyph; + for (unsigned int i = start; i < end; i++) + if (info[i].codepoint == virama_glyph && + _hb_glyph_info_ligated (&info[i]) && + _hb_glyph_info_multiplied (&info[i])) + { + /* This will make sure that this glyph passes is_halant_or_coeng() test. */ + info[i].indic_category() = OT_H; + _hb_glyph_info_clear_ligated_and_multiplied (&info[i]); + } + } + + /* 4. Final reordering: * * After the localized forms and basic shaping forms GSUB features have been