Shuffle code around

This commit is contained in:
Behdad Esfahbod 2018-10-02 13:04:05 +02:00
parent bf5088b3dc
commit 1d1734e985
5 changed files with 37 additions and 30 deletions

View File

@ -70,7 +70,7 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c,
bool found = (bool) c->unicode->compose (a, b, ab); 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 /* Special-case Hebrew presentation forms that are excluded from
* standard normalization, but wanted for old fonts. */ * standard normalization, but wanted for old fonts. */

View File

@ -441,7 +441,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
hb_font_t *font, hb_font_t *font,
hb_buffer_t *buffer) hb_buffer_t *buffer)
{ {
if (!plan->has_kern) return; if (!plan->kerning_requested) return;
OT::hb_ot_apply_context_t c (1, font, buffer); OT::hb_ot_apply_context_t c (1, font, buffer);
hb_mask_t kern_mask = plan->kern_mask; hb_mask_t kern_mask = plan->kern_mask;

View File

@ -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; hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference;
if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_AUTO) 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 // https://github.com/harfbuzz/harfbuzz/issues/653#issuecomment-423905920
//mode = HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED; //mode = HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED;
mode = HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS; mode = HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;

View File

@ -43,7 +43,32 @@
#include "hb-ot-layout-gsubgpos.hh" #include "hb-ot-layout-gsubgpos.hh"
#include "hb-aat-layout.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('c','c','m','p'),
HB_TAG('l','o','c','l'), HB_TAG('l','o','c','l'),
HB_TAG('m','a','r','k'), 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','a','l','t'),
HB_TAG('c','l','i','g'), HB_TAG('c','l','i','g'),
HB_TAG('c','u','r','s'), HB_TAG('c','u','r','s'),
@ -61,8 +87,6 @@ static hb_tag_t horizontal_features[] = {
HB_TAG('r','c','l','t'), HB_TAG('r','c','l','t'),
}; };
static void static void
hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
const hb_segment_properties_t *props, const hb_segment_properties_t *props,

View File

@ -42,9 +42,9 @@ struct hb_ot_shape_plan_t
const void *data; const void *data;
hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask;
hb_mask_t kern_mask; hb_mask_t kern_mask;
unsigned int has_frac : 1; bool has_frac : 1;
unsigned int has_kern : 1; bool kerning_requested : 1;
unsigned int has_mark : 1; bool has_gpos_mark : 1;
inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const 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), shaper (nullptr),
map (face, &props) {} map (face, &props) {}
inline void compile (hb_ot_shape_plan_t &plan, HB_INTERNAL void compile (hb_ot_shape_plan_t &plan,
const int *coords, const int *coords,
unsigned int num_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'));
}
private: private:
HB_DISALLOW_COPY_AND_ASSIGN (hb_ot_shape_planner_t); HB_DISALLOW_COPY_AND_ASSIGN (hb_ot_shape_planner_t);