From 30145272a7d428bc62a903388bd7be43f4da7fc3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 15 Oct 2013 13:47:27 +0200 Subject: [PATCH] [indic] Don't apply presentation features across syllables More like Uniscribe... We still allow user-defined features to work across syllables, but not pres,blws,abs,psts,etc. This "regressed" Sinhala numbers by 11. These are cases were there's Consonant followed by Ra,Halant,ZWJ at the of text. The Ra,Halant,ZWJ ends up forming reph, which is wrong... But before we were also ligating that reph with the previous consonant. That's even more wrong. That's also what Uniscribe does. Current numbers: BENGALI: 353732 out of 354188 tests passed. 456 failed (0.128745%) DEVANAGARI: 707307 out of 707394 tests passed. 87 failed (0.0122987%) GUJARATI: 366349 out of 366457 tests passed. 108 failed (0.0294714%) GURMUKHI: 60732 out of 60747 tests passed. 15 failed (0.0246926%) KANNADA: 951030 out of 951913 tests passed. 883 failed (0.0927606%) KHMER: 299070 out of 299124 tests passed. 54 failed (0.0180527%) MALAYALAM: 1048140 out of 1048334 tests passed. 194 failed (0.0185056%) ORIYA: 42320 out of 42329 tests passed. 9 failed (0.021262%) SINHALA: 271655 out of 271847 tests passed. 192 failed (0.070628%) TAMIL: 1091753 out of 1091754 tests passed. 1 failed (9.15957e-05%) TELUGU: 970555 out of 970573 tests passed. 18 failed (0.00185457%) --- src/hb-ot-shape-complex-indic.cc | 21 +++++++++++++++---- .../indic/script-sinhala/misc/misc.txt | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 00e3c45e3..7986ead6e 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -416,6 +416,10 @@ static void final_reordering (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); +static void +clear_syllables (const hb_ot_shape_plan_t *plan, + hb_font_t *font, + hb_buffer_t *buffer); static void collect_features_indic (hb_ot_shape_planner_t *plan) @@ -441,6 +445,7 @@ collect_features_indic (hb_ot_shape_planner_t *plan) for (; i < INDIC_NUM_FEATURES; i++) { map->add_feature (indic_features[i].tag, 1, indic_features[i].flags | F_MANUAL_ZWJ); } + map->add_gsub_pause (clear_syllables); } static void @@ -1558,15 +1563,23 @@ final_reordering (const hb_ot_shape_plan_t *plan, } final_reordering_syllable (plan, buffer, last, count); - /* Zero syllables now... */ - for (unsigned int i = 0; i < count; i++) - info[i].syllable() = 0; - HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category); HB_BUFFER_DEALLOCATE_VAR (buffer, indic_position); } +static void +clear_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED, + hb_font_t *font HB_UNUSED, + hb_buffer_t *buffer) +{ + hb_glyph_info_t *info = buffer->info; + unsigned int count = buffer->len; + for (unsigned int i = 0; i < count; i++) + info[i].syllable() = 0; +} + + static hb_ot_shape_normalization_mode_t normalization_preference_indic (const hb_segment_properties_t *props HB_UNUSED) { 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 363fcb660..c43cb95b1 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 @@ -38,3 +38,4 @@ ර්‍ ක්‍රා කේ +ගර්‍