mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
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.
This commit is contained in:
1 parent
b8ae1cd92f
commit
72d4359999
1 file changed
+12
-6
@@ -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<String> = 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}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user