Save the TeX cursor in native shipout order

This commit is contained in:
gloamxun committed 2026-11-21 04:27:06 +08:00
1 parent 555a029505
commit 413939911f
12 files changed
+173 -28

No files matched your search

+58
View File
@@ -181,3 +181,61 @@ fn initex_page_parameters_are_not_seeded_from_the_pdf_driver() {
);
fs::remove_dir_all(p).unwrap();
}
#[test]
fn saved_pdf_position_is_observed_in_shipout_order() {
let work = directory();
let source = r"\catcode123=1 \catcode125=2
\pdfoutput=1 \pdfpageheight=100pt \pdfhorigin=10pt \pdfvorigin=12pt
\immediate\openout5=positions.dat
\setbox5=\hbox{\kern32pt\pdfsavepos}
\immediate\write5{\the\pdflastxpos,\the\pdflastypos}
\shipout\hbox to40pt{\vrule width8pt height9pt
\hskip 2pt plus1fil \pdfsavepos\write5{\the\pdflastxpos,\the\pdflastypos}
\hbox{\kern3pt\pdfsavepos\write5{\the\pdflastxpos,\the\pdflastypos}}
\kern7pt}
\immediate\write5{\the\pdflastxpos,\the\pdflastypos}
\immediate\closeout5
\end";
fs::write(work.join("probe.tex"), source).unwrap();
let output = native_fonts::command()
.args([
"native",
"--job",
"--initex",
"--etex",
"probe.tex",
"native.pdf",
])
.current_dir(&work)
.output()
.unwrap();
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
let native = fs::read(work.join("positions.dat")).unwrap();
let output = Command::new("pdftex")
.args([
"-ini",
"-etex",
"-interaction=nonstopmode",
"-halt-on-error",
"probe.tex",
])
.current_dir(&work)
.output()
.unwrap();
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stdout)
);
assert_eq!(native, fs::read(work.join("positions.dat")).unwrap());
assert_eq!(
native,
b"0,0\n2621440,5177344\n2818048,5177344\n2818048,5177344\n"
);
fs::remove_dir_all(work).unwrap();
}