Handle legacy XeTeX paper and landscape specials
This commit is contained in:
1 parent
d944552188
commit
7ff988031f
5 files changed
+274
-55
No files matched your search
+73
-20
@@ -139,6 +139,64 @@ fn illegal_or_incompatible_magnification_and_huge_pages_protect_existing_pdf() {
|
||||
|
||||
#[test]
|
||||
fn xdv_page_setup_edit_updates_the_local_sheet_and_inherited_origin() {
|
||||
let prefix = r"\catcode123=1 \catcode125=2
|
||||
\pdfpagewidth=11182899sp \pdfpageheight=16445440sp
|
||||
\shipout\hbox{\special{pdf:pagesize width 170bp height 250bp xoffset 24bp}\vrule width10pt height4pt}
|
||||
";
|
||||
let tail = r"\input sheet.tex
|
||||
\shipout\hbox{\sheet\vrule width10pt height4pt}
|
||||
\shipout\hbox{\vrule width10pt height4pt}
|
||||
\shipout\hbox{\special{pdf:pagesize default}\vrule width10pt height4pt}
|
||||
\end
|
||||
";
|
||||
check_xdv_paper_revisions(
|
||||
prefix,
|
||||
tail,
|
||||
[
|
||||
"pdf:pagesize width 190bp xoffset 36bp",
|
||||
"pdf:pagesize width 205bp xoffset 46bp",
|
||||
],
|
||||
&[[170, 250], [205, 250], [170, 250], [170, 250]],
|
||||
&[1, 2],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xdv_legacy_paper_edit_propagates_until_the_next_document_default() {
|
||||
let prefix = r"\catcode123=1 \catcode125=2
|
||||
\shipout\hbox{\special{papersize=200bp,300bp}\vrule width10pt height4pt}
|
||||
";
|
||||
let tail = r"\input sheet.tex
|
||||
\shipout\hbox{\sheet\vrule width10pt height4pt}
|
||||
\shipout\hbox{\vrule width10pt height4pt}
|
||||
\shipout\hbox{\special{landscape}\vrule width10pt height4pt}
|
||||
\shipout\hbox{\special{landscape}\vrule width10pt height4pt}
|
||||
\shipout\hbox{\special{papersize=200bp,300bp}\vrule width10pt height4pt}
|
||||
\end
|
||||
";
|
||||
check_xdv_paper_revisions(
|
||||
prefix,
|
||||
tail,
|
||||
["papersize=160bp,230bp", "papersize=165bp,240bp"],
|
||||
&[
|
||||
[200, 300],
|
||||
[165, 240],
|
||||
[165, 240],
|
||||
[240, 165],
|
||||
[165, 240],
|
||||
[200, 300],
|
||||
],
|
||||
&[1, 2, 3, 4],
|
||||
);
|
||||
}
|
||||
|
||||
fn check_xdv_paper_revisions(
|
||||
prefix: &str,
|
||||
tail: &str,
|
||||
specials: [&str; 2],
|
||||
expected_sizes: &[[i32; 2]],
|
||||
expected_delta: &[usize],
|
||||
) {
|
||||
use std::sync::Arc;
|
||||
use texrra_engine::native::{
|
||||
CompileRequest, Entry, NativeCompiler, ProjectDefinition, ProjectSnapshot,
|
||||
@@ -151,19 +209,9 @@ fn xdv_page_setup_edit_updates_the_local_sheet_and_inherited_origin() {
|
||||
let root = directory().canonicalize().unwrap();
|
||||
let entry = root.join("probe.tex");
|
||||
let sheet = root.join("sheet.tex");
|
||||
let prefix = r"\catcode123=1 \catcode125=2
|
||||
\pdfpagewidth=11182899sp \pdfpageheight=16445440sp
|
||||
\shipout\hbox{\special{pdf:pagesize width 170bp height 250bp xoffset 24bp}\vrule width10pt height4pt}
|
||||
";
|
||||
let padding = format!("{}\n", "\\relax ".repeat(32)).repeat(48);
|
||||
let tail = r"\input sheet.tex
|
||||
\shipout\hbox{\sheet\vrule width10pt height4pt}
|
||||
\shipout\hbox{\vrule width10pt height4pt}
|
||||
\shipout\hbox{\special{pdf:pagesize default}\vrule width10pt height4pt}
|
||||
\end
|
||||
";
|
||||
let from_sheet = |width, x| -> Arc<[u8]> {
|
||||
format!("\\def\\sheet{{\\special{{pdf:pagesize width {width}bp xoffset {x}bp}}}}\n")
|
||||
let sheet_source = |text: &str| -> Arc<[u8]> {
|
||||
format!("\\def\\sheet{{\\special{{{text}}}}}\n")
|
||||
.into_bytes()
|
||||
.into()
|
||||
};
|
||||
@@ -177,7 +225,7 @@ fn xdv_page_setup_edit_updates_the_local_sheet_and_inherited_origin() {
|
||||
entry.clone(),
|
||||
format!("{prefix}{padding}{tail}").into_bytes().into(),
|
||||
),
|
||||
(sheet.clone(), from_sheet(190, 36)),
|
||||
(sheet.clone(), sheet_source(specials[0])),
|
||||
]
|
||||
.into(),
|
||||
directories: Default::default(),
|
||||
@@ -196,19 +244,24 @@ fn xdv_page_setup_edit_updates_the_local_sheet_and_inherited_origin() {
|
||||
.compile(request.clone().with_project(snapshot.clone()))
|
||||
.unwrap();
|
||||
let updated = snapshot
|
||||
.with_file_edits(2, [(sheet, from_sheet(205, 46))].into())
|
||||
.with_file_edits(2, [(sheet, sheet_source(specials[1]))].into())
|
||||
.unwrap();
|
||||
let revised = request.with_project(updated);
|
||||
let next = compiler.compile(revised.clone()).unwrap();
|
||||
assert!(next.entry_checkpoint_work.reused_steps > 0);
|
||||
let widths: Vec<_> = next.pages.iter().map(|page| page.width).collect();
|
||||
assert_eq!(
|
||||
widths,
|
||||
[170, 205, 170, 170].map(|bp| (f64::from(bp) * 65_781.76).round() as i64)
|
||||
);
|
||||
let sizes: Vec<_> = next
|
||||
.pages
|
||||
.iter()
|
||||
.map(|page| [page.width, page.height])
|
||||
.collect();
|
||||
let expected: Vec<_> = expected_sizes
|
||||
.iter()
|
||||
.map(|size| size.map(|bp| (f64::from(bp) * 65_781.76).round() as i64))
|
||||
.collect();
|
||||
assert_eq!(sizes, expected);
|
||||
let delta = next.preview_since(Some(first.revision())).unwrap();
|
||||
let changed: Vec<_> = delta.pages.iter().map(|page| page.index).collect();
|
||||
assert_eq!(changed, [1, 2]);
|
||||
assert_eq!(changed, expected_delta);
|
||||
|
||||
let full = NativeCompiler::default().compile(revised).unwrap();
|
||||
assert_eq!(next.pdf, full.pdf);
|
||||
|
||||
Reference in new issue
Block a user