library: vendors/kb_text_shape + vendors/file_utils; modules/ffi/stb_truetype.sx retired

kb_text_shape (v2.10, JimmyLefevre) had been LOST from the sx tree —
ffi/stb_truetype.sx referenced repo paths that no longer existed (and
nothing runs glyph_cache, so the dangling unit never fired). The
trimmed copy returns from the m3te project as a proper vendor:
curated c/kbts_api.h decls over the full upstream header, README with
provenance, and examples/1627 pinning context + font creation so the
unit compiles and runs in-suite. file_utils (in-house asset-read
helper with the Android AAssetManager hook) gets the same unit shape.

modules/ffi/stb_truetype.sx is gone: glyph_cache imports the three
vendored units (stb_truetype, kb_text_shape, file_utils) directly.
This commit is contained in:
agra
2026-06-12 17:58:23 +03:00
parent 58af806b7a
commit b06776d6e9
15 changed files with 30919 additions and 14 deletions

22
library/vendors/kb_text_shape/README.md vendored Normal file
View File

@@ -0,0 +1,22 @@
# vendors/kb_text_shape — OpenType text shaping for sx programs
- Version: **v2.10** (version history at the top of the header)
- Source: <https://github.com/JimmyLefevre/kb> (`kb_text_shape.h`)
- License: zlib-style permissive (see the header's license block)
- Files: `c/kb/kb_text_shape.h` (the full upstream single-header,
~30k lines), `c/kb_text_shape_impl.c` (defines
`KB_TEXT_SHAPE_IMPLEMENTATION` and includes it), and
`c/kbts_api.h` — a hand-curated MINIMAL declaration header carrying
only the bound surface, so decl synthesis never parses the full
upstream header.
`#import "vendors/kb_text_shape/kb_text_shape.sx"` resolves through
the stdlib search paths; the implementation compiles once per machine
through sx's object cache. Shape contexts, fonts, runs, and glyphs are
opaque pointers on the sx side (modules/ui/glyph_cache.sx is the
reference consumer; `examples/1627-vendor-kbts-shape-context.sx` pins
context + font creation in the sx suite).
To upgrade: replace `c/kb/kb_text_shape.h` with a newer upstream copy,
extend `c/kbts_api.h` if the bound surface grows, update this file,
and rebuild (the object cache keys on source bytes).

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
#define KB_TEXT_SHAPE_IMPLEMENTATION
#include "kb/kb_text_shape.h"

View File

@@ -0,0 +1,15 @@
// Minimal API declarations for SX import.
// Only the functions/types we actually use — avoids parsing the full 30k-line header.
typedef struct kbts_shape_context kbts_shape_context;
typedef struct kbts_font kbts_font;
kbts_shape_context *kbts_CreateShapeContext(void *Allocator, void *AllocatorData);
void kbts_DestroyShapeContext(kbts_shape_context *Context);
kbts_font *kbts_ShapePushFontFromMemory(kbts_shape_context *Context, void *Memory, int Size, int FontIndex);
void kbts_GetFontInfo2(kbts_font *Font, void *Info);
void kbts_ShapeBegin(kbts_shape_context *Context, unsigned int ParagraphDirection, unsigned int Language);
void kbts_ShapeUtf8(kbts_shape_context *Context, const char *Utf8, int Length, unsigned int UserIdGenerationMode);
void kbts_ShapeEnd(kbts_shape_context *Context);
int kbts_ShapeRun(kbts_shape_context *Context, void *Run);
int kbts_GlyphIteratorNext(void *It, void **Glyph);

View File

@@ -0,0 +1,18 @@
// =====================================================================
// vendors/kb_text_shape — Jimmy Lefevre's kb_text_shape (OpenType text
// shaping) as a `#import c` unit (c/, see README.md for version +
// provenance).
//
// `#import "vendors/kb_text_shape/kb_text_shape.sx"` gives any sx
// program text shaping with no system dependency. The decls come from
// c/kbts_api.h — a hand-curated MINIMAL declaration header covering
// only the bound surface (the full upstream header is ~30k lines and
// is included only by the implementation unit). Shape contexts, fonts,
// runs, and glyphs are opaque pointers on the sx side; see
// modules/ui/glyph_cache.sx for the reference consumer.
// =====================================================================
#import c {
#include "c/kbts_api.h";
#source "c/kb_text_shape_impl.c";
};