[trak] Allow disabling tracking for ranges of text
Fixes https://github.com/harfbuzz/harfbuzz/issues/1303
This commit is contained in:
parent
8869436cb8
commit
cf92d6579e
|
@ -184,6 +184,8 @@ struct trak
|
||||||
{
|
{
|
||||||
TRACE_APPLY (this);
|
TRACE_APPLY (this);
|
||||||
|
|
||||||
|
hb_mask_t trak_mask = c->plan->trak_mask;
|
||||||
|
|
||||||
const float ptem = c->font->ptem;
|
const float ptem = c->font->ptem;
|
||||||
if (unlikely (ptem <= 0.f))
|
if (unlikely (ptem <= 0.f))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
@ -197,6 +199,7 @@ struct trak
|
||||||
hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
|
hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
|
||||||
foreach_grapheme (buffer, start, end)
|
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_advance += advance_to_add;
|
||||||
buffer->pos[start].x_offset += offset_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);
|
hb_position_t advance_to_add = c->font->em_scalef_y (tracking);
|
||||||
foreach_grapheme (buffer, start, end)
|
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_advance += advance_to_add;
|
||||||
buffer->pos[start].y_offset += offset_to_add;
|
buffer->pos[start].y_offset += offset_to_add;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,16 +62,18 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
|
||||||
plan.shaper = shaper;
|
plan.shaper = shaper;
|
||||||
map.compile (plan.map, coords, num_coords);
|
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.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.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.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.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_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
|
||||||
HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
|
HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
|
||||||
plan.kern_mask = plan.map.get_mask (kern_tag);
|
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_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 has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
|
||||||
bool disable_gpos = plan.shaper->gpos_tag &&
|
bool disable_gpos = plan.shaper->gpos_tag &&
|
||||||
plan.shaper->gpos_tag != plan.map.chosen_script[1];
|
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;
|
plan.fallback_mark_positioning = true;
|
||||||
|
|
||||||
/* Currently we always apply trak. */
|
/* Currently we always apply trak. */
|
||||||
plan.apply_trak = hb_aat_layout_has_tracking (face) &&
|
plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
|
||||||
plan.map.needs_fallback (HB_TAG ('t','r','a','k'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +179,9 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
|
||||||
/* Random! */
|
/* Random! */
|
||||||
map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE);
|
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 ('t','r','a','k'), F_HAS_FALLBACK);
|
||||||
|
|
||||||
map->enable_feature (HB_TAG ('H','A','R','F'));
|
map->enable_feature (HB_TAG ('H','A','R','F'));
|
||||||
|
|
|
@ -40,10 +40,13 @@ struct hb_ot_shape_plan_t
|
||||||
const struct hb_ot_complex_shaper_t *shaper;
|
const struct hb_ot_complex_shaper_t *shaper;
|
||||||
hb_ot_map_t map;
|
hb_ot_map_t map;
|
||||||
const void *data;
|
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 kern_mask;
|
||||||
|
hb_mask_t trak_mask;
|
||||||
|
|
||||||
bool requested_kerning : 1;
|
bool requested_kerning : 1;
|
||||||
|
bool requested_tracking : 1;
|
||||||
bool has_frac : 1;
|
bool has_frac : 1;
|
||||||
bool has_gpos_mark : 1;
|
bool has_gpos_mark : 1;
|
||||||
bool fallback_glyph_classes : 1;
|
bool fallback_glyph_classes : 1;
|
||||||
|
|
|
@ -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: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: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]
|
||||||
|
|
Loading…
Reference in New Issue