From 1d1734e985e1f2a746b4fff0cd82d96d477577d5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Oct 2018 13:04:05 +0200 Subject: [PATCH] Shuffle code around --- src/hb-ot-shape-complex-hebrew.cc | 2 +- src/hb-ot-shape-fallback.cc | 2 +- src/hb-ot-shape-normalize.cc | 2 +- src/hb-ot-shape.cc | 32 +++++++++++++++++++++++++++---- src/hb-ot-shape.hh | 29 ++++++---------------------- 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/hb-ot-shape-complex-hebrew.cc b/src/hb-ot-shape-complex-hebrew.cc index ba25258a3..ddb25ef2a 100644 --- a/src/hb-ot-shape-complex-hebrew.cc +++ b/src/hb-ot-shape-complex-hebrew.cc @@ -70,7 +70,7 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c, bool found = (bool) c->unicode->compose (a, b, ab); - if (!found && !c->plan->has_mark) + if (!found && !c->plan->has_gpos_mark) { /* Special-case Hebrew presentation forms that are excluded from * standard normalization, but wanted for old fonts. */ diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index f7409e8bf..6673abd14 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -441,7 +441,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { - if (!plan->has_kern) return; + if (!plan->kerning_requested) return; OT::hb_ot_apply_context_t c (1, font, buffer); hb_mask_t kern_mask = plan->kern_mask; diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 2f0cba184..0e13707ed 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -296,7 +296,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference; if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_AUTO) { - if (plan->has_mark) + if (plan->has_gpos_mark) // https://github.com/harfbuzz/harfbuzz/issues/653#issuecomment-423905920 //mode = HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED; mode = HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 5404a5c3a..f0e3c8be7 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -43,7 +43,32 @@ #include "hb-ot-layout-gsubgpos.hh" #include "hb-aat-layout.hh" -static hb_tag_t common_features[] = { + +void +hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, + const int *coords, + unsigned int num_coords) +{ + plan.props = props; + plan.shaper = shaper; + map.compile (plan.map, coords, num_coords); + + plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); + plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); + plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); + plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); + + plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? + HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); + + plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); + plan.kerning_requested = !!plan.kern_mask; + plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); +} + + +static hb_tag_t common_features[] = +{ HB_TAG('c','c','m','p'), HB_TAG('l','o','c','l'), HB_TAG('m','a','r','k'), @@ -52,7 +77,8 @@ static hb_tag_t common_features[] = { }; -static hb_tag_t horizontal_features[] = { +static hb_tag_t horizontal_features[] = +{ HB_TAG('c','a','l','t'), HB_TAG('c','l','i','g'), HB_TAG('c','u','r','s'), @@ -61,8 +87,6 @@ static hb_tag_t horizontal_features[] = { HB_TAG('r','c','l','t'), }; - - static void hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, const hb_segment_properties_t *props, diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index b3a490a37..a6a315a42 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -42,9 +42,9 @@ struct hb_ot_shape_plan_t const void *data; hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; hb_mask_t kern_mask; - unsigned int has_frac : 1; - unsigned int has_kern : 1; - unsigned int has_mark : 1; + bool has_frac : 1; + bool kerning_requested : 1; + bool has_gpos_mark : 1; inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const { @@ -83,26 +83,9 @@ struct hb_ot_shape_planner_t shaper (nullptr), map (face, &props) {} - inline void compile (hb_ot_shape_plan_t &plan, - const int *coords, - unsigned int num_coords) - { - plan.props = props; - plan.shaper = shaper; - map.compile (plan.map, coords, num_coords); - - plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); - plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); - plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); - plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); - - plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? - HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); - - plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); - plan.has_kern = !!plan.kern_mask; - plan.has_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); - } + HB_INTERNAL void compile (hb_ot_shape_plan_t &plan, + const int *coords, + unsigned int num_coords); private: HB_DISALLOW_COPY_AND_ASSIGN (hb_ot_shape_planner_t);