font.4th: TEXT entry point, UTF-8 string rendering (item 4.3.6f)

Punch list §25 item 4.3.6f complete. TEXT ( c-addr u x y size color -- )
walks a UTF-8 byte string, decoding one codepoint at a time via
DECODE-UTF8, drawing each via DRAW-GLYPH, and accumulating the cursor
X by the glyph's em-advance scaled to pixels. Uses 2>R/2R> to stash
the DECODE-UTF8 remainder off the data stack while DRAW-GLYPH's args
are pushed.

Defined in font.4th, not fabric.4th, so its compiled DRAW-GLYPH call
binds to the real definition, not fabric.4th's 4.3.6b placeholder --
same early-binding constraint as DISPATCH-GLYPH itself.

Verified live: a string mixing ASCII, Latin-1 (degree sign), and
General Punctuation (em dash) renders correctly in one TEXT call with
proportional spacing, no overlap.

Three-arch acceptance boot clean, Stadium conservation unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-09 20:46:55 -04:00
co-authored by Claude Sonnet 5
parent aee09cac0a
commit 2960989100
13 changed files with 54937 additions and 145 deletions
+17 -1
View File
@@ -4610,7 +4610,7 @@ document and committing that amendment as its own item.*
> (`resident_sum=43691 reservoir=21845 sum=65536`): amd64 (`logs/20260809-203815`),
> aarch64 (`logs/20260809-203858`), riscv64 (`logs/20260809-203950`).
- [ ] **4.3.6f — `TEXT` entry point.** `TEXT ( c-addr u x y size color -- )`: decode UTF-8 via
- [x] **4.3.6f — `TEXT` entry point.** `TEXT ( c-addr u x y size color -- )`: decode UTF-8 via
4.3.6a, dispatch each codepoint through 4.3.6b/`DRAW-GLYPH`, draw via its stroke word, scale
its returned `em-advance` to pixels (`GSIZE @ EM-UNITS */`) and accumulate into the cursor
X, per §27.6.6. *Done when:* a string containing ASCII, at least one Latin-1 character, and
@@ -4618,6 +4618,22 @@ document and committing that amendment as its own item.*
CANVAS in one call, verified via screendump, with correct proportional spacing (no
overlapping/misspaced glyphs, visibly different advance widths for e.g. `i` vs `M`).
*Refs:* §27.6.6.
> **Done 2026-08-09.** `capsules/font.4th` block 4985, using `2>R`/`2R>` to stash the
> `DECODE-UTF8` remainder (`addr' u'`) off the data stack while `DRAW-GLYPH`'s five args
> (codepoint already sits at the right stack depth for it) are pushed and consumed —
> avoids the alternative of re-deriving the remainder pointer by hand each iteration.
> Defined in `font.4th`, not `fabric.4th`, for the same reason `DISPATCH-GLYPH` had to be
> redefined there in 4.3.6c: a `fabric.4th`-compiled `TEXT` would bind early to
> `fabric.4th`'s own placeholder `DRAW-GLYPH`, not the real one.
>
> Verified live: `S" Hi 30° end—X"` (ASCII + `°` U+00B0 Latin-1 + `—` U+2014 General
> Punctuation, mixed in one string) rendered via one `TEXT` call — correct glyphs, no
> overlap, visibly proportional spacing (`i` narrow, `H`/`X`/`m`-width chars wider),
> confirmed by screendump.
>
> Three-architecture acceptance boot clean, Stadium conservation unchanged
> (`resident_sum=43691 reservoir=21845 sum=65536`): amd64 (`logs/20260809-204422`),
> aarch64 (`logs/20260809-204458`), riscv64 (`logs/20260809-204550`).
- [ ] **4.3.6g — Checkpoint: render every v1 glyph on the CANVAS.** Same posture as
4.3.4/4.3.5f — stop and review here before scoping REPL wiring (M8). *Done when:* a single