From 771a8f50289e8fa458cfc3cd84f73a380ce98077 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 23 Jul 2012 20:07:50 -0400 Subject: [PATCH] [Indic] exclude ligatures when matching on Indic category If, say, a H,ZWJ,C ligature was formed, we don't want the code to detec that as a Halant. So, ignore ligatures when matching category in final_reordering. Sinhala failures down from 514 to 455 (0.167374%). --- src/hb-ot-shape-complex-indic.cc | 41 ++++++++++--------- .../indic/script-sinhala/misc/misc.txt | 1 + 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 6b1e2fac..7af72236 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -26,6 +26,7 @@ #include "hb-ot-shape-complex-indic-private.hh" #include "hb-ot-shape-private.hh" +#include "hb-ot-layout-gsubgpos-private.hh" #define OLD_INDIC_TAG(script) (((hb_tag_t) script) | 0x20000000) #define IS_OLD_INDIC_TAG(tag) ( \ @@ -187,7 +188,7 @@ matra_position (hb_codepoint_t u, indic_position_t side) abort (); } -static bool +static inline bool is_ra (hb_codepoint_t u) { return !!bsearch (&u, ra_chars, @@ -196,36 +197,38 @@ is_ra (hb_codepoint_t u) compare_codepoint); } +static inline bool +is_one_of (const hb_glyph_info_t &info, unsigned int flags) +{ + /* If it ligated, all bets are off. */ + if (unlikely (get_lig_id (info))) return false; + return !!(FLAG (info.indic_category()) & flags); +} + #define JOINER_FLAGS (FLAG (OT_ZWJ) | FLAG (OT_ZWNJ)) -static bool +static inline bool is_joiner (const hb_glyph_info_t &info) { - return !!(FLAG (info.indic_category()) & JOINER_FLAGS); + return is_one_of (info, JOINER_FLAGS); } +/* Note: + * + * We treat Vowels and placeholders as if they were consonants. This is safe because Vowels + * cannot happen in a consonant syllable. The plus side however is, we can call the + * consonant syllable logic from the vowel syllable function and get it all right! */ #define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_Ra) | FLAG (OT_V) | FLAG (OT_NBSP) | FLAG (OT_DOTTEDCIRCLE)) -static bool +static inline bool is_consonant (const hb_glyph_info_t &info) { - /* Note: - * - * We treat Vowels and placeholders as if they were consonants. This is safe because Vowels - * cannot happen in a consonant syllable. The plus side however is, we can call the - * consonant syllable logic from the vowel syllable function and get it all right! */ - return !!(FLAG (info.indic_category()) & CONSONANT_FLAGS); + return is_one_of (info, CONSONANT_FLAGS); } #define HALANT_OR_COENG_FLAGS (FLAG (OT_H) | FLAG (OT_Coeng)) -static bool +static inline bool is_halant_or_coeng (const hb_glyph_info_t &info) { - return !!(FLAG (info.indic_category()) & HALANT_OR_COENG_FLAGS); -} - -static bool -is_one_of (const hb_glyph_info_t &info, unsigned int flags) -{ - return !!(FLAG (info.indic_category()) & flags); + return is_one_of (info, HALANT_OR_COENG_FLAGS); } static inline void @@ -726,7 +729,7 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff /* XXX This will not match for old-Indic spec since the Halant-Ra order is reversed already. */ if (basic_mask_array[PREF] && base + 2 < end) { - /* Find a Halant,Ra sequence and mark it fore pre-base reordering processing. */ + /* Find a Halant,Ra sequence and mark it for pre-base reordering processing. */ for (unsigned int i = base + 1; i + 1 < end; i++) if (is_halant_or_coeng (info[i]) && info[i + 1].indic_category() == OT_Ra) diff --git a/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt b/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt index 32af26f2..03a0fae8 100644 --- a/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt +++ b/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt @@ -29,3 +29,4 @@ ර්‍ම ශී‍්‍ර ස්ට්‍රේ +ග්‍යෙ -- GitLab