Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

LR6: done, 11-12: measureText and getImageData from the page's fonts and pixels, as built and measured

shinyobjectzfb4572f2843a
diff --git a/docs/layout-reads.feature b/docs/layout-reads.feature
index 3b06cada..82a16ab6 100644
--- a/docs/layout-reads.feature
+++ b/docs/layout-reads.feature
@@ -195,6 +195,7 @@ Feature: Layout reads: a composition measures its text and layout as Chrome does
Rule: the composition has a document
+ @done
Scenario: LR6. measureText measures with the real fonts
Then `document.createElement("canvas").getContext("2d")` is @raea/ui's 2D context, the one canvas2d.ts installs
And its measureText returns TextMetrics (width, actualBoundingBoxLeft, actualBoundingBoxRight,
@@ -205,6 +206,15 @@ Feature: Layout reads: a composition measures its text and layout as Chrome does
And the 2D context has putImageData and getImageData that read back what it drew (orb-swarm throws without
putImageData)
And with the same font, the width is within 0.5 px of Chrome's
+ And 11-12, built:
+ - systems/canvas measure.rs: measureText is the text shaped by usvg as the canvas draws it (canvas.measure),
+ its advance and font box usvg's layout box, its ink the glyphs' outlines. getImageData draws the context's
+ list on a bitmap of its own and reads it back (canvas.read); putImageData writes its pixels as they are.
+ raea-runtime-canvas serves them as natives, reached through @raea/ui's wire (canvas2d.ts __ui_sync).
+ - raea's bundled faces (Inter and the rest) now reach usvg's font database too (systems/fonts), so a canvas
+ measures and draws in them, not a fallback: the probe's width had been 314.6 against Chrome's 368.8.
+ - probes/measure.tsx matches Chrome: the width exactly, ink and font box within 0.8 px, the pixels read back
+ equal. orb-swarm (putImageData) passes.
@needs:LR1
Scenario: LR7. document's other parts