From c6c2c7d0fec56a6f9e67ea59096efcdb4ad3799b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Wed, 7 Oct 2026 07:17:36 +0700 Subject: [PATCH] Tests: the font resolution test no longer depends on the installed fonts list_says_how_each_font_resolved expected Source Sans 3 Black to be a substitute, which holds only while the bundled family is the only Source Sans 3: on a machine with the full family installed (it ships with many font packs), Black resolves exactly and the test failed. It now asks for a style no Source Sans 3 has, so the substitute path is tested anywhere. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/fonts.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/fonts.rs b/crates/engine/src/cmd/fonts.rs index 4b98f619..fc15d370 100644 --- a/crates/engine/src/cmd/fonts.rs +++ b/crates/engine/src/cmd/fonts.rs @@ -277,8 +277,10 @@ mod open_tests { fn list_says_how_each_font_resolved() { let mut s = Session::new(); s.execute("file.new", &json!({"width": 200, "height": 200})).unwrap(); + // "Black Wide" is a style no Source Sans 3 has, bundled or installed, so it is always a + // substitute (the installed family can hold a real Black). for (text, font, style) in - [("Exact", "Source Sans 3", "Semibold"), ("Closest", "Source Sans 3", "Black"), ("Gone", "No Such Font Family", "Regular")] + [("Exact", "Source Sans 3", "Semibold"), ("Closest", "Source Sans 3", "Black Wide"), ("Gone", "No Such Font Family", "Regular")] { s.execute("text.create", &json!({"x": 10, "y": 20, "text": text, "font": font, "style": style})).unwrap(); } @@ -298,8 +300,8 @@ mod open_tests { .collect(); let row = |style: &str| rows.iter().find(|r| r.0 == style).cloned().unwrap(); assert_eq!(row("Semibold").1, "exact"); - assert_eq!(row("Black").1, "substitute", "{rows:?}"); - assert_eq!(row("Black").2, "Source Sans 3"); + assert_eq!(row("Black Wide").1, "substitute", "{rows:?}"); + assert_eq!(row("Black Wide").2, "Source Sans 3"); assert_eq!((row("Regular").1.as_str(), row("Regular").2.as_str()), ("missing", vectorcraft_text::FALLBACK_FAMILY)); s.execute("text.create", &json!({"x": 10, "y": 90, "text": "Ab 雅楽", "font": "Inter"})).unwrap(); let inter = s.execute("text.fonts", &json!({})).unwrap().as_array().unwrap().iter().find(|f| f["family"] == "Inter").cloned().unwrap();