Minor refactoring

This commit is contained in:
Behdad Esfahbod 2013-02-15 06:22:26 -05:00
parent cfc507c543
commit ee9c3a17d0
3 changed files with 26 additions and 64 deletions

View File

@ -36,7 +36,7 @@
*/ */
static const hb_tag_t static const hb_tag_t
myanmar_features[] = basic_features[] =
{ {
/* /*
* Basic features. * Basic features.
@ -46,6 +46,10 @@ myanmar_features[] =
HB_TAG('p','r','e','f'), HB_TAG('p','r','e','f'),
HB_TAG('b','l','w','f'), HB_TAG('b','l','w','f'),
HB_TAG('p','s','t','f'), HB_TAG('p','s','t','f'),
};
static const hb_tag_t
other_features[] =
{
/* /*
* Other features. * Other features.
* These features are applied all at once, after final_reordering. * These features are applied all at once, after final_reordering.
@ -58,25 +62,6 @@ myanmar_features[] =
HB_TAG('d','i','s','t'), HB_TAG('d','i','s','t'),
}; };
/*
* Must be in the same order as the myanmar_features array.
*/
enum {
_RPHF,
_PREF,
_BLWF,
_PSTF,
_PRES,
_ABVS,
_BLWS,
_PSTS,
_DIST,
MYANMAR_NUM_FEATURES,
MYANMAR_BASIC_FEATURES = _PRES /* Don't forget to update this! */
};
static void static void
setup_syllables (const hb_ot_shape_plan_t *plan, setup_syllables (const hb_ot_shape_plan_t *plan,
hb_font_t *font, hb_font_t *font,
@ -104,16 +89,15 @@ collect_features_myanmar (hb_ot_shape_planner_t *plan)
map->add_global_bool_feature (HB_TAG('c','c','m','p')); map->add_global_bool_feature (HB_TAG('c','c','m','p'));
unsigned int i = 0;
map->add_gsub_pause (initial_reordering); map->add_gsub_pause (initial_reordering);
for (; i < MYANMAR_BASIC_FEATURES; i++) { for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++)
map->add_feature (myanmar_features[i], 1, F_GLOBAL | F_MANUAL_JOINERS); {
map->add_feature (basic_features[i], 1, F_GLOBAL | F_MANUAL_JOINERS);
map->add_gsub_pause (NULL); map->add_gsub_pause (NULL);
} }
map->add_gsub_pause (final_reordering); map->add_gsub_pause (final_reordering);
for (; i < MYANMAR_NUM_FEATURES; i++) { for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++)
map->add_feature (myanmar_features[i], 1, F_GLOBAL); map->add_feature (other_features[i], 1, F_GLOBAL);
}
} }
static void static void

View File

@ -38,7 +38,7 @@
*/ */
static const hb_tag_t static const hb_tag_t
sea_features[] = basic_features[] =
{ {
/* /*
* Basic features. * Basic features.
@ -48,6 +48,10 @@ sea_features[] =
HB_TAG('a','b','v','f'), HB_TAG('a','b','v','f'),
HB_TAG('b','l','w','f'), HB_TAG('b','l','w','f'),
HB_TAG('p','s','t','f'), HB_TAG('p','s','t','f'),
};
static const hb_tag_t
other_features[] =
{
/* /*
* Other features. * Other features.
* These features are applied all at once, after final_reordering. * These features are applied all at once, after final_reordering.
@ -60,25 +64,6 @@ sea_features[] =
HB_TAG('d','i','s','t'), HB_TAG('d','i','s','t'),
}; };
/*
* Must be in the same order as the sea_features array.
*/
enum {
_PREF,
_ABVF,
_BLWF,
_PSTF,
_PRES,
_ABVS,
_BLWS,
_PSTS,
_DIST,
SEA_NUM_FEATURES,
SEA_BASIC_FEATURES = _PRES /* Don't forget to update this! */
};
static void static void
setup_syllables (const hb_ot_shape_plan_t *plan, setup_syllables (const hb_ot_shape_plan_t *plan,
hb_font_t *font, hb_font_t *font,
@ -105,17 +90,15 @@ collect_features_sea (hb_ot_shape_planner_t *plan)
* there is a use of it, it's typically at the beginning. */ * there is a use of it, it's typically at the beginning. */
map->add_global_bool_feature (HB_TAG('c','c','m','p')); map->add_global_bool_feature (HB_TAG('c','c','m','p'));
unsigned int i = 0;
map->add_gsub_pause (initial_reordering); map->add_gsub_pause (initial_reordering);
for (; i < SEA_BASIC_FEATURES; i++) { for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++)
map->add_feature (sea_features[i], 1, F_GLOBAL | F_MANUAL_JOINERS); {
map->add_feature (basic_features[i], 1, F_GLOBAL | F_MANUAL_JOINERS);
map->add_gsub_pause (NULL); map->add_gsub_pause (NULL);
} }
map->add_gsub_pause (final_reordering); map->add_gsub_pause (final_reordering);
for (; i < SEA_NUM_FEATURES; i++) { for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++)
map->add_feature (sea_features[i], 1, F_GLOBAL | F_MANUAL_JOINERS); map->add_feature (other_features[i], 1, F_GLOBAL);
}
} }
static void static void

View File

@ -97,27 +97,22 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
break; break;
} }
#define ADD_FEATURES(array) \
HB_STMT_START { \
for (unsigned int i = 0; i < ARRAY_LENGTH (array); i++) \
map->add_global_bool_feature (array[i]); \
} HB_STMT_END
if (planner->shaper->collect_features) if (planner->shaper->collect_features)
planner->shaper->collect_features (planner); planner->shaper->collect_features (planner);
ADD_FEATURES (common_features); for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++)
map->add_global_bool_feature (common_features[i]);
if (HB_DIRECTION_IS_HORIZONTAL (props->direction)) if (HB_DIRECTION_IS_HORIZONTAL (props->direction))
ADD_FEATURES (horizontal_features); for (unsigned int i = 0; i < ARRAY_LENGTH (horizontal_features); i++)
map->add_global_bool_feature (horizontal_features[i]);
else else
ADD_FEATURES (vertical_features); for (unsigned int i = 0; i < ARRAY_LENGTH (vertical_features); i++)
map->add_global_bool_feature (vertical_features[i]);
if (planner->shaper->override_features) if (planner->shaper->override_features)
planner->shaper->override_features (planner); planner->shaper->override_features (planner);
#undef ADD_FEATURES
for (unsigned int i = 0; i < num_user_features; i++) { for (unsigned int i = 0; i < num_user_features; i++) {
const hb_feature_t *feature = &user_features[i]; const hb_feature_t *feature = &user_features[i];
map->add_feature (feature->tag, feature->value, map->add_feature (feature->tag, feature->value,