mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-18 00:15:44 +00:00
ui_shot: a {"ppp": s} line sets the window's pixels per point
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.
This commit is contained in:
1 parent
7a3c3b40af
commit
e8c852d490
1 file changed
+5
-2
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user