From 0c3b061ac244fa8a8657366e1b95523503fdf7be Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 7 Nov 2018 13:58:41 -0500 Subject: [PATCH] [kern] Apply erlier, where GPOS/kerx are applied --- src/hb-aat-layout-kerx-table.hh | 3 +-- src/hb-ot-shape-fallback.cc | 9 +++++++++ src/hb-ot-shape.cc | 12 +++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index 6bbeda764..8b87e176f 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -889,8 +889,7 @@ struct KerxTable if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ()) goto skip; - reverse = T::Types::extended /* TODO remove after kern application is moved earlier. */ && - bool (st->u.header.coverage & st->u.header.Backwards) != + reverse = bool (st->u.header.coverage & st->u.header.Backwards) != HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction); if (!c->buffer->message (c->font, "start %c%c%c%c subtable %d", HB_UNTAG (thiz()->tableTag), c->lookup_index)) diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index cfd06e7fd..bbc410ad6 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -464,9 +464,18 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, !font->has_glyph_h_kerning_func () : !font->has_glyph_v_kerning_func ()) return; + + bool reverse = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); + + if (reverse) + buffer->reverse (); + hb_ot_shape_fallback_kern_driver_t driver (font, buffer); OT::hb_kern_machine_t machine (driver); machine.kern (font, buffer, plan->kern_mask, false); + + if (reverse) + buffer->reverse (); } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 98c29a483..d2f771320 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -866,10 +866,15 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c) break; } + /* XXX Clean up relationship between these. */ if (c->plan->apply_gpos) c->plan->position (c->font, c->buffer); else if (c->plan->apply_kerx) hb_aat_layout_position (c->plan, c->font, c->buffer); + else if (c->plan->apply_kern) + hb_ot_layout_kern (c->plan, c->font, c->buffer); + else if (c->plan->fallback_kerning) + _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer); if (c->plan->apply_trak) hb_aat_layout_track (c->plan, c->font, c->buffer); @@ -915,13 +920,6 @@ hb_ot_position (const hb_ot_shape_context_t *c) if (HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction)) hb_buffer_reverse (c->buffer); - /* Visual fallback goes here. */ - - if (c->plan->apply_kern) - hb_ot_layout_kern (c->plan, c->font, c->buffer); - else if (c->plan->fallback_kerning) - _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer); - _hb_buffer_deallocate_gsubgpos_vars (c->buffer); }