From d84932ba50482b3b47e393714eb77b19173d1f14 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 19 Jun 2019 16:57:48 -0700 Subject: [PATCH] [config] add HB_NO_OT_SHAPE_FRACTIONS, enabled in HB_LEAN Part of https://github.com/harfbuzz/harfbuzz/issues/1652 --- src/hb-config.hh | 1 + src/hb-ot-shape.cc | 9 +++++++++ src/hb-ot-shape.hh | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/hb-config.hh b/src/hb-config.hh index 381146c55..2ff92ced3 100644 --- a/src/hb-config.hh +++ b/src/hb-config.hh @@ -65,6 +65,7 @@ #define HB_NO_NAME #define HB_NO_OPEN #define HB_NO_SETLOCALE +#define HB_NO_OT_SHAPE_FRACTIONS #define HB_NO_SUBSET_LAYOUT #endif diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index e11dc15ce..4bc91c2ef 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -101,10 +101,13 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, if (apply_morx) aat_map.compile (plan.aat_map); +#ifndef HB_NO_OT_SHAPE_FRACTIONS 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.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); +#endif + plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (props.direction) ? HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n'); @@ -309,10 +312,12 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, break; } +#ifndef HB_NO_OT_SHAPE_FRACTIONS /* Automatic fractions. */ 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')); +#endif /* Random! */ map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE); @@ -590,6 +595,10 @@ hb_ot_mirror_chars (const hb_ot_shape_context_t *c) static inline void hb_ot_shape_setup_masks_fraction (const hb_ot_shape_context_t *c) { +#ifdef HB_NO_OT_SHAPE_FRACTIONS + return; +#endif + if (!(c->buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII) || !c->plan->has_frac) return; diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index 09164427e..452da635d 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -65,14 +65,24 @@ struct hb_ot_shape_plan_t hb_ot_map_t map; hb_aat_map_t aat_map; const void *data; +#ifndef HB_NO_OT_SHAPE_FRACTIONS hb_mask_t frac_mask, numr_mask, dnom_mask; +#else + static constexpr hb_mask_t frac_mask = 0; + static constexpr hb_mask_t numr_mask = 0; + static constexpr hb_mask_t dnom_mask = 0; +#endif hb_mask_t rtlm_mask; hb_mask_t kern_mask; hb_mask_t trak_mask; bool requested_kerning : 1; bool requested_tracking : 1; +#ifndef HB_NO_OT_SHAPE_FRACTIONS bool has_frac : 1; +#else + static constexpr bool has_frac = false; +#endif bool has_gpos_mark : 1; bool zero_marks : 1; bool fallback_glyph_classes : 1;