Real fonts in the wasm compositor: the host rasterises glyphs (Allo Variable, Adwaita Mono)
CI / test (push) Failing after 27s
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:
1 parent
0b9af11232
commit
5c3bebc7fd
15 files changed
+408
-143
No files matched your search
@@ -1,7 +1,24 @@
|
||||
///| The compositor as a wasm component has no C rasteriser. Until the host offers glyphs through
|
||||
/// an import, text uses the renderer's built-in bitmap font.
|
||||
///| 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).
|
||||
|
||||
///| Install real fonts; always false here, so the renderer keeps its bitmap font.
|
||||
pub fn install() -> Bool {
|
||||
false
|
||||
///| 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),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user