From e8c852d4906f515c0c5b0a293ecdfb3d209f943b Mon Sep 17 00:00:00 2001 From: Mikael Tollefsen Date: Mon, 19 Oct 2026 12:39:58 +0200 Subject: [PATCH] ui_shot: a {"ppp": s} line sets the window's pixels per point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Headless screenshots were always taken at 2x, so text could not be seen as it is drawn on a fractional desktop scale (e.g. 1.45 on a 4K screen at 145 %). The scale is clamped to 0.5–4; 2 stays the default. --- crates/ui-egui/examples/ui_shot.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/examples/ui_shot.rs b/crates/ui-egui/examples/ui_shot.rs index d818ed94da..c10788daf8 100644 --- a/crates/ui-egui/examples/ui_shot.rs +++ b/crates/ui-egui/examples/ui_shot.rs @@ -8,7 +8,9 @@ //! `{"steps": n}` to run extra frames, or `{"wait": ms}` to keep running frames for a while (for //! background work such as a Zotero session). The window is 1440×900 pt at 2× and opens the sample //! document unless the first line is `{"empty": true}`; `{"empty": true, "startScreen": true}` -//! starts the way the desktop app does with nothing to open (File › Home, #766). +//! starts the way the desktop app does with nothing to open (File › Home, #766). A line +//! `{"width": w}`, `{"height": h}` or `{"ppp": s}` sets the window size in points or its pixels +//! per point (e.g. 1.45 for a 145 % desktop, to see text as it is drawn there). use wordcraft_engine::Session; use wordcraft_ui_egui::{ControlRequest, Services, WordApp}; @@ -33,8 +35,9 @@ fn main() { } let w = lines.iter().find_map(|l| l.get("width").and_then(|v| v.as_f64())).unwrap_or(1440.0) as f32; let h = lines.iter().find_map(|l| l.get("height").and_then(|v| v.as_f64())).unwrap_or(900.0) as f32; + let ppp = lines.iter().find_map(|l| l.get("ppp").and_then(|v| v.as_f64())).filter(|p| (0.5..=4.0).contains(p)).unwrap_or(2.0) as f32; let mut harness = - egui_kittest::Harness::builder().with_size(egui::vec2(w, h)).with_pixels_per_point(2.0).with_max_steps(1_000_000).wgpu().build_ui_state( + egui_kittest::Harness::builder().with_size(egui::vec2(w, h)).with_pixels_per_point(ppp).with_max_steps(1_000_000).wgpu().build_ui_state( |ui, app: &mut WordApp| { if !READY.load(std::sync::atomic::Ordering::Relaxed) { return;