Skip to content

fix(engine2d): text staging walks codepoints so one em dash cannot blank a page - #632

Merged
ormastes merged 1 commit into
mainfrom
work/engine2d-text-staging-codepoints-2026-09-12
Sep 12, 2026
Merged

ormastes merged 1 commit into
mainfrom
work/engine2d-text-staging-codepoints-2026-09-12

Conversation

@ormastes

Copy link
Copy Markdown
Owner

fix(engine2d): stage text quads per codepoint so one em dash cannot blank a page

ResolvedFontMetrics.advances carries one entry per CODEPOINT. The advance
re-layout paired it with a table of cumulative BYTE offsets, while the staged
quads carry a codepoint index in their field named byte_offset (both
LayoutGlyph producers increment it by 1 per glyph). On ASCII the two spaces
coincide; after one em dash every lookup missed, font_batch_apply_advances
returned false, the batch was marked invalid and the whole page's Draw IR drew
nothing -- two of eight catalog pages rendered zero pixels.

  • font_advance_layout.spl: decode once with text_codepoints, index advances
    and shifts per codepoint, resolve the quads' index space once per batch.
    font_advances_codepoint_arity accepts BOTH conventions -- per-codepoint and
    round 5's byte-expanded array, collapsed losslessly -- and returns [] for
    anything else so the caller can fall back rather than reinterpret.
  • draw_ir_adv.spl: the advance gate counts codepoints and normalises arity; a
    producer may declare font-advance-arity: codepoint|byte on the command and
    a declaration that disagrees with what arrived takes the fallback. A resolved
    text run that still cannot be staged is now painted with the font's own
    advances and recorded via mark_cpu_fallback("text-advance-arity"), never
    dropping the composition. Shaped runs with a malformed payload stay
    fail-closed.
  • engine.spl: mark_cpu_fallback_reason forwards that receipt.
  • check-chrome-catalog-pixel-diff.shs: a readable capture with no ink is now
    zero-pixel-render and NAMES the page instead of counting as "unreadable";
    keyed on the PPM, never on a log line. Two new selftest fixtures (5 total).

Specs: font_advance_codepoint_arity_spec 9/9, draw_ir_em_dash_text_ink_spec 2/2
(cpu_simd, interpreter). Sabotage (byte index space) reproduces the incident
signature advances=23 text_len=25 with zero ink while ASCII stays green.
draw_ir_adv_spec is 69 examples / 25 failures both here and at origin/main --
a pre-existing red, offender lists byte-identical.

Catalog evidence (cpu_simd, interpreter, 900x760, all 8 pages): overview
337644, html 626974, css-layout 587715, css-paint 627026, forms-media 661438,
animation 661438, evidence 190568, tab-bar 45156 non-background pixels -- no
page at 0. html and css-layout are the two that rendered zero pixels in the
incident.

Pre-push, exit codes read into variables: conflict-markers PASS (28 files),
tree-size PASS (1 commit, base 136250 files), rt-dual-implementation PASS
(2519/2519, 0 new, 0 stale), test-tree-divergence-delta PASS (3209 pre-existing
offenders, 0 introduced -- pre-existing offender list saved at
/var/folders/.../test_tree_divergence_preexisting.txt, 3943 lines, recorded
here as required). check-guard-wiring FAILs on 2 NEW unwired guards,
check-blur-rect-spirv-pinned.shs and check-glass-material-spirv-pinned.shs,
both landed by a peer lane in 9ee2779 and untouched by this change.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi

🤖 Generated with Claude Code

https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi

…lank a page

`ResolvedFontMetrics.advances` carries one entry per CODEPOINT. The advance
re-layout paired it with a table of cumulative BYTE offsets, while the staged
quads carry a codepoint index in their field named `byte_offset` (both
LayoutGlyph producers increment it by 1 per glyph). On ASCII the two spaces
coincide; after one em dash every lookup missed, `font_batch_apply_advances`
returned false, the batch was marked invalid and the whole page's Draw IR drew
nothing -- two of eight catalog pages rendered zero pixels.

- font_advance_layout.spl: decode once with `text_codepoints`, index advances
  and shifts per codepoint, resolve the quads' index space once per batch.
  `font_advances_codepoint_arity` accepts BOTH conventions -- per-codepoint and
  round 5's byte-expanded array, collapsed losslessly -- and returns [] for
  anything else so the caller can fall back rather than reinterpret.
- draw_ir_adv.spl: the advance gate counts codepoints and normalises arity; a
  producer may declare `font-advance-arity: codepoint|byte` on the command and
  a declaration that disagrees with what arrived takes the fallback. A resolved
  text run that still cannot be staged is now painted with the font's own
  advances and recorded via `mark_cpu_fallback("text-advance-arity")`, never
  dropping the composition. Shaped runs with a malformed payload stay
  fail-closed.
- engine.spl: `mark_cpu_fallback_reason` forwards that receipt.
- check-chrome-catalog-pixel-diff.shs: a readable capture with no ink is now
  `zero-pixel-render` and NAMES the page instead of counting as "unreadable";
  keyed on the PPM, never on a log line. Two new selftest fixtures (5 total).

Specs: font_advance_codepoint_arity_spec 9/9, draw_ir_em_dash_text_ink_spec 2/2
(cpu_simd, interpreter). Sabotage (byte index space) reproduces the incident
signature `advances=23 text_len=25` with zero ink while ASCII stays green.
draw_ir_adv_spec is 69 examples / 25 failures both here and at origin/main --
a pre-existing red, offender lists byte-identical.

Catalog evidence (cpu_simd, interpreter, 900x760, all 8 pages): overview
337644, html 626974, css-layout 587715, css-paint 627026, forms-media 661438,
animation 661438, evidence 190568, tab-bar 45156 non-background pixels -- no
page at 0. html and css-layout are the two that rendered zero pixels in the
incident.

Pre-push, exit codes read into variables: conflict-markers PASS (28 files),
tree-size PASS (1 commit, base 136250 files), rt-dual-implementation PASS
(2519/2519, 0 new, 0 stale), test-tree-divergence-delta PASS (3209 pre-existing
offenders, 0 introduced -- pre-existing offender list saved at
/var/folders/.../test_tree_divergence_preexisting.txt, 3943 lines, recorded
here as required). check-guard-wiring FAILs on 2 NEW unwired guards,
check-blur-rect-spirv-pinned.shs and check-glass-material-spirv-pinned.shs,
both landed by a peer lane in 9ee2779 and untouched by this change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi
@ormastes
ormastes merged commit c253249 into main Sep 12, 2026
9 of 35 checks passed
@ormastes
ormastes temporarily deployed to self-review-admission September 12, 2026 11:21 — with GitHub Actions Inactive
@ormastes
ormastes deleted the work/engine2d-text-staging-codepoints-2026-09-12 branch September 12, 2026 11:22

This branch was previously deployed

1 inactive deployment
self-review-admission — 2d4af296 Deployed Sep 12, 2026 by ormastes via Invalidate changed PR self-review state #4176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant