From 02733dededff5759d7f90bd82426e34ab902b238 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Mar 2025 19:44:07 -0600 Subject: [PATCH] [kerx] Skip machine subtables that don't intersect the buffer We do this extensively in morx. Do it here too. Still no machine class cache in kerx. Speeds up GeezaPro shaping Arabic text by 20%. --- src/hb-aat-layout-kerx-table.hh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index 4b980ca89..97f2c9702 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -185,6 +185,9 @@ struct Format1Entry DEFINE_SIZE_STATIC (2); }; + static bool initiateAction (const Entry &entry) + { return entry.flags & Push; } + static bool performAction (const Entry &entry) { return entry.data.kernActionIndex != 0xFFFF; } @@ -394,10 +397,8 @@ struct KerxSubTableFormat1 template void collect_glyphs (set_t &left_set, set_t &right_set, unsigned num_glyphs) const { - set_t set; - machine.collect_glyphs (set, num_glyphs); - left_set.union_ (set); - right_set.union_ (set); + machine.collect_initial_glyphs (left_set, num_glyphs, *this); + machine.collect_glyphs (right_set, num_glyphs); } protected: @@ -671,10 +672,8 @@ struct KerxSubTableFormat4 template void collect_glyphs (set_t &left_set, set_t &right_set, unsigned num_glyphs) const { - set_t set; - machine.collect_glyphs (set, num_glyphs); - left_set.union_ (set); - right_set.union_ (set); + machine.collect_initial_glyphs (left_set, num_glyphs, *this); + machine.collect_glyphs (right_set, num_glyphs); } protected: @@ -1002,6 +1001,14 @@ struct KerxTable if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ()) goto skip; + c->machine_glyph_set = accel_data ? &accel_data[i].first : &Null(hb_bit_set_t); + + if (!c->buffer_intersects_machine ()) + { + (void) c->buffer->message (c->font, "skipped subtable %u because no glyph matches", c->lookup_index); + goto skip; + } + reverse = bool (st->u.header.coverage & st->u.header.Backwards) != HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);