From 4aa781e4a36d16ffbf552b2ad3ad08ec5ed159e5 Mon Sep 17 00:00:00 2001 From: Skef Iterum Date: Mon, 18 May 2026 15:12:03 -0700 Subject: [PATCH] [depend] Filter context position-0 class members by coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In context_depend_lookup and chain_context_depend_lookup, the ClassBasedContext case at position 0 collected all class members via collect_class without intersecting with the coverage. For a ContextSubst/ChainContextSubst to fire, the first glyph must be in BOTH the class AND the coverage. Class members outside the coverage can never trigger the rule, so their edges are spurious. Fix: intersect pos0_glyphs with parent_active_glyphs (which the ContextFormat2/ChainContextFormat2 caller sets to coverage ∩ glyphs) after collecting class members. Found via parity checker testing with AOTS font classdef1_font3.otf (ContextSubst format 2 with coverage smaller than class membership). Assisted-by: Claude Sonnet 4.6 --- src/hb-ot-layout-gsubgpos.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 1b3824ad2..96706525f 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -2333,7 +2333,9 @@ static inline void context_depend_lookup (hb_depend_context_t *c, /* Build glyph sets for ALL input positions */ hb_vector_t input_position_glyphs; - /* Position 0 (Coverage glyph) */ + /* Position 0 (Coverage glyph) — must be in both the class AND the + * coverage, so intersect with parent_active_glyphs (= coverage ∩ glyphs + * set by the ContextFormat2/3 caller). */ hb_set_t pos0_glyphs; switch (lookup_context.context_format) { @@ -2342,6 +2344,7 @@ static inline void context_depend_lookup (hb_depend_context_t *c, break; case ContextFormat::ClassBasedContext: collect_class (&pos0_glyphs, value, lookup_context.intersects_data); + pos0_glyphs.intersect (c->parent_active_glyphs ()); break; case ContextFormat::CoverageBasedContext: collect_coverage (&pos0_glyphs, value, lookup_context.intersects_data); @@ -3708,7 +3711,8 @@ static inline void chain_context_depend_lookup (hb_depend_context_t *c, /* Build glyph sets for ALL input positions */ hb_vector_t input_position_glyphs; - /* Position 0 (first input coverage/class/glyph) */ + /* Position 0 (first input coverage/class/glyph) — must be in both the + * class AND the coverage, so intersect with parent_active_glyphs. */ hb_set_t pos0_glyphs; switch (lookup_context.context_format) { @@ -3717,6 +3721,7 @@ static inline void chain_context_depend_lookup (hb_depend_context_t *c, break; case ContextFormat::ClassBasedContext: collect_class (&pos0_glyphs, value, lookup_context.intersects_data[1]); + pos0_glyphs.intersect (c->parent_active_glyphs ()); break; case ContextFormat::CoverageBasedContext: collect_coverage (&pos0_glyphs, value, lookup_context.intersects_data[1]);