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:
co-authored by
Claude Sonnet 5
parent
aee09cac0a
commit
2960989100
@@ -717,3 +717,17 @@ Block 4984
|
||||
: DRAW-GLYPH ( codepoint x y size color -- adv )
|
||||
GCOLOR ! GSIZE ! GOY ! GOX !
|
||||
DISPATCH-GLYPH ;
|
||||
|
||||
Block 4985
|
||||
( TEXT: 4.3.6f. Defined here, not fabric.4th -- binds to the )
|
||||
( real DRAW-GLYPH above, not fabric.4th's placeholder. )
|
||||
VARIABLE TX VARIABLE TY VARIABLE TSIZE VARIABLE TCOLOR
|
||||
: TEXT ( c-addr u x y size color -- )
|
||||
TCOLOR ! TSIZE ! TY ! TX !
|
||||
BEGIN DUP 0> WHILE
|
||||
DECODE-UTF8 2>R
|
||||
TX @ TY @ TSIZE @ TCOLOR @ DRAW-GLYPH
|
||||
TSIZE @ EM-UNITS */ TX @ + TX !
|
||||
2R>
|
||||
REPEAT
|
||||
2DROP ;
|
||||
|
||||
Reference in New Issue
Block a user