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.

LR10: a family raea/text's loadFont asked for gets Google's faces in the page even where raea bundles faces of that name, as a linked stylesheet's @font-face shadows a local font in Chrome. Inter is bundled (static 400 and 700), so it was never a missing family and Google's never came: 300, 400 and 500 drew alike ("snapcn" at 100px 345.45 px; Chrome 340.39, 345.47, 350.45) and 600 as 700. Now 340.33, 345.45, 350.48, 355.38, 360.45. snapcn 18 -> 21 of 33 (wordmark-cut, text-select, hero-launch pass; punch-lines 18.1 -> 0.9, text-rewrite 7.4 -> 0.2); P26 unchanged (185 of 215, every frame at the same SSIM). LR10 records the read cost: the first read in a frame about 0.39 ms, each further one about 0.01 ms (300 frames, median of 6), and karaoke-captions' reads under the run's noise

shinyobjectz869318073a7a
diff --git a/docs/layout-reads.feature b/docs/layout-reads.feature
index 39647363..d1a80430 100644
--- a/docs/layout-reads.feature
+++ b/docs/layout-reads.feature
@@ -322,7 +322,7 @@ Feature: Layout reads: a composition measures its text and layout as Chrome does
And a composition that measures every frame (karaoke-captions, 300 frames) has its cost per read and per frame
measured and written here
And sdk/raea/conformance covers the JS side, and Rust tests cover the call, the wait and the hang guard
- And 11-12, in progress (snapcn: 3 of 33 before LR work, 7 after LR1-LR9, 12 after the usvg and font fixes, 17 with kerning and the manifest, 18 now):
+ And 11-12, in progress (snapcn: 3 of 33 before LR work, 7 after LR1-LR9, 12 after the usvg and font fixes, 17 with kerning and the manifest, 21 now):
- Kerning across spans. blitz-dom gave every composition span a border edge: with `border-style: none` (the
initial style) a border's computed width is still `medium`, and inline_edges read the width alone, so each
plain span got a zero-width spacer box at both ends and parley split its shaping there. "AVAWATAVAWAT" in a
@@ -347,10 +347,21 @@ Feature: Layout reads: a composition measures its text and layout as Chrome does
Figtree's "scene" at 600 64px measured 145.72 against Chrome's 171.25, now 171.26. An app-bundled face of a
family the page already gave is left out (Geist fetched at import came before the bundled Geist).
bloom-lockup passes (40.8 px off before), word-gather is 1.2 px off (25.5 before).
- - Still off (15), not yet traced: announce-title (frame 0's runs), capture-reveal (3 runs only raea has),
- font-shuffle, portal-intro, prompt-send, punch-lines, search-typing, status-cycle, text-build (SF's trak),
- text-rewrite, text-select, word-gather, card-rail, hero-launch (a video's frame, not text) and
- wordmark-cut.
+ - A loadFont family's faces are the page's even where raea bundles faces of that name, as a linked
+ stylesheet's @font-face shadows a local font. Inter is bundled (static 400 and 700), so it was never missing
+ and Google's never came: raea drew 300, 400 and 500 alike (345.45 px at 100px for "snapcn"; Chrome 340.39,
+ 345.47, 350.45) and 600 as 700. Now 340.33, 345.45, 350.48, 355.38, 360.45. wordmark-cut (22 px narrow at 500),
+ text-select and hero-launch pass; punch-lines 18.1 -> 0.9, text-rewrite 7.4 -> 0.2 (box; ink 1.9).
+ - Still off (12): announce-title (frame 0's runs), capture-reveal (3 runs only raea has), font-shuffle,
+ portal-intro, prompt-send, punch-lines and text-rewrite (their ink, 1.3 to 1.9 px past Chrome's, the boxes
+ within 1), search-typing (1.9), status-cycle, text-build (SF's trak), word-gather (1.2) and card-rail.
+ - The cost, measured 11-12 on the M5 Pro (300 frames, 1280x720, 40 inline-blocks of Inter whose text changes
+ every frame, rendered to hashes, median of 6): no reads 2.034 s, one getBoundingClientRect a frame 2.151 s,
+ ten a frame 2.180 s. The first read in a frame costs about 0.39 ms (one layout synced); each further read in
+ that frame about 0.01 ms (the answer is cached until the next flush). snapcn's karaoke-captions (150 frames at
+ its defaults) reads two rects when a card mounts and once more when Montserrat is ready, not every frame:
+ 0.74 s with its reads, 0.75 to 0.77 s with them replaced by 0, the same frames, so its reads cost less than
+ the run's noise.
- P26 with these: 185 of 215 frames at the bar, the same frames at the same SSIM (to six places) as a binary
before them. The 12 compositions under it are all 3D (classbg, datamaps, paint, planes, texmaps, the four
volumetric benches, box3d, arena3d) plus css/edit.tsx, which throws before its first commit; the volumetric
diff --git a/systems/fonts/src/google.rs b/systems/fonts/src/google.rs
index e54e2352..f2d9314d 100644
--- a/systems/fonts/src/google.rs
+++ b/systems/fonts/src/google.rs
@@ -50,14 +50,29 @@ pub fn enabled() -> bool {
every() || !WANTED.lock().unwrap().is_empty()
}
-/// Gives `doc` the faces of each family its elements name that it has none of and Google Fonts has; true when one
-/// was given (its text is laid out again).
+/// Gives `doc` the faces of each family its elements name that it has none of and Google Fonts has, and once each
+/// family raea/text's loadFont asked for even where raea bundles faces of that name (as a linked stylesheet's
+/// @font-face shadows a local font in Chrome: raea's static Inter 400 and 700 drew loadFont's Inter 500 as 400 and 600
+/// as 700); true when one was given (its text is laid out again).
pub fn load_missing(doc: &mut BaseDocument) -> bool {
- let mut loaded = false;
- for family in doc.missing_font_families() {
- if !wanted(&family) {
- continue;
+ // (document, family) each asked-for family went to
+ static GIVEN: Mutex<Vec<(usize, String)>> = Mutex::new(Vec::new());
+ let mut families = doc.missing_font_families();
+ families.retain(|f| wanted(f));
+ {
+ let mut given = GIVEN.lock().unwrap();
+ for family in WANTED.lock().unwrap().iter() {
+ let key = (doc.id(), family.to_lowercase());
+ if !given.contains(&key) {
+ given.push(key);
+ if !families.iter().any(|f| f.eq_ignore_ascii_case(family)) {
+ families.push(family.clone());
+ }
+ }
}
+ }
+ let mut loaded = false;
+ for family in families {
let faces = FAMILIES.lock().unwrap().get_or_insert_default().get(&family).cloned();
let faces = faces.unwrap_or_else(|| {
let found = Arc::new(fetch(&family));