fix(pdf): a line landing exactly on the text floor stays on its page
FLOOR_EPSILON on the ensure_room test; four-long keeps its last line on page 1. wasm gzip (size test) 596738 B.
This commit is contained in:
1 parent
cca2195f04
commit
a1c2aefbba
2 files changed
+13
-1
No files matched your search
@@ -157,10 +157,14 @@ struct PageHead<'h> {
|
|||||||
severity: Option<Severity>,
|
severity: Option<Severity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The fit branch of `row_budget` sizes the images so the last line lands exactly on the floor;
|
||||||
|
/// float accumulation must not push it onto a new page (the census keeps a 1 pt clearance anyway).
|
||||||
|
const FLOOR_EPSILON: f64 = 1e-6;
|
||||||
|
|
||||||
/// Opens a continuation page when a line with `below` points of text under its baseline would
|
/// Opens a continuation page when a line with `below` points of text under its baseline would
|
||||||
/// go under the floor: never into the footer, never off the page (R2).
|
/// go under the floor: never into the footer, never off the page (R2).
|
||||||
fn ensure_room(layout: &mut Layout<'_>, cursor: &mut Cursor, head: &PageHead<'_>, below: f64) {
|
fn ensure_room(layout: &mut Layout<'_>, cursor: &mut Cursor, head: &PageHead<'_>, below: f64) {
|
||||||
if cursor.y - below >= TEXT_FLOOR_Y {
|
if cursor.y - below >= TEXT_FLOOR_Y - FLOOR_EPSILON {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let page = layout.log.add_page();
|
let page = layout.log.add_page();
|
||||||
|
|||||||
@@ -774,6 +774,14 @@ fn every_reference_case_passes_the_census() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn four_long_keeps_its_last_line_on_the_floor_of_the_first_page() {
|
||||||
|
let drawn = draw(&reference_case("four-long"));
|
||||||
|
// One observation page and the conclusion.
|
||||||
|
assert_eq!(drawn.pages.len(), 2);
|
||||||
|
assert_clean(&drawn);
|
||||||
|
}
|
||||||
|
|
||||||
fn color(c: &faunosteo_core::pdf::write::draw_log::Rgb) -> Value {
|
fn color(c: &faunosteo_core::pdf::write::draw_log::Rgb) -> Value {
|
||||||
json!({ "type": "RGB", "red": c.red, "green": c.green, "blue": c.blue })
|
json!({ "type": "RGB", "red": c.red, "green": c.green, "blue": c.blue })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user