Implement native text accents for unmodified LaTeX jobs

This commit is contained in:
gloamxun committed 2026-11-20 16:15:30 +08:00
1 parent ca60c66a17
commit 4eeb5686b8
16 files changed
+269 -18

No files matched your search

@@ -1,4 +1,6 @@
//! Actual native box/list displays against independent INITEX diagnostics.
#[path = "support/dvi_shipout.rs"]
mod dvi_shipout;
#[path = "support/font_world.rs"]
mod font_world;
use std::{fs, process::Command};
@@ -301,3 +303,57 @@ fn errmessage_uses_scoped_unexpanded_error_help() {
.unwrap_err();
assert_eq!(error.help, None);
}
#[test]
fn text_accents_preserve_font_metrics_kerns_and_paint_positions() {
let case = directory("text-accent");
let source = r"\catcode123=1 \catcode125=2
\font\regular=cmr10
\font\slanted=cmti10
\font\smaller=cmr7
\regular
\showboxbreadth=99 \showboxdepth=99
\setbox1=\hbox{\regular\accent19 A}
\setbox2=\hbox{\regular\accent19\slanted\char84}
\setbox3=\hbox{\regular\accent19\relax}
\setbox4=\hbox{\regular\accent255 Z}
\setbox5=\hbox{\regular\accent19\let\letter=a\letter}
\setbox6=\hbox{\regular\accent19\count0=731 \smaller\char97\message{ACCENT-ASSIGNMENT:\the\count0}}
\setbox7=\vbox{\hsize=50pt \baselineskip=12pt \parfillskip=0pt plus1fil
\noindent W\hfil\penalty-10000 \accent19 A\par}
\setbox8=\vbox{\hsize=50pt \parfillskip=0pt plus1fil
\everypar{\global\count2=197}\accent19 A\par}
\message{ACCENT-EVERYPAR:\the\count2}
\showbox1 \showbox2 \showbox3 \showbox4 \showbox5 \showbox6 \showbox7 \showbox8
\shipout\vbox{\box1\box2\box3\box4\box5\box6\box7\box8}
\end
";
let log = dvi_shipout::run_reference_with_showboxes(&case, source, 8);
assert!(log.contains("ACCENT-ASSIGNMENT:731"));
assert!(log.contains("ACCENT-EVERYPAR:197"));
let actual = Executor::new(State::initex().with_etex(), Limits::default())
.with_native_pages()
.run(
SourceFile {
name: "text-accent.tex".into(),
data: source.as_bytes().to_vec(),
},
&mut Host::default(),
)
.unwrap_or_else(|error| panic!("{case:?}: {error}"));
assert_eq!(actual.state.count(2), 197);
let lists = reports(&actual);
assert_eq!(lists.len(), 8);
for report in lists {
assert!(
log.contains(&report.text),
"{case:?}\nnative:\n{}\nreference:\n{log}",
report.text
);
}
let pages = dvi_shipout::compare_shipouts(&case, &actual)
.unwrap_or_else(|error| panic!("{case:?}: {error}"));
assert_eq!(pages.len(), 1);
assert_eq!(pages[0]["glyphs"].as_u64(), Some(15));
assert!(pages[0]["max_coordinate_error_sp"].as_i64().unwrap() <= 1);
}