Honour declared paper size in route-D output
This commit is contained in:
1 parent
043ae7f072
commit
7b9d543e49
7 files changed
+142
-33
No files matched your search
@@ -566,6 +566,12 @@ fn default_insertion_multiplier() -> u32 {
|
||||
pub struct Document {
|
||||
pub units: Vec<Unit>,
|
||||
pub page_goal: i64,
|
||||
/// TeX `\paperwidth`: width of the output page.
|
||||
#[serde(default = "default_paper_width")]
|
||||
pub paper_width: i64,
|
||||
/// TeX `\paperheight`: height of the output page.
|
||||
#[serde(default = "default_paper_height")]
|
||||
pub paper_height: i64,
|
||||
/// TeX-like `\topskip`: distance from the page top to the first baseline.
|
||||
#[serde(default)]
|
||||
pub top_skip: i64,
|
||||
@@ -630,6 +636,14 @@ pub struct Document {
|
||||
pub output_routine: Option<String>,
|
||||
}
|
||||
|
||||
fn default_paper_width() -> i64 {
|
||||
612 * 65_536
|
||||
}
|
||||
|
||||
fn default_paper_height() -> i64 {
|
||||
792 * 65_536
|
||||
}
|
||||
|
||||
fn default_text_fraction() -> u8 {
|
||||
50
|
||||
}
|
||||
@@ -671,6 +685,8 @@ impl Document {
|
||||
Self {
|
||||
units,
|
||||
page_goal,
|
||||
paper_width: default_paper_width(),
|
||||
paper_height: default_paper_height(),
|
||||
top_skip: 0,
|
||||
max_depth: 0,
|
||||
text_fraction_percent: default_text_fraction(),
|
||||
@@ -2401,6 +2417,13 @@ impl Engine {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn documents_default_to_letter_paper() {
|
||||
let document = Document::new(100, Vec::new());
|
||||
assert_eq!(document.paper_width, 612 * 65_536);
|
||||
assert_eq!(document.paper_height, 792 * 65_536);
|
||||
}
|
||||
|
||||
fn document() -> Document {
|
||||
Document::new(
|
||||
50,
|
||||
|
||||
Reference in new issue
Block a user