Commit graph

3 commits

Author SHA1 Message Date
Danila Poyarkov 7d9eb2931c Move font loading and layout into SkiaRenderer.prepareForExport
The headless render path duplicated font collection, text measurer
setup, and layout recomputation separately from the renderer. Move
this into SkiaRenderer.prepareForExport() so browser and headless
share the same code path for export preparation.

Remove the now-redundant loadFonts from CLI headless and the manual
setTextMeasurer/collectFontKeys/computeAllLayouts from headless-render.
2026-03-14 12:06:46 +03:00
Danila Poyarkov b9d6afcdbc Fix headless layout: set text measurer and recompute after font load
Layout was computed before fonts were loaded, so Yoga used a rough
character-width approximation instead of real CanvasKit text
measurements. Also, setTextMeasurer was never called in headless mode,
so even a second layout pass would still use the approximation.

Set the text measurer from the renderer after loadFonts, then
recompute layout before rendering.
2026-03-14 11:51:59 +03:00
Danila Poyarkov a2b56ef15a Fix headless font rendering and deduplicate CLI/MCP setup
CLI headless only loaded one 'Regular' style per font family and never
initialized the CanvasKit font provider, so all text rendered with
fallback glyphs or wrong weights.

Extract headlessRenderNodes/headlessRenderThumbnail into core's
headless-render.ts — handles CanvasKit init, renderer creation, font
provider setup, per-weight font loading via collectFontKeys, and
rendering in one call. Both CLI and MCP server now use this shared
module instead of duplicating the setup.
2026-03-14 11:45:38 +03:00