From e89b7d2a61b7f58e6c7cec00d5ce2246dee1e8a1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 8 Oct 2010 12:29:59 -0400 Subject: [PATCH] Logically separate feature collection --- src/hb-ot-shape.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 8b8b76fcf..febac351d 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -237,20 +237,17 @@ struct hb_mask_allocator_t { }; static void -hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c, - lookup_map *lookups, - unsigned int *num_lookups) +hb_ot_shape_collect_features (hb_ot_shape_context_t *c, + hb_mask_allocator_t *allocator) { - hb_mask_allocator_t allocator; - switch (c->original_direction) { case HB_DIRECTION_LTR: - allocator.add_feature (HB_TAG ('l','t','r','a'), 1, true); - allocator.add_feature (HB_TAG ('l','t','r','m'), 1, true); + allocator->add_feature (HB_TAG ('l','t','r','a'), 1, true); + allocator->add_feature (HB_TAG ('l','t','r','m'), 1, true); break; case HB_DIRECTION_RTL: - allocator.add_feature (HB_TAG ('r','t','l','a'), 1, true); - allocator.add_feature (HB_TAG ('r','t','l','m'), 1, false); + allocator->add_feature (HB_TAG ('r','t','l','a'), 1, true); + allocator->add_feature (HB_TAG ('r','t','l','m'), 1, false); break; case HB_DIRECTION_TTB: case HB_DIRECTION_BTT: @@ -259,15 +256,25 @@ hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c, } for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++) - allocator.add_feature (default_features[i], 1, true); + allocator->add_feature (default_features[i], 1, true); /* complex */ for (unsigned int i = 0; i < c->num_features; i++) { const hb_feature_t *feature = &c->features[i]; - allocator.add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1)); + allocator->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1)); } +} + + +static void +hb_ot_shape_setup_lookups (hb_ot_shape_context_t *c, + lookup_map *lookups, + unsigned int *num_lookups) +{ + hb_mask_allocator_t allocator; + hb_ot_shape_collect_features (c, &allocator); /* Compile features */ unsigned int script_index, language_index, feature_index;