Honor pdfTeX character program tags and qualify PLOS ONE

This commit is contained in:
gloamxun committed 2026-11-29 06:26:35 +08:00
1 parent 84ad682939
commit a1585339b9
21 files changed
+308 -28

No files matched your search

@@ -91,6 +91,56 @@ fn compare(p: &std::path::Path, source: &str, labels: &[String]) -> Execution {
eprintln!("{} exact native boxes matched real INITEX", labels.len());
e
}
#[test]
fn pdfnoligatures_clears_character_programs_and_keeps_the_left_boundary() {
let p = directory();
fs::write(
p.join("switch.tfm"),
font(
&[
(Some(b'A'), b'B', Op::Lig(0, b'C')),
(Some(b'D'), b'E', Op::Kern(-12345)),
(None, b'F', Op::Lig(0, b'G')),
(Some(b'G'), 255, Op::Lig(0, b'H')),
],
Some(255),
),
)
.unwrap();
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
fs::copy(root.join("assets/cmex10.tfm"), p.join("cmex10.tfm")).unwrap();
let source = format!(
r"{SETUP}
\font\F=switch \font\same=switch \font\size=switch at 11pt \font\ext=cmex10
\message{{BEFORE=\the\pdfnoligatures\F,\the\pdfnoligatures\nullfont,\the\pdfnoligatures\ext}}
\setbox0=\hbox{{\F AB DE F}}\showbox0
\setbox0=\hbox{{\size AB DE F}}\showbox0
{{\tagcode\F65=-1}}\tagcode\F68=1
\message{{SELECTIVE=\the\tagcode\same65,\the\tagcode\same68,\the\tagcode\size65,\the\tagcode\same0}}
\setbox0=\hbox{{\same AB DE F}}\showbox0
{{\pdfnoligatures\F}}\pdfnoligatures\ext
\message{{AFTER=\the\pdfnoligatures\same,\the\pdfnoligatures\size,\the\pdfnoligatures\ext}}
\message{{EXT=\the\tagcode\ext0,\the\tagcode\ext12}}
\tagcode\ext0=-2\tagcode\ext12=-4\tagcode\ext12=4
\message{{CLEARED=\the\tagcode\ext0,\the\tagcode\ext12}}
\setbox0=\hbox{{\same AB DE F}}\showbox0
\setbox0=\hbox{{\size AB DE F}}\showbox0
\end",
);
let labels = ["initial", "initial size", "selective", "disabled alias", "independent size"].map(str::to_owned);
let result = compare(&p, &source, &labels);
let messages: Vec<_> = result.events.iter().filter_map(|event| match event {
Event::Message { text, .. } => Some(text.as_str()),
_ => None,
}).collect();
assert_eq!(messages, [
"BEFORE=0,1,0", "SELECTIVE=0,1,1,-1", "AFTER=1,0,0", "EXT=2,4", "CLEARED=0,0",
]);
let reference = fs::read_to_string(p.join("probe.log")).unwrap();
assert!(messages.iter().all(|message| reference.contains(message)));
fs::remove_dir_all(p).unwrap();
}
#[test]
fn all_operation_bytes_retention_pass_and_real_character_boundaries_match_initex() {
let p = directory();