Skip to content

Commit

Permalink
[config] add HB_NO_OT_SHAPE_FRACTIONS, enabled in HB_LEAN
Browse files Browse the repository at this point in the history
Part of #1652
  • Loading branch information
behdad committed Jun 19, 2019
1 parent eaf4a73 commit d84932b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hb-config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/hb-ot-shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/hb-ot-shape.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

3 comments on commit d84932b

@dscorbett
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this one belong in HB_LEAN? CONFIG.md says “HB_LEAN: Disables various non-shaping functionality in the library” but this option disables shaping functionality.

@behdad
Copy link
Member Author

@behdad behdad commented on d84932b Jun 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm. Right. There's also HB_NO_OT_SHAPE_COMPLEX_VOWEL_CONSTRAINTS that is maybe misplaced as well. I'll try to find another setting for those. Thanks!

@behdad
Copy link
Member Author

@behdad behdad commented on d84932b Jun 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change the wording of HB_LEAN for now. We will eventually change or document better.

HB_LEAN also changes glyph extents with hb-ot-font, which affects shaping if font doesn't have positioning table...

Please sign in to comment.