From 48955694765b65363ffd513122e9d5f7fabd0ef9 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 21 Oct 2026 21:45:28 +0100 Subject: [PATCH] M2: review of #1567: the viewer-wiring test no longer skips when the wiring is lost CodeRabbit: the engine test skipped when the viewer's render was blank, so a viewer pool that lost the installed-font fallback would have skipped instead of failing. Whether this machine has a face that can draw the page is now asked of a renderer with RenderConfig::system_fonts switched on by hand, and the viewer's render must then draw it. Without the fallback on the viewer's pool the test fails. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tests.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 5e6ef3b301..867afc8a07 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -425,10 +425,16 @@ trailer << /Root 1 0 R >> std::thread::yield_now(); }; let inked = |rgba: &[u8]| rgba.as_chunks::<4>().0.iter().filter(|c| c[0] < 128).count(); - if inked(&viewer.rgba) < 300 { + // Whether this machine has a face that can draw the page at all, asked of a renderer with the + // fallback switched on by hand, so a viewer pool that lost it fails below instead of skipping. + let probe = pdfcraft_render::PageRenderer::new(doc.display.clone(), pdfcraft_render::RenderConfig { system_fonts: true, ..Default::default() }) + .render(pdfcraft_render::RenderRequest { page: 0, scale: 1.0, ..Default::default() }); + assert!(probe.error.is_none(), "{:?}", probe.error); + if inked(&probe.rgba) < 300 { eprintln!("no installed Traditional Chinese face (or PDFCRAFT_SYSTEM_FONTS=0): skipped"); return; } + assert!(inked(&viewer.rgba) > 300, "the viewer's pool draws it with the installed face ({} dark pixels)", inked(&viewer.rgba)); let png = export::Exporter::new(doc).png(0, 72.0).unwrap(); let exported = image::load_from_memory(&png).unwrap().into_rgba8(); assert!(inked(exported.as_raw()) < 50, "an export draws nothing with an installed font ({} dark pixels)", inked(exported.as_raw()));