ttf_words.c: TTF-TEXT entry point, hmtx advance widths (item 4.3.7e)
Punch list §25 item 4.3.7e complete. New src/word_source/ttf_words.c registers TTF-TEXT ( c-addr u x y size color -- ): lazily loads the v1 default font capsule + raster cache once, decodes UTF-8 (C reimplementation mirroring capsules/fabric.4th's DECODE-UTF8 exactly), looks up each glyph's cached bitmap, blits via fb_put_pixel, advances the pen by the glyph's real hmtx advance width scaled to pixels. Necessary plumbing: ttf_parse() now also locates hhea/hmtx, and ttf_glyph_advance_width() reads a glyph's advance width -- required for this item's own "proportional spacing correct" acceptance clause, no advance-width data existed anywhere else in the parser. Verified in tools/ttftest.c: A/a/0/space all read advance_width=600, correctly uniform since JetBrainsMono-Regular.ttf is monospace. (x,y) is raster pixel space (top-left origin, Y-down), deliberately not the stroke font TEXT's Cartesian Y-up convention -- recorded explicitly in ttf_words.h, not conflated. Verified live, amd64, screendump: injected S" Hi 4.3.7e!" 200 200 28 16777215 TTF-TEXT over a serial socket after boot, no error, captured a screendump showing the string rendered legibly with correct mixed-case/digit/punctuation glyphs and even spacing. TTF-TEXT is this item's permanent deliverable, not a throwaway probe. Compile-checked clean on all three architectures. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
2db4603d04
commit
715ebcc57e
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
StarForth — Steady-State Virtual Machine Runtime
|
||||
|
||||
Copyright (c) 2023–2025 Robert A. James
|
||||
All rights reserved.
|
||||
|
||||
Licensed under the StarForth License, Version 1.0
|
||||
*/
|
||||
|
||||
#ifndef TTF_WORDS_H
|
||||
#define TTF_WORDS_H
|
||||
|
||||
#include "vm.h"
|
||||
|
||||
/**
|
||||
* @defgroup ttf_words TrueType Text Words
|
||||
* @{
|
||||
*
|
||||
* @brief `TTF-TEXT`, the TrueType-backed text entry point (FABRIC.md item
|
||||
* 4.3.7e). Kernel-only; no-op on hosted builds (no framebuffer/capsule
|
||||
* system exists there).
|
||||
*
|
||||
* @par TTF-TEXT ( c-addr u x y size color -- )
|
||||
* Render a UTF-8 string via the v1 default font capsule
|
||||
* (`fonts:JetBrainsMono-Regular.ttf`, loaded and cached lazily on first
|
||||
* use). (x,y) is raster pixel space (top-left origin, Y-down) -- NOT
|
||||
* capsules/fabric.4th's Cartesian Y-up convention used by the stroke
|
||||
* font's `TEXT` (4.3.6f); the two are deliberately different coordinate
|
||||
* systems, not interchangeable. (x,y) is the first glyph's baseline-left
|
||||
* origin. `size` is capped at `TTF_CACHE_MAX_SIZE_PX` (see ttf.h).
|
||||
* Advances proportionally per glyph via the font's real hmtx advance
|
||||
* width, scaled to pixels.
|
||||
* @}
|
||||
*/
|
||||
|
||||
void register_ttf_words(VM *vm);
|
||||
|
||||
#endif /* TTF_WORDS_H */
|
||||
Reference in New Issue
Block a user