From b20305022a8235b19e6b640bc62651854e1336f1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 26 Apr 2016 16:41:17 -0700 Subject: [PATCH] Do NOT ignore Mongolian Free Variation Selectors during matching Fixes https://github.com/behdad/harfbuzz/issues/234 --- src/hb-ot-layout-gsubgpos-private.hh | 2 +- src/hb-ot-layout-private.hh | 23 ++++++++++++++++-- src/hb-ot-shape-complex-arabic.cc | 2 +- ...4a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf | Bin 0 -> 3700 bytes .../tests/mongolian-variation-selector.tests | 1 + 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 test/shaping/fonts/sha1sum/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 691334c99..56c501533 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -319,7 +319,7 @@ struct hb_apply_context_t : if (!c->check_glyph_property (&info, lookup_props)) return SKIP_YES; - if (unlikely (_hb_glyph_info_is_default_ignorable (&info) && + if (unlikely (_hb_glyph_info_is_default_ignorable_and_not_fvs (&info) && (ignore_zwnj || !_hb_glyph_info_is_zwnj (&info)) && (ignore_zwj || !_hb_glyph_info_is_zwj (&info)))) return SKIP_MAYBE; diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 22faa485a..778b2c442 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -218,7 +218,8 @@ _next_syllable (hb_buffer_t *buffer, unsigned int start) * - General_Category: 5 bits. * - A bit each for: * * Is it Default_Ignorable(); we have a modified Default_Ignorable(). - * * Two free bits right now. + * * Whether it's one of the three Mongolian Free Variation Selectors. + * * One free bit right now. * * The high-byte has different meanings, switched by the Gen-Cat: * - For Mn,Mc,Me: the modified Combining_Class. @@ -230,6 +231,7 @@ _next_syllable (hb_buffer_t *buffer, unsigned int start) enum hb_unicode_props_flags_t { UPROPS_MASK_GEN_CAT = 0x001Fu, UPROPS_MASK_IGNORABLE = 0x0020u, + UPROPS_MASK_FVS = 0x0040u, /* MONGOLIAN FREE VARIATION SELECTOR 1..3 */ /* If GEN_CAT=FORMAT, top byte masks: */ UPROPS_MASK_Cf_ZWJ = 0x0100u, @@ -254,6 +256,15 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer) props |= UPROPS_MASK_IGNORABLE; if (u == 0x200Cu) props |= UPROPS_MASK_Cf_ZWNJ; if (u == 0x200Du) props |= UPROPS_MASK_Cf_ZWJ; + /* Mongolian Free Variation Selectors need to be remembered + * because although we need to hide them like default-ignorables, + * they need to non-ignorable during shaping. This is similar to + * what we do for joiners in Indic-like shapers, but since the + * FVSes are GC=Mn, we have use a separate bit to remember them. + * Fixes: + * https://github.com/behdad/harfbuzz/issues/234 + */ + if (unlikely (hb_in_range (u, 0x180Bu, 0x180Du))) props |= UPROPS_MASK_FVS; } else if (unlikely (HB_UNICODE_GENERAL_CATEGORY_IS_NON_ENCLOSING_MARK_OR_MODIFIER_SYMBOL (gen_cat))) { @@ -349,7 +360,15 @@ static inline bool _hb_glyph_info_ligated (const hb_glyph_info_t *info); static inline hb_bool_t _hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info) { - return (info->unicode_props() & UPROPS_MASK_IGNORABLE) && !_hb_glyph_info_ligated (info); + return (info->unicode_props() & UPROPS_MASK_IGNORABLE) && + !_hb_glyph_info_ligated (info); +} +static inline hb_bool_t +_hb_glyph_info_is_default_ignorable_and_not_fvs (const hb_glyph_info_t *info) +{ + return ((info->unicode_props() & (UPROPS_MASK_IGNORABLE|UPROPS_MASK_FVS)) + == UPROPS_MASK_IGNORABLE) && + !_hb_glyph_info_ligated (info); } static inline bool diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 4da899055..ea57d4e47 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -215,7 +215,7 @@ collect_features_arabic (hb_ot_shape_planner_t *plan) { bool has_fallback = plan->props.script == HB_SCRIPT_ARABIC && !FEATURE_IS_SYRIAC (arabic_features[i]); map->add_feature (arabic_features[i], 1, has_fallback ? F_HAS_FALLBACK : F_NONE); - map->add_gsub_pause (NULL); + //map->add_gsub_pause (NULL); } map->add_feature (HB_TAG('r','l','i','g'), 1, F_GLOBAL|F_HAS_FALLBACK); diff --git a/test/shaping/fonts/sha1sum/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf b/test/shaping/fonts/sha1sum/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf new file mode 100644 index 0000000000000000000000000000000000000000..74fceec894af91ed877bf7445522e21079f7caec GIT binary patch literal 3700 zcmcgveQZM0_Of5+^{I z2$|NN=!OsMGdGM@vbZo%`%0 zP^hML)oya%z2}^F&pG$}&b{v#2mlyh99ZaCyC&8IPOt#zZzI>Uw!N(razPJ}B_f@@ zwzF%MYr>>O+5teewslriJ$L2srvSRMDDT-h*gNd_ll>pKo>wfiE?wU@ zFuEtUO>+t79|1`J?BCtH>!TgND!}!q4P0y2M> znIR?YaojBst2<0eQtz4LG=rP~Lcc4T79T*`8J$Jz}kiidSPyq^5Lp`j77&Jo% zbVDzE9rnRV0IyXJ%bD)R(JO})f?bmtDNW}Keq{f8<;vWf$t3YkPcvP~e+;)7 zMCPTGcJ6eHG|r93rtUN2bK{IM_YS*1q0QIgBfIy;xp*`h=k88L4;_k59hw`SWY@N* zMpBn!=J^JEog>S(3&LmAQ^$VTbV# zNi%#YRFA-m@bfgP6wQTB(OW>yg!6EQrX!^nWd9M>MJ!1HvD@s3s;7bki68%cWeBWA zu^Nc%@%s?aD(}O1M-c96WIqVF3OU6)MDb3IQMglM(_F<8(h4?;K5Z1~)XnMX)Sr_{ z_R!;yzJD--FIyv5n!8+USBJ|j4#B1ruGx^aM?0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