From 474bef1cfd8f8c839cfe7e6d1333bbf93057dde4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 Feb 2025 19:17:13 +0000 Subject: [PATCH] [aat] Use exact set for buffer intersection versus subchains --- src/hb-aat-layout-common.hh | 4 ++-- src/hb-aat-layout-morx-table.hh | 24 +++++++++++++----------- src/hb-buffer.hh | 8 +++++++- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 5db0d1212..4213ee280 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -63,10 +63,10 @@ struct hb_aat_apply_context_t : const ankr *ankr_table; const OT::GDEF *gdef_table; const hb_sorted_vector_t *range_flags = nullptr; - hb_set_digest_t buffer_digest = hb_set_digest_t::full (); + hb_set_t buffer_digest; const hb_set_t *left_set = nullptr; const hb_set_t *right_set = nullptr; - hb_set_digest_t machine_glyph_set = hb_set_digest_t::full (); + const hb_set_t *machine_glyph_set = nullptr; hb_aat_class_cache_t *machine_class_cache = nullptr; hb_mask_t subtable_flags = 0; diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index f5c986349..b2fd47d1f 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -172,7 +172,7 @@ struct RearrangementSubtable StateTableDriver driver (machine, c->face); if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && - !c->buffer_digest.intersects (c->machine_glyph_set)) + !c->buffer_digest.intersects (*c->machine_glyph_set)) { (void) c->buffer->message (c->font, "skipped chainsubtable because no glyph matches"); return_trace (false); @@ -340,7 +340,7 @@ struct ContextualSubtable StateTableDriver driver (machine, c->face); if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && - !c->buffer_digest.intersects (c->machine_glyph_set)) + !c->buffer_digest.intersects (*c->machine_glyph_set)) { (void) c->buffer->message (c->font, "skipped chainsubtable because no glyph matches"); return_trace (false); @@ -606,7 +606,7 @@ struct LigatureSubtable StateTableDriver driver (machine, c->face); if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && - !c->buffer_digest.intersects (c->machine_glyph_set)) + !c->buffer_digest.intersects (*c->machine_glyph_set)) { (void) c->buffer->message (c->font, "skipped chainsubtable because no glyph matches"); return_trace (false); @@ -885,7 +885,7 @@ struct InsertionSubtable StateTableDriver driver (machine, c->face); if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && - !c->buffer_digest.intersects (c->machine_glyph_set)) + !c->buffer_digest.intersects (*c->machine_glyph_set)) { (void) c->buffer->message (c->font, "skipped chainsubtable because no glyph matches"); return_trace (false); @@ -947,19 +947,21 @@ struct hb_accelerate_subtables_context_t : friend struct hb_aat_layout_lookup_accelerator_t; public: - hb_set_digest_t digest; + hb_set_t glyph_set; mutable hb_aat_class_cache_t class_cache; template auto init_ (const T &obj_, unsigned num_glyphs, hb_priority<1>) HB_AUTO_RETURN - ( - obj_.machine.collect_glyphs (this->digest, num_glyphs) - ) + (( + glyph_set.init (), + obj_.machine.collect_glyphs (glyph_set, num_glyphs) + )) template void init_ (const T &obj_, unsigned num_glyphs, hb_priority<0>) { - digest = digest.full (); + glyph_set.init (); + glyph_set.invert (); } template @@ -1185,7 +1187,7 @@ struct Chain hb_map ([subtable_flags] (const hb_aat_map_t::range_flags_t _) -> bool { return subtable_flags & (_.flags); }))) goto skip; c->subtable_flags = subtable_flags; - c->machine_glyph_set = accel ? accel->subtables[i].digest : hb_set_digest_t::full (); + c->machine_glyph_set = accel ? &accel->subtables[i].glyph_set : nullptr; c->machine_class_cache = accel ? &accel->subtables[i].class_cache : nullptr; if (!(subtable->get_coverage() & ChainSubtable::AllDirections) && @@ -1416,7 +1418,7 @@ struct mortmorx c->buffer->unsafe_to_concat (); - c->buffer_digest = c->buffer->digest (); + c->buffer_digest = c->buffer->set (); c->set_lookup_index (0); const Chain *chain = &firstChain; diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 2a6ad6128..4a4a9631a 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -32,6 +32,7 @@ #include "hb.hh" #include "hb-unicode.hh" +#include "hb-set.hh" #include "hb-set-digest.hh" @@ -194,7 +195,12 @@ struct hb_buffer_t hb_set_digest_t digest () const { hb_set_digest_t d; - d.init (); + d.add_array (&info[0].codepoint, len, sizeof (info[0])); + return d; + } + hb_set_t set () const + { + hb_set_t d; d.add_array (&info[0].codepoint, len, sizeof (info[0])); return d; }