From 72d43599998cc1017db891bd21b2ba4994ad653b Mon Sep 17 00:00:00 2001 From: Zach Schneider Date: Wed, 14 Oct 2026 12:05:26 -0500 Subject: [PATCH] Font preview test: skip installed fonts whose Arabic glyphs are blank (#5259) (#5261) a_system_arabic_face_renders_both_samples took the first family whose character map claims Latin and Arabic and expected its Arabic sample to render. A font can map those characters to empty glyphs (for example Black Mountain), so cargo test failed on machines that have one installed. The test now renders every candidate and checks the first one that actually draws an Arabic sample, and skips only if none does. --- crates/ui-egui/src/font_preview.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/font_preview.rs b/crates/ui-egui/src/font_preview.rs index 74c334d6827..678da4191cc 100644 --- a/crates/ui-egui/src/font_preview.rs +++ b/crates/ui-egui/src/font_preview.rs @@ -244,14 +244,20 @@ mod tests { fn a_system_arabic_face_renders_both_samples() { let mut engine = photocraft_text::TextEngine::new(); engine.fonts.load_system_fonts(); - let both = engine.fonts.families().into_iter().find(|f| sample_texts(&engine.fonts.charmap(f, 400, false)).1.is_some()); - let Some(family) = both else { - eprintln!("skipped: no installed family covers both Latin and Arabic"); + let candidates: Vec = engine.fonts.families().into_iter().filter(|f| sample_texts(&engine.fonts.charmap(f, 400, false)).1.is_some()).collect(); + // A face can map the Arabic characters to blank glyphs (#5259): `render` then rightly gives + // no sample, so every candidate is rendered and the first one with an Arabic sample is checked. + let mut rendered = None; + for family in &candidates { + if let Some(arabic) = images(&mut engine, family, 1, MEDIUM).and_then(|i| i.arabic) { + rendered.get_or_insert((family.clone(), arabic)); + } + } + let Some((family, arabic)) = rendered else { + eprintln!("skipped: no installed family renders both Latin and Arabic ({} claim both)", candidates.len()); return; }; - let images = images(&mut engine, &family, 1, MEDIUM).expect(&family); - let arabic = images.arabic.expect("Arabic sample"); - assert_eq!(arabic.size, [ARABIC_WIDTH as usize, HEIGHT as usize]); + assert_eq!(arabic.size, [ARABIC_WIDTH as usize, HEIGHT as usize], "{family}"); assert!(arabic.pixels.iter().any(|p| p.a() > 0), "{family}"); } }