Fit native paragraph endings using preceding line glue
This commit is contained in:
1 parent
e72104eab3
commit
11fd66713b
10 files changed
+247
-23
No files matched your search
@@ -87,6 +87,47 @@ fn paragraph_fill_is_discarded_after_a_break_that_consumes_the_tail() {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn last_line_fit_reuses_the_selected_fill_only_for_the_same_parameter() {
|
||||
use std::sync::Arc;
|
||||
|
||||
let cache = Arc::new(LineBreakCache::default());
|
||||
let compile = |factor, cached| {
|
||||
let mut executor = Executor::new(State::initex().with_etex(), Limits::default());
|
||||
if cached {
|
||||
executor = executor.with_line_break_cache(cache.clone());
|
||||
}
|
||||
executor.run(
|
||||
SourceFile {
|
||||
name: "fitted.tex".into(),
|
||||
data: format!(r"{SETUP}\hsize=50pt\pretolerance=10000
|
||||
\lastlinefit={factor}\noindent
|
||||
\hbox to20pt{{A\hfil}}\hskip4pt plus12pt\hbox to20pt{{B\hfil}}%
|
||||
\penalty-10000
|
||||
\hbox to12pt{{C\hfil}}\hskip4pt plus12pt\hbox to12pt{{D\hfil}}\par\end")
|
||||
.into_bytes(),
|
||||
},
|
||||
&mut FontFiles,
|
||||
).unwrap()
|
||||
};
|
||||
for (factor, width) in [(1000, 16), (500, 19), (1000, 16)] {
|
||||
let live = compile(factor, true);
|
||||
let full = compile(factor, false);
|
||||
let (live, full) = (paragraphs(&live)[0], paragraphs(&full)[0]);
|
||||
assert_eq!(live, full);
|
||||
assert_eq!(live.parameters[&Parameter::Parfillskip].glue().stretch.amount, 65536);
|
||||
let BoxContent::Horizontal(nodes) = &live.line_boxes[1].content else {
|
||||
panic!("expected the fitted final line");
|
||||
};
|
||||
assert!(nodes.iter().any(|node| matches!(node,
|
||||
TextNode::NamedGlue(fill, Parameter::Parfillskip)
|
||||
if fill.width == width * 65536 && fill.stretch.amount == 0
|
||||
)));
|
||||
}
|
||||
let work = cache.work();
|
||||
assert_eq!((work.solved_passes, work.reused_passes), (2, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_parameters_have_scopes_and_par_end_timing() {
|
||||
let e = run(
|
||||
|
||||
Reference in new issue
Block a user