Match XeTeX margin boundaries and Web2c glue rounding
This commit is contained in:
1 parent
52db77885d
commit
9da75c82f5
5 files changed
+150
-19
No files matched your search
@@ -418,6 +418,97 @@ fn margin_protrusion_uses_font_slots_in_break_search_and_shipout() {
|
||||
assert!(page["max_coordinate_error_sp"].as_i64().unwrap() <= 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paragraph_protrusion_observes_profile_specific_whatsit_boundaries() {
|
||||
let source = r"\catcode123=1 \catcode125=2
|
||||
\font\roman=cmr10 \roman
|
||||
\hsize=100pt \parfillskip=0pt plus 1fil
|
||||
\showboxdepth=20 \showboxbreadth=60
|
||||
\lpcode\roman65=100 \rpcode\roman66=200
|
||||
\setbox0=\vbox{\noindent AB\par}
|
||||
\setbox1=\vbox{\noindent\setlanguage0 AB\setlanguage0 \par}
|
||||
\setbox2=\vbox{\noindent\special{color push gray 0}AB\special{color pop}\par}
|
||||
\setbox3=\vbox{\noindent\hbox{\setlanguage0 AB\setlanguage0 }\par}
|
||||
\setbox4=\vbox{\noindent\hbox{\special{color push gray 0}AB\special{color pop}}\par}
|
||||
\setbox5=\vbox{\noindent\hbox{\setlanguage0 }AB\hbox{\setlanguage0 }\par}
|
||||
\showbox0 \showbox1 \showbox2 \showbox3 \showbox4 \showbox5
|
||||
\end
|
||||
";
|
||||
for (profile, parameter, expected) in [
|
||||
(InputProfile::TeX8Bit, "pdfprotrudechars", [2, 2, 2, 2, 2, 2]),
|
||||
(InputProfile::XeTeX, "XeTeXprotrudechars", [2, 0, 0, 0, 0, 0]),
|
||||
] {
|
||||
let execution = Executor::new(
|
||||
State::initex().with_etex().with_input_profile(profile),
|
||||
Limits::default(),
|
||||
)
|
||||
.with_native_pages()
|
||||
.run(
|
||||
SourceFile {
|
||||
name: "margin-whatsits.tex".into(),
|
||||
data: format!("\\{parameter}=1\n{source}").into_bytes(),
|
||||
},
|
||||
&mut Host::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let actual: Vec<_> = reports(&execution)
|
||||
.iter()
|
||||
.map(|report| {
|
||||
report.text.lines().filter(|line| line.ends_with(" margin)")).count()
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(actual, expected, "{profile:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shipout_applies_the_stored_glue_ratio_before_rounding() {
|
||||
use texrra_tex_core::render::DisplayItem;
|
||||
|
||||
let source = r"\catcode123=1 \catcode125=2
|
||||
\shipout\vbox{\hbox to7sp{\hskip0sp plus47sp\vrule width4sp height1pt\hskip0sp plus47sp}%
|
||||
\kern10pt\hbox to1sp{\hskip0sp minus47sp\vrule width4sp height1pt\hskip0sp minus47sp}%
|
||||
\kern10pt\hbox to5sp{\hskip0sp plus49sp\vrule width4sp height1pt\hskip0sp plus49sp}%
|
||||
\kern10pt\hbox to3sp{\hskip0sp minus49sp\vrule width4sp height1pt\hskip0sp minus49sp}%
|
||||
\kern10pt\hbox{\vrule width4sp height1pt}}
|
||||
\end
|
||||
";
|
||||
for profile in [InputProfile::TeX8Bit, InputProfile::XeTeX] {
|
||||
let execution = Executor::new(
|
||||
State::initex().with_etex().with_input_profile(profile),
|
||||
Limits::default(),
|
||||
)
|
||||
.with_native_pages()
|
||||
.run(
|
||||
SourceFile {
|
||||
name: "rounded-glue.tex".into(),
|
||||
data: source.as_bytes().to_vec(),
|
||||
},
|
||||
&mut font_world::FontFiles,
|
||||
)
|
||||
.unwrap();
|
||||
let page = execution
|
||||
.events
|
||||
.iter()
|
||||
.find_map(|event| match event {
|
||||
Event::Shipout(page) => Some(page.display_list().unwrap()),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
let positions: Vec<_> = page
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
DisplayItem::Rule { x, .. } => Some(*x),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let (&origin, rules) = positions.split_last().unwrap();
|
||||
let offsets: Vec<_> = rules.iter().map(|&x| x - origin).collect();
|
||||
assert_eq!(offsets, [1, -1, 1, -1], "{profile:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn font_expansion_codes_invalidate_cached_break_geometry() {
|
||||
let source = r"\catcode123=1 \catcode125=2
|
||||
|
||||
Reference in new issue
Block a user