Real fonts in the wasm compositor: the host rasterises glyphs (Allo Variable, Adwaita Mono)
CI / test (push) Failing after 27s

New moonplasma:host/font import (load a TTF into a slot, rasterise a glyph). compositor/font now
shares its loading/caching/install logic and has two backends: stb_truetype through C (native) and
the host import (wasm). The Rust host draws glyphs with ab_glyph's outlines on an integer pixel grid,
using stb_truetype's em-size scaling, so text matches the native build.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-25 01:50:01 -08:00
1 parent 0b9af11232
commit 5c3bebc7fd
15 files changed
+408 -143

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// One rendered glyph: an 8-bit coverage bitmap `width` x `height`, whose top-left sits at
/// (`xoff`, `yoff`) from the pen on the baseline (y grows downward), and the pen advance.
pub(all) struct Glyph {
width : Int; height : Int; xoff : Int; yoff : Int; advance : Int; coverage : FixedArray[Byte]
}
///|
/// Load the TTF file at `path` into `slot` (0..3). False when it can't be read or parsed.
pub fn load(slot : UInt, path : String) -> Bool {
let ptr = mbt_ffi_str2ptr(path)
let result : Int = wasmImportLoad((slot).reinterpret_as_int(), ptr, path.length());
let ret = (result != 0)
mbt_ffi_free(ptr)
return ret
}
///|
pub fn rasterise(slot : UInt, codepoint : UInt, size : UInt) -> Glyph {
let return_area = mbt_ffi_malloc(28)
wasmImportRasterise((slot).reinterpret_as_int(), (codepoint).reinterpret_as_int(), (size).reinterpret_as_int(), return_area);
let result = mbt_ffi_ptr2bytes(mbt_ffi_load32((return_area) + 20), mbt_ffi_load32((return_area) + 24))
let ret = Glyph::{width : mbt_ffi_load32((return_area) + 0), height : mbt_ffi_load32((return_area) + 4), xoff : mbt_ffi_load32((return_area) + 8), yoff : mbt_ffi_load32((return_area) + 12), advance : mbt_ffi_load32((return_area) + 16), coverage : result}
mbt_ffi_free(return_area)
return ret
}