diff --git a/Cargo.lock b/Cargo.lock index 33c5e69..a58d5e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "canvas-pilot" -version = "0.10.0-rc.16" +version = "0.10.0-rc.17" dependencies = [ "base64 0.22.1", "craft-dwg", diff --git a/Cargo.toml b/Cargo.toml index 41c6f33..702507c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"] resolver = "3" [workspace.package] -version = "0.10.0-rc.16" +version = "0.10.0-rc.17" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot" diff --git a/crates/canvas-pilot/src/gui.rs b/crates/canvas-pilot/src/gui.rs index 0181a99..f430b85 100644 --- a/crates/canvas-pilot/src/gui.rs +++ b/crates/canvas-pilot/src/gui.rs @@ -5179,6 +5179,40 @@ mod tests { app.crop_mask_key_input(ctx, &mut input); ctx.run_ui(input, |ui| app.ui(ui)) } + + #[test] + fn extreme_camera_zoom_keeps_canvas_text_out_of_the_font_atlas() { + let ctx = egui::Context::default(); + let mut app = Editor { + zoom: 256.0, + ..Default::default() + }; + let output = frame(&mut app, &ctx, vec![]); + let text: Vec<_> = output + .shapes + .iter() + .filter_map(|shape| match &shape.shape { + egui::Shape::Text(text) => Some(text), + _ => None, + }) + .collect(); + assert!(!text.is_empty(), "ordinary UI text should still render"); + assert!(text.iter().all(|text| { + text.galley + .job + .sections + .iter() + .all(|section| section.format.font_id.size <= MAX_CANVAS_TEXT_RASTER_PIXELS) + })); + assert!(!text.iter().any(|text| { + text.galley.text() == "Ideas worth sharing." + || text + .galley + .text() + .starts_with("Illustrative reference artwork") + })); + assert_eq!(app.zoom, 256.0, "precision camera zoom remains available"); + } fn key(key: egui::Key) -> egui::Event { egui::Event::Key { key, diff --git a/crates/canvas-pilot/src/main.rs b/crates/canvas-pilot/src/main.rs index 79c6d04..832e3a8 100644 --- a/crates/canvas-pilot/src/main.rs +++ b/crates/canvas-pilot/src/main.rs @@ -64,6 +64,17 @@ struct Ink { scale: f32, } +// egui rasterizes text into one shared font texture. Camera-scaled decorative text +// must not request multi-thousand-pixel glyphs and evict/corrupt ordinary UI text. +const MAX_CANVAS_TEXT_RASTER_PIXELS: f32 = 128.0; + +fn bounded_canvas_font_size(ctx: &egui::Context, size: f32) -> Option { + (size.is_finite() + && size > 0.0 + && size * ctx.pixels_per_point() <= MAX_CANVAS_TEXT_RASTER_PIXELS) + .then_some(size) +} + impl Ink { fn new(ui: &egui::Ui, rect: Rect) -> Self { Self { @@ -96,11 +107,15 @@ impl Ink { } fn text(&self, x: f32, y: f32, text: &str, size: f32, color: Color32) { + let size = size * self.scale; + let Some(size) = bounded_canvas_font_size(self.painter.ctx(), size) else { + return; + }; self.painter.text( self.point(x, y), Align2::LEFT_TOP, text, - FontId::proportional(size * self.scale), + FontId::proportional(size), color, ); } @@ -154,13 +169,15 @@ fn screen_labels(ink: &Ink, output: [u32; 2]) { 12.0 * k, palette.muted, ); - ink.painter.text( - ink.point(width, -SCREEN_LABEL_TOP * k), - Align2::RIGHT_TOP, - format!("{} × {} px", output[0], output[1]), - FontId::proportional(13.0 * k * ink.scale), - palette.muted, - ); + if let Some(size) = bounded_canvas_font_size(ink.painter.ctx(), 13.0 * k * ink.scale) { + ink.painter.text( + ink.point(width, -SCREEN_LABEL_TOP * k), + Align2::RIGHT_TOP, + format!("{} × {} px", output[0], output[1]), + FontId::proportional(size), + palette.muted, + ); + } } fn screen_artwork(ink: &Ink, title: &str, output: [u32; 2]) { @@ -203,10 +220,13 @@ fn screen_reference_hint(ink: &Ink, output: [u32; 2]) { .painter .with_clip_rect(ink.painter.clip_rect().intersect(rect)); let color = theme::palette(ink.painter.ctx()).muted; + let Some(font_size) = bounded_canvas_font_size(ink.painter.ctx(), 12.0 * ink.scale) else { + return; + }; let text = painter.layout( "Illustrative reference artwork · Drag & drop an image or use Import > Reference image…" .into(), - FontId::proportional(12.0 * ink.scale), + FontId::proportional(font_size), color, (size.x - 48.0).max(1.0) * ink.scale, ); diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index 37e17e5..ec7fb26 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,13 @@ ## Unreleased +### v0.10.0-rc.17 + +- Keep extreme scroll zoom responsive by omitting camera-scaled decorative canvas + text before it would request oversized glyphs from egui's shared font atlas. + Layer geometry, fixed-size layer labels, pixel guides and the existing 256× camera + range remain available for precise placement. + ## v0.10.0-rc.16 — 2026-11-19 Published release candidate collecting the crop, preview, input adaptation and diff --git a/docs/canvas-pilot/guide/formats-and-crop.md b/docs/canvas-pilot/guide/formats-and-crop.md index 4d9b7a9..9831826 100644 --- a/docs/canvas-pilot/guide/formats-and-crop.md +++ b/docs/canvas-pilot/guide/formats-and-crop.md @@ -16,6 +16,10 @@ Valid output presets and numeric resolution edits apply immediately; invalid dra leave the output unchanged and are retained for correction. The same window offers numeric camera zoom relative to fit-to-screen and a **1:1 display pixels** action; camera changes never modify crop geometry. +Scroll zoom and the Zoom tool retain the full precision camera range. At extreme +zoom, decorative screen titles and reference-hint text are hidden before their +camera-scaled glyphs would slow the renderer; layers, handles, fixed-size layer +labels, pixel guides and placement remain visible and editable. Select one layer and click its **Layer resolution** card to open **Layer properties**: