diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index cb70583f44811e88c843140be9ed01fbdda96e59..ebac6d140692d829a5e81e6a5f8d290b5f2da665 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -74,8 +74,9 @@ hb_ot_map_builder_t::~hb_ot_map_builder_t (void) stages[table_index].fini (); } -void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, - hb_ot_map_feature_flags_t flags) +void hb_ot_map_builder_t::add_feature (hb_tag_t tag, + hb_ot_map_feature_flags_t flags, + unsigned int value) { feature_info_t *info = feature_infos.push(); if (unlikely (!tag)) return; diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index c4e7837a8e1407d0caea4b8e70dde67354628797..f719cc6a37dc866fd632f807af572bccc4f59ffe 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -196,17 +196,18 @@ struct hb_ot_map_builder_t HB_INTERNAL ~hb_ot_map_builder_t (void); - HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value, - hb_ot_map_feature_flags_t flags); + HB_INTERNAL void add_feature (hb_tag_t tag, + hb_ot_map_feature_flags_t flags=F_NONE, + unsigned int value=1); inline void add_feature (const hb_ot_map_feature_t &feat) - { add_feature (feat.tag, 1, feat.flags); } + { add_feature (feat.tag, feat.flags); } - inline void add_global_bool_feature (hb_tag_t tag) - { add_feature (tag, 1, F_GLOBAL); } + inline void enable_feature (hb_tag_t tag) + { add_feature (tag, F_GLOBAL); } inline void disable_feature (hb_tag_t tag) - { add_feature (tag, 0, F_GLOBAL); } + { add_feature (tag, F_GLOBAL, 0); } inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func) { add_pause (0, pause_func); } diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index ebc1d3d5fd0ab6442b9b03593b8b5b5b26eb48cd..fff3b31286de804ec4ec557f66dd729ff1b9b954 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -202,28 +202,28 @@ collect_features_arabic (hb_ot_shape_planner_t *plan) map->add_gsub_pause (nuke_joiners); - map->add_global_bool_feature (HB_TAG('s','t','c','h')); + map->enable_feature (HB_TAG('s','t','c','h')); map->add_gsub_pause (record_stch); - map->add_global_bool_feature (HB_TAG('c','c','m','p')); - map->add_global_bool_feature (HB_TAG('l','o','c','l')); + map->enable_feature (HB_TAG('c','c','m','p')); + map->enable_feature (HB_TAG('l','o','c','l')); map->add_gsub_pause (nullptr); for (unsigned int i = 0; i < ARABIC_NUM_FEATURES; i++) { 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_feature (arabic_features[i], has_fallback ? F_HAS_FALLBACK : F_NONE); map->add_gsub_pause (nullptr); } - map->add_feature (HB_TAG('r','l','i','g'), 1, F_GLOBAL|F_HAS_FALLBACK); + map->add_feature (HB_TAG('r','l','i','g'), F_GLOBAL|F_HAS_FALLBACK); if (plan->props.script == HB_SCRIPT_ARABIC) map->add_gsub_pause (arabic_fallback_shape); /* No pause after rclt. See 98460779bae19e4d64d29461ff154b3527bf8420. */ - map->add_global_bool_feature (HB_TAG('r','c','l','t')); - map->add_global_bool_feature (HB_TAG('c','a','l','t')); + map->enable_feature (HB_TAG('r','c','l','t')); + map->enable_feature (HB_TAG('c','a','l','t')); map->add_gsub_pause (nullptr); /* The spec includes 'cswh'. Earlier versions of Windows @@ -234,8 +234,8 @@ collect_features_arabic (hb_ot_shape_planner_t *plan) * Note that IranNastaliq uses this feature extensively * to fixup broken glyph sequences. Oh well... * Test case: U+0643,U+0640,U+0631. */ - //map->add_global_bool_feature (HB_TAG('c','s','w','h')); - map->add_global_bool_feature (HB_TAG('m','s','e','t')); + //map->enable_feature (HB_TAG('c','s','w','h')); + map->enable_feature (HB_TAG('m','s','e','t')); } #include "hb-ot-shape-complex-arabic-fallback.hh" diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc index 3d8199b5cd3e558b6d00348e0a0290c4790afe25..96fd42678f9a8ddff2fc266b5537cbd40a07bc93 100644 --- a/src/hb-ot-shape-complex-hangul.cc +++ b/src/hb-ot-shape-complex-hangul.cc @@ -56,7 +56,7 @@ collect_features_hangul (hb_ot_shape_planner_t *plan) hb_ot_map_builder_t *map = &plan->map; for (unsigned int i = FIRST_HANGUL_FEATURE; i < HANGUL_FEATURE_COUNT; i++) - map->add_feature (hangul_features[i], 1, F_NONE); + map->add_feature (hangul_features[i]); } static void diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index b541402af60947a4732a8be96e7986d2f1a4b53a..e2fae7aea156fe61b26bfbc6cd66ba5fea63bcb4 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -190,10 +190,10 @@ collect_features_indic (hb_ot_shape_planner_t *plan) /* Do this before any lookups have been applied. */ map->add_gsub_pause (setup_syllables); - map->add_global_bool_feature (HB_TAG('l','o','c','l')); + map->enable_feature (HB_TAG('l','o','c','l')); /* The Indic specs do not require ccmp, but we apply it here since if * there is a use of it, it's typically at the beginning. */ - map->add_global_bool_feature (HB_TAG('c','c','m','p')); + map->enable_feature (HB_TAG('c','c','m','p')); unsigned int i = 0; @@ -209,8 +209,8 @@ collect_features_indic (hb_ot_shape_planner_t *plan) for (; i < INDIC_NUM_FEATURES; i++) map->add_feature (indic_features[i]); - map->add_global_bool_feature (HB_TAG('c','a','l','t')); - map->add_global_bool_feature (HB_TAG('c','l','i','g')); + map->enable_feature (HB_TAG('c','a','l','t')); + map->enable_feature (HB_TAG('c','l','i','g')); map->add_gsub_pause (clear_syllables); } diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc index 9987841539e50ca499ee9c1187eeb4429a5a9cd1..77059293d4be2a0861f57be955e3c7bdafac59ab 100644 --- a/src/hb-ot-shape-complex-khmer.cc +++ b/src/hb-ot-shape-complex-khmer.cc @@ -116,8 +116,8 @@ collect_features_khmer (hb_ot_shape_planner_t *plan) * * https://github.com/harfbuzz/harfbuzz/issues/974 */ - map->add_global_bool_feature (HB_TAG('l','o','c','l')); - map->add_global_bool_feature (HB_TAG('c','c','m','p')); + map->enable_feature (HB_TAG('l','o','c','l')); + map->enable_feature (HB_TAG('c','c','m','p')); unsigned int i = 0; for (; i < KHMER_BASIC_FEATURES; i++) @@ -128,8 +128,8 @@ collect_features_khmer (hb_ot_shape_planner_t *plan) for (; i < KHMER_NUM_FEATURES; i++) map->add_feature (khmer_features[i]); - map->add_global_bool_feature (HB_TAG('c','a','l','t')); - map->add_global_bool_feature (HB_TAG('c','l','i','g')); + map->enable_feature (HB_TAG('c','a','l','t')); + map->enable_feature (HB_TAG('c','l','i','g')); } diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index 215e7053116af2c8e3981233393bae8461bb1a05..532ebfdc9a08fe88a55366e61631c8ab0e9e72c2 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -96,27 +96,27 @@ collect_features_myanmar (hb_ot_shape_planner_t *plan) /* Do this before any lookups have been applied. */ map->add_gsub_pause (setup_syllables); - map->add_global_bool_feature (HB_TAG('l','o','c','l')); + map->enable_feature (HB_TAG('l','o','c','l')); /* The Indic specs do not require ccmp, but we apply it here since if * there is a use of it, it's typically at the beginning. */ - map->add_global_bool_feature (HB_TAG('c','c','m','p')); + map->enable_feature (HB_TAG('c','c','m','p')); map->add_gsub_pause (initial_reordering); for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++) { - map->add_feature (basic_features[i], 1, F_GLOBAL | F_MANUAL_ZWJ); + map->add_feature (basic_features[i], F_GLOBAL | F_MANUAL_ZWJ); map->add_gsub_pause (nullptr); } map->add_gsub_pause (final_reordering); for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++) - map->add_feature (other_features[i], 1, F_GLOBAL | F_MANUAL_ZWJ); + map->add_feature (other_features[i], F_GLOBAL | F_MANUAL_ZWJ); for (unsigned int i = 0; i < ARRAY_LENGTH (positioning_features); i++) - map->add_feature (positioning_features[i], 1, F_GLOBAL); + map->enable_feature (positioning_features[i]); } static void diff --git a/src/hb-ot-shape-complex-tibetan.cc b/src/hb-ot-shape-complex-tibetan.cc index 9982ebc29f0fd2b34a34cfd5855a99ac199e1f2d..27c60b11e2964f20afa518a17d7d6c05423d0049 100644 --- a/src/hb-ot-shape-complex-tibetan.cc +++ b/src/hb-ot-shape-complex-tibetan.cc @@ -40,7 +40,7 @@ static void collect_features_tibetan (hb_ot_shape_planner_t *plan) { for (const hb_tag_t *script_features = tibetan_features; script_features && *script_features; script_features++) - plan->map.add_global_bool_feature (*script_features); + plan->map.enable_feature (*script_features); } diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 62aef7e6f21e3a4e6e7245a4e3cd7d37c42ee33f..0ca088ba882893d7bfadaa3afdf7730112eb02c0 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -129,37 +129,37 @@ collect_features_use (hb_ot_shape_planner_t *plan) map->add_gsub_pause (setup_syllables); /* "Default glyph pre-processing group" */ - map->add_global_bool_feature (HB_TAG('l','o','c','l')); - map->add_global_bool_feature (HB_TAG('c','c','m','p')); - map->add_global_bool_feature (HB_TAG('n','u','k','t')); - map->add_global_bool_feature (HB_TAG('a','k','h','n')); + map->enable_feature (HB_TAG('l','o','c','l')); + map->enable_feature (HB_TAG('c','c','m','p')); + map->enable_feature (HB_TAG('n','u','k','t')); + map->enable_feature (HB_TAG('a','k','h','n')); /* "Reordering group" */ map->add_gsub_pause (clear_substitution_flags); - map->add_feature (HB_TAG('r','p','h','f'), 1, F_MANUAL_ZWJ); + map->add_feature (HB_TAG('r','p','h','f'), F_MANUAL_ZWJ); map->add_gsub_pause (record_rphf); map->add_gsub_pause (clear_substitution_flags); - map->add_feature (HB_TAG('p','r','e','f'), 1, F_GLOBAL | F_MANUAL_ZWJ); + map->add_feature (HB_TAG('p','r','e','f'), F_GLOBAL | F_MANUAL_ZWJ); map->add_gsub_pause (record_pref); /* "Orthographic unit shaping group" */ for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++) - map->add_feature (basic_features[i], 1, F_GLOBAL | F_MANUAL_ZWJ); + map->add_feature (basic_features[i], F_GLOBAL | F_MANUAL_ZWJ); map->add_gsub_pause (reorder); /* "Topographical features" */ for (unsigned int i = 0; i < ARRAY_LENGTH (arabic_features); i++) - map->add_feature (arabic_features[i], 1, F_NONE); + map->add_feature (arabic_features[i]); map->add_gsub_pause (nullptr); /* "Standard typographic presentation" */ for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++) - map->add_feature (other_features[i], 1, F_GLOBAL | F_MANUAL_ZWJ); + map->add_feature (other_features[i], F_GLOBAL | F_MANUAL_ZWJ); /* "Positional feature application" */ for (unsigned int i = 0; i < ARRAY_LENGTH (positioning_features); i++) - map->add_feature (positioning_features[i], 1, F_GLOBAL); + map->enable_feature (positioning_features[i]); } struct use_shape_plan_t diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 437b0feb45cd9adaf39e1c66fc0cf5f2c45e6655..6bfd2c7a099e4c40f82a80876a3f4d980d9efdf6 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -71,17 +71,17 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, { hb_ot_map_builder_t *map = &planner->map; - map->add_global_bool_feature (HB_TAG('r','v','r','n')); + map->enable_feature (HB_TAG('r','v','r','n')); map->add_gsub_pause (nullptr); switch (props->direction) { case HB_DIRECTION_LTR: - map->add_global_bool_feature (HB_TAG ('l','t','r','a')); - map->add_global_bool_feature (HB_TAG ('l','t','r','m')); + map->enable_feature (HB_TAG ('l','t','r','a')); + map->enable_feature (HB_TAG ('l','t','r','m')); break; case HB_DIRECTION_RTL: - map->add_global_bool_feature (HB_TAG ('r','t','l','a')); - map->add_feature (HB_TAG ('r','t','l','m'), 1, F_NONE); + map->enable_feature (HB_TAG ('r','t','l','a')); + map->add_feature (HB_TAG ('r','t','l','m')); break; case HB_DIRECTION_TTB: case HB_DIRECTION_BTT: @@ -91,22 +91,22 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, } /* Automatic fractions. */ - map->add_feature (HB_TAG ('f','r','a','c'), 1, F_NONE); - map->add_feature (HB_TAG ('n','u','m','r'), 1, F_NONE); - map->add_feature (HB_TAG ('d','n','o','m'), 1, F_NONE); + map->add_feature (HB_TAG ('f','r','a','c')); + map->add_feature (HB_TAG ('n','u','m','r')); + map->add_feature (HB_TAG ('d','n','o','m')); /* Random! */ - map->add_feature (HB_TAG ('r','a','n','d'), HB_OT_MAP_MAX_VALUE, F_GLOBAL | F_RANDOM); + map->add_feature (HB_TAG ('r','a','n','d'), F_GLOBAL | F_RANDOM, HB_OT_MAP_MAX_VALUE); if (planner->shaper->collect_features) planner->shaper->collect_features (planner); for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++) - map->add_global_bool_feature (common_features[i]); + map->enable_feature (common_features[i]); if (HB_DIRECTION_IS_HORIZONTAL (props->direction)) for (unsigned int i = 0; i < ARRAY_LENGTH (horizontal_features); i++) - map->add_feature (horizontal_features[i], 1, F_GLOBAL | + map->add_feature (horizontal_features[i], F_GLOBAL | (horizontal_features[i] == HB_TAG('k','e','r','n') ? F_HAS_FALLBACK : F_NONE)); else @@ -115,7 +115,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, * matter which script/langsys it is listed (or not) under. * See various bugs referenced from: * https://github.com/harfbuzz/harfbuzz/issues/63 */ - map->add_feature (HB_TAG ('v','e','r','t'), 1, F_GLOBAL | F_GLOBAL_SEARCH); + map->add_feature (HB_TAG ('v','e','r','t'), F_GLOBAL | F_GLOBAL_SEARCH); } if (planner->shaper->override_features) @@ -124,9 +124,9 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, for (unsigned int i = 0; i < num_user_features; i++) { const hb_feature_t *feature = &user_features[i]; - map->add_feature (feature->tag, feature->value, - (feature->start == 0 && feature->end == (unsigned int) -1) ? - F_GLOBAL : F_NONE); + map->add_feature (feature->tag, + (feature->start == 0 && feature->end == (unsigned int) -1) ? F_GLOBAL : F_NONE, + feature->value); } }