diff --git a/crates/format/src/lib.rs b/crates/format/src/lib.rs index 6f345e11c..97caafdb3 100644 --- a/crates/format/src/lib.rs +++ b/crates/format/src/lib.rs @@ -247,6 +247,11 @@ pub fn repair(p: &mut Presentation) { if !(p.notes_size.width.is_finite() && p.notes_size.width > 0.0 && p.notes_size.height.is_finite() && p.notes_size.height > 0.0) { p.notes_size = Presentation::default().notes_size; } + // A notes page is bounded like a slide: canvas and handout drawing scale with it. + p.notes_size = deckcraft_model::Size::new( + p.notes_size.width.clamp(*SLIDE_SIDE.start(), *SLIDE_SIDE.end()), + p.notes_size.height.clamp(*SLIDE_SIDE.start(), *SLIDE_SIDE.end()), + ); sane_numbers(p); } diff --git a/crates/format/src/tests.rs b/crates/format/src/tests.rs index aa692d03f..ccda612f0 100644 --- a/crates/format/src/tests.rs +++ b/crates/format/src/tests.rs @@ -451,6 +451,13 @@ fn degenerate_slide_sizes_are_repaired() { } } +#[test] +fn repair_bounds_the_notes_page_size() { + let mut p = Presentation { notes_size: deckcraft_model::Size::new(1e12, 0.01), ..Default::default() }; + repair(&mut p); + assert_eq!((p.notes_size.width, p.notes_size.height), (4032.0, 72.0)); +} + /// A file whose slide size is null, a string or missing a side (written by hand or by /// another tool; NaN is also saved as null) opens with the default size rather than failing /// as damaged.