Expose page stretch and shrink to the output routine
This commit is contained in:
1 parent
62d3c4154e
commit
ca36c94eb3
5 files changed
+69
-6
No files matched your search
@@ -3,7 +3,8 @@
|
||||
//! Only the subset that decides *which* page box leaves the page builder is
|
||||
//! supported today: `\shipout\box255`, `\relax`, `\message{...}` and
|
||||
//! `\ifdim` comparisons over the page registers `\pagegoal`, `\pagetotal`,
|
||||
//! `\pagedepth`, `\vsize`, `\topskip` and `\maxdepth`. Anything else is a parse error, which
|
||||
//! `\pagedepth`, `\pagestretch`, `\pageshrink`, `\vsize`, `\topskip` and
|
||||
//! `\maxdepth`. Anything else is a parse error, which
|
||||
//! makes `Engine::layout_paged` fall back to the scrolling builder.
|
||||
|
||||
use std::fmt;
|
||||
@@ -17,6 +18,10 @@ pub struct OutputContext {
|
||||
pub page_total: i64,
|
||||
/// TeX `\pagedepth`: the depth of the page box so far.
|
||||
pub page_depth: i64,
|
||||
/// TeX `\pagestretch`: stretch of the vertical glue so far.
|
||||
pub page_stretch: i64,
|
||||
/// TeX `\pageshrink`: shrink of the vertical glue so far.
|
||||
pub page_shrink: i64,
|
||||
/// TeX `\vsize`: the configured page height.
|
||||
pub vsize: i64,
|
||||
/// TeX `\topskip`.
|
||||
@@ -99,6 +104,8 @@ enum Register {
|
||||
PageGoal,
|
||||
PageTotal,
|
||||
PageDepth,
|
||||
PageStretch,
|
||||
PageShrink,
|
||||
Vsize,
|
||||
TopSkip,
|
||||
MaxDepth,
|
||||
@@ -112,6 +119,8 @@ impl Dimension {
|
||||
Register::PageGoal => context.page_goal,
|
||||
Register::PageTotal => context.page_total,
|
||||
Register::PageDepth => context.page_depth,
|
||||
Register::PageStretch => context.page_stretch,
|
||||
Register::PageShrink => context.page_shrink,
|
||||
Register::Vsize => context.vsize,
|
||||
Register::TopSkip => context.top_skip,
|
||||
Register::MaxDepth => context.max_depth,
|
||||
@@ -478,6 +487,8 @@ fn parse_dimension(tokens: &[Token], index: &mut usize) -> Result<Dimension, Str
|
||||
"pagegoal" => Register::PageGoal,
|
||||
"pagetotal" => Register::PageTotal,
|
||||
"pagedepth" => Register::PageDepth,
|
||||
"pagestretch" => Register::PageStretch,
|
||||
"pageshrink" => Register::PageShrink,
|
||||
"vsize" => Register::Vsize,
|
||||
"topskip" => Register::TopSkip,
|
||||
"maxdepth" => Register::MaxDepth,
|
||||
@@ -566,6 +577,8 @@ mod tests {
|
||||
page_goal: 612 * 65_536,
|
||||
page_total,
|
||||
page_depth: 0,
|
||||
page_stretch: 0,
|
||||
page_shrink: 0,
|
||||
vsize: 612 * 65_536,
|
||||
top_skip: 10 * 65_536,
|
||||
max_depth: 0,
|
||||
@@ -581,6 +594,21 @@ mod tests {
|
||||
assert_eq!(program.shipout_count(&context(0)).unwrap(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_stretch_and_shrink_are_visible() {
|
||||
let program = OutputProgram::parse(r"\ifdim\pagestretch>9pt\shipout\box255\fi").unwrap();
|
||||
let mut stretched = context(0);
|
||||
stretched.page_stretch = 10 * 65_536;
|
||||
assert_eq!(program.shipout_count(&stretched).unwrap(), 1);
|
||||
assert_eq!(program.shipout_count(&context(0)).unwrap(), 0);
|
||||
|
||||
let shrink = OutputProgram::parse(r"\ifdim\pageshrink>9pt\shipout\box255\fi").unwrap();
|
||||
let mut shrunk = context(0);
|
||||
shrunk.page_shrink = 10 * 65_536;
|
||||
assert_eq!(shrink.shipout_count(&shrunk).unwrap(), 1);
|
||||
assert_eq!(shrink.shipout_count(&context(0)).unwrap(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_depth_register_is_visible() {
|
||||
let program = OutputProgram::parse(r"\ifdim\pagedepth>4pt\shipout\box255\fi").unwrap();
|
||||
|
||||
Reference in new issue
Block a user