[depend] Filter context position-0 class members by coverage

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 <noreply@anthropic.com>
This commit is contained in:
Skef Iterum committed 2026-06-05 15:09:12 -07:00
1 parent 6ff195b540
commit 4aa781e4a3
1 file changed
+7 -2
+7 -2
View File
@@ -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<hb_set_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<hb_set_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]);