diff --git a/crates/core/src/pdf/write/views.rs b/crates/core/src/pdf/write/views.rs index 35fac32b..a70a0b3c 100644 --- a/crates/core/src/pdf/write/views.rs +++ b/crates/core/src/pdf/write/views.rs @@ -87,7 +87,9 @@ pub fn raster_size_of(view_box: Option<&str>) -> (u32, u32) { /// The raster size of a view (owner 2026-11-22, A5): the frame's ratio to half a pixel for /// every ratio, so `meet` shows nothing outside the frame (R2). The short side is rounded first /// and the long side follows from it; never more pixels than 1 200 x 2 400. From 1:1 to 1:2 -/// that is `raster_size_of`, whose rounding already holds the bound. Logos keep +/// that is `raster_size_of`, whose rounding already holds the bound. The 0.25 px bound holds +/// for frames up to 100:1 either way (the core's MAX_FRAME_ASPECT, which no view frame +/// exceeds); beyond about 1:1200 the 1 px minimum side would break it. Logos keep /// `raster_size_of`. pub fn view_raster_size(view_box: Option<&str>) -> (u32, u32) { let aspect = aspect_of(view_box); diff --git a/crates/core/tests/pdf_proportions.rs b/crates/core/tests/pdf_proportions.rs index b0b75e71..27f22f00 100644 --- a/crates/core/tests/pdf_proportions.rs +++ b/crates/core/tests/pdf_proportions.rs @@ -80,15 +80,30 @@ fn the_board_frames_get_their_sizes() { } /// For the owner's report (A5: « contrôler les éventuelles différences »): the O4 inputs whose -/// view size differs from the logo rule, printed; none of them is a historical view. +/// view size differs from the logo rule, printed and pinned. None is a historical view (main +/// and head are pinned in `the_historical_views_keep_their_sizes`). #[test] fn the_o4_inputs_where_views_differ_from_logos_are_listed() { let (_, oracle) = common::oracle_file("r4/text.json"); + let mut differing = Vec::new(); for case in oracle["rasterSizeOf"]["cases"].as_array().unwrap() { let input = case[0].as_str(); let (view, logo) = (view_raster_size(input), raster_size_of(input)); if view != logo { println!("O4 {input:?}: logo {logo:?}, view {view:?}"); + differing.push((input.unwrap().to_string(), view, logo)); } } + let expected = [ + ("0 0 100 1000", (240, 2400), (1200, 2400)), + ("0 0 1000 1", (1000, 1), (1200, 240)), + ("0 0 5e-324 1", (1, 2400), (1200, 2400)), + ("0 0 0b11 0o7", (1029, 2400), (1200, 2400)), + ("0 0 7 3", (1199, 514), (1200, 514)), + ]; + let expected: Vec<_> = expected + .iter() + .map(|(input, view, logo)| (input.to_string(), *view, *logo)) + .collect(); + assert_eq!(differing, expected); }