From 31b653b70fb31e77e0e7260ab0e875c572b14266 Mon Sep 17 00:00:00 2001 From: Drew Dibble Date: Sat, 24 Oct 2026 10:27:54 -0600 Subject: [PATCH] Renderer tests: the Arabic alternate-glyph tests take the font lock `tests_alternate`'s Arabic tests look up installed fonts by name (`FontDb::face`), which loads each one into the global database and so changes its generation, without `tests_fontchange::adding_fonts()`. When that lands in the first frame of `tests_charstroke::character_stroke_outlines_are_kept_between_frames`, the second frame lays the type out again and expands the stroke again, and the test fails (3 runs in 30 on macOS, where Arial and Geeza Pro are installed; where no Arabic font is, those tests return early and nothing changes). They now hold the lock, and its documentation says looking up an installed font counts as changing the fonts. Co-Authored-By: Claude Opus 5.5 --- crates/render/src/tests_alternate.rs | 6 ++++++ crates/render/src/tests_fontchange.rs | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/render/src/tests_alternate.rs b/crates/render/src/tests_alternate.rs index 87b491bf0..2438be8be 100644 --- a/crates/render/src/tests_alternate.rs +++ b/crates/render/src/tests_alternate.rs @@ -80,6 +80,8 @@ fn glyphs(t: &vectorcraft_doc::text::TextObject) -> Vec<(usize, usize, u32)> { /// required shaping, not alternates, so ordinary Arabic text shows no pink. #[test] fn arabic_joining_forms_are_not_alternates() { + // Looking up an installed font loads it, which changes the fonts. + let _adding = crate::tests_fontchange::adding_fonts(); let Some(style) = arabic_style("arabic_joining_forms_are_not_alternates") else { return }; let t = text("خلطة مبتكرة من اللومي الحساوي", style); // The words are shaped: most glyphs are not their letter's cmap glyph. @@ -90,6 +92,8 @@ fn arabic_joining_forms_are_not_alternates() { /// #394: the lam-alef ligature is required (`rlig`), so it isn't highlighted either. #[test] fn lam_alef_is_not_an_alternate() { + // Looking up an installed font loads it, which changes the fonts. + let _adding = crate::tests_fontchange::adding_fonts(); let Some(style) = arabic_style("lam_alef_is_not_an_alternate") else { return }; for s in ["لا", "سلام", "الاسم"] { assert_eq!(alternates(&text(s, style.clone())), 0, "{s}"); @@ -100,6 +104,8 @@ fn lam_alef_is_not_an_alternate() { /// discretionary alternate…) is highlighted on the glyphs it changes, and only on those. #[test] fn optional_features_on_arabic_flag_only_the_glyphs_they_change() { + // Looking up an installed font loads it, which changes the fonts. + let _adding = crate::tests_fontchange::adding_fonts(); let db = vectorcraft_text::FontDb::global(); let s = "خلطة مبتكرة من اللومي الحساوي"; // Arabic fonts that may have optional features; the first installed one with a feature that diff --git a/crates/render/src/tests_fontchange.rs b/crates/render/src/tests_fontchange.rs index 3d8e158ea..5b23eb959 100644 --- a/crates/render/src/tests_fontchange.rs +++ b/crates/render/src/tests_fontchange.rs @@ -9,8 +9,10 @@ use vectorcraft_geom::Point; use super::*; -/// Taken to add fonts. Renderers lay type out again when the fonts change, so tests of what they -/// keep between frames hold it shared ([`fonts_steady`]) and the tests here hold it alone. +/// Taken to add fonts, or to look up an installed one by name (`FontDb::face` loads it, which +/// changes the fonts too). Renderers lay type out again when the fonts change, so tests of what +/// they keep between frames hold it shared ([`fonts_steady`]) and the tests that change the fonts +/// hold it alone ([`adding_fonts`]). static FONTS: RwLock<()> = RwLock::new(()); /// No fonts are added by these tests until the guard is dropped.