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>
25 lines
678 B
MoonBit
25 lines
678 B
MoonBit
///| Wasm font backend: the component has no C rasteriser, so glyphs come from the host's
|
|
/// `moonplasma:host/font` import (the host draws them from the TTF files it loads).
|
|
|
|
///| Load a TTF file into `slot`.
|
|
fn b_load(slot : Int, path : String) -> Bool {
|
|
@hostfont.load(slot.reinterpret_as_uint(), path)
|
|
}
|
|
|
|
///| Rasterise one glyph.
|
|
fn b_glyph(slot : Int, cp : Int, size : Int) -> RawGlyph {
|
|
let g = @hostfont.rasterise(
|
|
slot.reinterpret_as_uint(),
|
|
cp.reinterpret_as_uint(),
|
|
size.reinterpret_as_uint(),
|
|
)
|
|
{
|
|
w: g.width,
|
|
h: g.height,
|
|
xoff: g.xoff,
|
|
yoff: g.yoff,
|
|
advance: g.advance,
|
|
coverage: Bytes::from_fixedarray(g.coverage),
|
|
}
|
|
}
|