diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index 8cfc8bc37b5c0ff9151c8bcbe50a03ac7f5a7326..de2071ad6aa31aac94d0cba80eeb569275df510f 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -184,6 +184,8 @@ struct trak { TRACE_APPLY (this); + hb_mask_t trak_mask = c->plan->trak_mask; + const float ptem = c->font->ptem; if (unlikely (ptem <= 0.f)) return_trace (false); @@ -197,6 +199,7 @@ struct trak hb_position_t advance_to_add = c->font->em_scalef_x (tracking); foreach_grapheme (buffer, start, end) { + if (!(buffer->info[start].mask & trak_mask)) continue; buffer->pos[start].x_advance += advance_to_add; buffer->pos[start].x_offset += offset_to_add; } @@ -209,6 +212,7 @@ struct trak hb_position_t advance_to_add = c->font->em_scalef_y (tracking); foreach_grapheme (buffer, start, end) { + if (!(buffer->info[start].mask & trak_mask)) continue; buffer->pos[start].y_advance += advance_to_add; buffer->pos[start].y_offset += offset_to_add; } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 8de66f3d6f11a7220d339112f95e9b319c144fdd..e05a67706eff0d69c2713e7e0117370d1de546f2 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -62,16 +62,18 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, 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.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); + plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n'); plan.kern_mask = plan.map.get_mask (kern_tag); + plan.trak_mask = plan.map.get_mask (HB_TAG ('t','r','a','k')); plan.requested_kerning = !!plan.kern_mask; + plan.requested_tracking = !!plan.trak_mask; bool has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX; bool disable_gpos = plan.shaper->gpos_tag && plan.shaper->gpos_tag != plan.map.chosen_script[1]; @@ -116,8 +118,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, plan.fallback_mark_positioning = true; /* Currently we always apply trak. */ - plan.apply_trak = hb_aat_layout_has_tracking (face) && - plan.map.needs_fallback (HB_TAG ('t','r','a','k')); + plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face); } @@ -178,7 +179,9 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, /* Random! */ map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE); - /* Tracking. */ + /* Tracking. We enable dummy feature here just to allow disabling + * AAT 'trak' table using features. + * https://github.com/harfbuzz/harfbuzz/issues/1303 */ map->enable_feature (HB_TAG ('t','r','a','k'), F_HAS_FALLBACK); map->enable_feature (HB_TAG ('H','A','R','F')); diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index c9c0d3e093db628fef08c561648d4a619f002fe9..93fce2d971b6b102fc912f5abba450d9dd62ac10 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -40,10 +40,13 @@ struct hb_ot_shape_plan_t const struct hb_ot_complex_shaper_t *shaper; hb_ot_map_t map; const void *data; - hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; + hb_mask_t frac_mask, numr_mask, dnom_mask; + hb_mask_t rtlm_mask; hb_mask_t kern_mask; + hb_mask_t trak_mask; bool requested_kerning : 1; + bool requested_tracking : 1; bool has_frac : 1; bool has_gpos_mark : 1; bool fallback_glyph_classes : 1; diff --git a/test/shaping/data/in-house/tests/aat-trak.tests b/test/shaping/data/in-house/tests/aat-trak.tests index c8f10fbcfbf5606ca935342929951b4e3fd0337c..3c558e60eda995ce6a1c6206b2ef22ab92da532b 100644 --- a/test/shaping/data/in-house/tests/aat-trak.tests +++ b/test/shaping/data/in-house/tests/aat-trak.tests @@ -8,3 +8,4 @@ ../fonts/TestTRAK.ttf:--font-ptem=144:U+0041,U+0042,U+0043:[A.alt=0@-107,0+786|B=1@-107,0+786|C.alt=2@-107,0+786] ../fonts/TestTRAK.ttf:--font-ptem=144:U+0041,U+0042,U+0043:[A.alt=0@-107,0+786|B=1@-107,0+786|C.alt=2@-107,0+786] ../fonts/TestTRAK.ttf:--font-ptem=144 --features=-trak:U+0041,U+0042,U+0043:[A.alt=0+1000|B=1+1000|C.alt=2+1000] +../fonts/TestTRAK.ttf:--font-ptem=144 --features=-trak[1;3]:U+0041,U+0042,U+0043,U+0041,U+0042,U+0043:[A.alt=0@-107,0+786|B=1+1000|C.alt=2+1000|A.alt=3@-107,0+786|B=4@-107,0+786|C.alt=5@-107,0+786]