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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
LR10: a canvas's system-ui and BlinkMacSystemFont are macOS's SF ("System Font", variable in weight and optical size), as Chrome's canvas takes them. fontdb knew neither name, so a font list headed by them (snapcn's '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif') was measured and drawn in Helvetica, about 10% wider at 72px, and 600 measured as 700. -apple-system alone stays as it is: Chrome's canvas finds no face for it either. text-build, which places its words from measureText, goes from 9 px off Chrome to 1.3; the rest is SF's trak table, which CoreText applies and usvg doesn't
shinyobjectz5189132ef87b
diff --git a/docs/layout-reads.feature b/docs/layout-reads.featureindex fc24788a..58ca31a3 100644--- a/docs/layout-reads.feature+++ b/docs/layout-reads.feature@@ -337,9 +337,14 @@ Feature: Layout reads: a composition measures its text and layout as Chrome does- A manifest text's ink spans its glyph runs and inline-blocks, not the line's whole advance: an inlineelement's padding at a line's end (a caption's word pill) isn't ink. karaoke-captions and word-captionspass.+ - A canvas's `system-ui` and `BlinkMacSystemFont` are macOS's SF ("System Font", variable in weight and optical+ size), as Chrome's canvas takes them: fontdb knew neither, so a list headed by them was measured in+ Helvetica, about 10% wider at 72px. text-build, which places its words from measureText, went from 9 px off+ to 1.3: what's left is SF's `trak` table (CoreText tracks SF about 0.12 px a letter at 72px; usvg doesn't).- Still off (16), not yet traced: announce-title (frame 0's runs), bloom-lockup, capture-reveal (3 runs only- raea has), font-shuffle, portal-intro, prompt-send, punch-lines, search-typing, status-cycle, text-build,- text-rewrite, text-select, word-gather, card-rail, hero-launch (a video's frame, not text) and wordmark-cut.+ 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.- P26 with these: 185 of 215 frames at the bar, the same frames at the same SSIM (to six places) as a binarybefore them. The 12 compositions under it are all 3D (classbg, datamaps, paint, planes, texmaps, the fourvolumetric benches, box3d, arena3d) plus css/edit.tsx, which throws before its first commit; the volumetricdiff --git a/systems/canvas/src/measure.rs b/systems/canvas/src/measure.rsindex 04bf9ac8..17230064 100644--- a/systems/canvas/src/measure.rs+++ b/systems/canvas/src/measure.rs@@ -6,6 +6,24 @@use serde_json::{json, Value};use usvg::fontdb::{Family, Query, Style, Weight, ID};+/// The system UI face's family where the faces have it: macOS's SF (SFNS.ttf, "System Font"), variable in weight and+/// optical size, which usvg sets from the size as Chrome does.+const SYSTEM_UI: &str = "System Font";++/// A CSS family list with the names Chrome's canvas takes for the system UI face (`system-ui`, `BlinkMacSystemFont`)+/// given as that face's own family, when the faces have it: fontdb knows them as no family, so a list headed by them+/// fell through to sans-serif (Helvetica, about 10% wider than SF at 72px: snapcn's text-build spread its words).+/// Chrome's canvas finds no face for `-apple-system` alone, so it stays as it is.+pub(crate) fn system_ui(family: &str, db: &usvg::fontdb::Database) -> String {+ let has = || db.faces().any(|f| f.families.iter().any(|(n, _)| n == SYSTEM_UI));+ let names: Vec<&str> = family.split(',').map(str::trim).collect();+ let ui = |n: &str| matches!(n.trim_matches(['\'', '"']).to_ascii_lowercase().as_str(), "system-ui" | "blinkmacsystemfont");+ if !names.iter().any(|n| ui(n)) || !has() {+ return family.to_string();+ }+ names.iter().map(|n| if ui(n) { format!("'{SYSTEM_UI}'") } else { n.to_string() }).collect::<Vec<_>>().join(", ")+}+/// A 2D context's text call as the SVG usvg shapes: `text` at `at` in `font` ({family, size, weight, style}), on the/// context's (textAlign, textBaseline), painted by `paint` (attributes), on a `size` document.pub(crate) fn text_doc(opt: &usvg::Options, font: &Value, text: &str, at: (f32, f32), (align, baseline): (&Value, &Value), paint: &str, (w, h): (u32, u32)) -> String {@@ -23,7 +41,7 @@ pub(crate) fn text_doc(opt: &usvg::Options, font: &Value, text: &str, at: (f32,_ => "alphabetic",};let escape = |s: &str| s.replace('&', "&").replace('<', "<");- let fam = font["family"].as_str().unwrap_or("sans-serif").replace('"', "'");+ let fam = system_ui(font["family"].as_str().unwrap_or("sans-serif"), &opt.fontdb).replace('"', "'");// a family split across files by unicode-range: each run names the file that has its glyphs (subsets.rs)let split = crate::split_families(&opt.fontdb).and_then(|s| crate::subsets::runs(&opt.fontdb, &s, &fam, text));let esc = match split {@@ -90,7 +108,7 @@ pub fn advances(opt: &usvg::Options, args: &Value) -> Value {let font = &args["font"];let weight = font["weight"].as_str().and_then(|w| w.parse().ok()).unwrap_or(400u16);let style = if font["style"].as_str() == Some("italic") { Style::Italic } else { Style::Normal };- let names: Vec<String> = font["family"].as_str().unwrap_or("sans-serif").split(',').map(|s| s.trim().trim_matches(['\'', '"']).to_string()).filter(|s| !s.is_empty()).collect();+ let names: Vec<String> = system_ui(font["family"].as_str().unwrap_or("sans-serif"), db).split(',').map(|s| s.trim().trim_matches(['\'', '"']).to_string()).filter(|s| !s.is_empty()).collect();let face_of = |name: &str| -> Option<ID> {let family = match name.to_lowercase().as_str() {"serif" => Family::Serif,@@ -138,6 +156,17 @@ pub fn advances(opt: &usvg::Options, args: &Value) -> Value {mod tests {use super::*;+ #[test]+ fn system_ui_names_are_the_system_face_where_there_is_one() {+ let list = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif";+ let mut db = usvg::fontdb::Database::new();+ assert_eq!(system_ui(list, &db), list, "no system face: the list as it was");+ db.load_font_data(std::fs::read("/System/Library/Fonts/SFNS.ttf").unwrap());+ assert_eq!(system_ui(list, &db), "-apple-system, 'System Font', \"Segoe UI\", Roboto, sans-serif");+ assert_eq!(system_ui("system-ui", &db), "'System Font'");+ assert_eq!(system_ui("-apple-system", &db), "-apple-system", "Chrome's canvas finds no face for it alone");+ }+#[test]fn advances_are_the_faces_and_say_whose() {let mut db = usvg::fontdb::Database::new();