summaryrefslogtreecommitdiff
path: root/library/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-04-25 16:09:10 +0200
committerLaurenz <laurmaedje@gmail.com>2023-04-25 16:09:10 +0200
commit946756bc5370431e07d0e8fd1ab28a72c9800419 (patch)
tree65e8aeeee22560e5149185e4a6dc59e54c33f4c8 /library/src/layout
parent62361b4127c39fc1b165b81f24f52b14ddaa41db (diff)
A small comment regarding page layout
Diffstat (limited to 'library/src/layout')
-rw-r--r--library/src/layout/page.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs
index 7fa0bc5e..38da7878 100644
--- a/library/src/layout/page.rs
+++ b/library/src/layout/page.rs
@@ -271,9 +271,19 @@ pub struct PageElem {
}
impl PageElem {
- /// Layout the page run into a sequence of frames, one per page.
+ /// A document can consist of multiple `PageElem`s, one per run of pages
+ /// with equal properties (not one per actual output page!). The `number` is
+ /// the physical page number of the first page of this run. It is mutated
+ /// while we post-process the pages in this function. This function returns
+ /// a fragment consisting of multiple frames, one per output page of this
+ /// page run.
#[tracing::instrument(skip_all)]
- pub fn layout(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Fragment> {
+ pub fn layout(
+ &self,
+ vt: &mut Vt,
+ styles: StyleChain,
+ mut number: NonZeroUsize,
+ ) -> SourceResult<Fragment> {
tracing::info!("Page layout");
// When one of the lengths is infinite the page fits its content along
@@ -333,8 +343,8 @@ impl PageElem {
);
// Realize overlays.
- for (i, frame) in fragment.iter_mut().enumerate() {
- tracing::info!("Layouting page #{i}");
+ for frame in fragment.iter_mut() {
+ tracing::info!("Layouting page #{number}");
frame.prepend(Point::zero(), numbering_meta.clone());
let size = frame.size();
let pad = padding.resolve(styles).relative_to(size);
@@ -382,6 +392,8 @@ impl PageElem {
if let Some(fill) = &fill {
frame.fill(fill.clone());
}
+
+ number = number.saturating_add(1);
}
Ok(fragment)