提交 f048ead8 编写于 作者: B Behdad Esfahbod

Some more

上级 1676f608
......@@ -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;
......
......@@ -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); }
......
......@@ -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"
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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'));
}
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册