From e1cb3b155a219e03fffac1355140a24b6f856cc8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 Feb 2025 17:28:29 +0000 Subject: [PATCH] Revert "[aat] Remove set-digest" This reverts commit 832f199607292a41b4621b87a646c30cddc00124. --- src/hb-aat-layout-common.hh | 3 ++- src/hb-aat-layout-morx-table.hh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 121c25f18..37d919a17 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -68,6 +68,7 @@ struct hb_aat_apply_context_t : hb_set_digest_t buffer_digest = hb_set_digest_t::full (); 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 (); hb_aat_class_cache_t *machine_class_cache = nullptr; hb_mask_t subtable_flags = 0; @@ -941,7 +942,7 @@ struct StateTableDriver { const auto entry = machine.get_entry (StateTableT::STATE_START_OF_TEXT, CLASS_OUT_OF_BOUNDS); return !c->is_actionable (ac->buffer, this, entry) && - machine.new_state (entry.newState) == StateTableT::STATE_START_OF_TEXT; + machine.new_state (entry.newState) == StateTableT::STATE_START_OF_TEXT; } template diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index d05737a89..1b836944e 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -171,6 +171,10 @@ struct RearrangementSubtable StateTableDriver driver (machine, c->face); + if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && + !c->buffer_digest.may_have (c->machine_glyph_set)) + return_trace (false); + driver.drive (&dc, c); return_trace (dc.ret); @@ -332,6 +336,10 @@ struct ContextualSubtable StateTableDriver driver (machine, c->face); + if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && + !c->buffer_digest.may_have (c->machine_glyph_set)) + return_trace (false); + driver.drive (&dc, c); return_trace (dc.ret); @@ -591,6 +599,10 @@ struct LigatureSubtable StateTableDriver driver (machine, c->face); + if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && + !c->buffer_digest.may_have (c->machine_glyph_set)) + return_trace (false); + driver.drive (&dc, c); return_trace (dc.ret); @@ -863,6 +875,10 @@ struct InsertionSubtable StateTableDriver driver (machine, c->face); + if (driver.is_idempotent_on_all_out_of_bounds (&dc, c) && + !c->buffer_digest.may_have (c->machine_glyph_set)) + return_trace (false); + driver.drive (&dc, c); return_trace (dc.ret); @@ -919,11 +935,25 @@ struct hb_accelerate_subtables_context_t : friend struct hb_aat_layout_lookup_accelerator_t; public: + hb_set_digest_t digest; 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) + ) + + template + void init_ (const T &obj_, unsigned num_glyphs, hb_priority<0>) + { + digest = digest.full (); + } + template void init (const T &obj_, unsigned num_glyphs) { + init_ (obj_, num_glyphs, hb_prioritize); class_cache.clear (); } @@ -1143,6 +1173,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_class_cache = accel ? &accel->subtables[i].class_cache : nullptr; if (!(subtable->get_coverage() & ChainSubtable::AllDirections) &&