Apply e-TeX line penalty arrays to native pagination
This commit is contained in:
1 parent
09cd19594c
commit
c094d9a81d
12 files changed
+243
-24
No files matched your search
@@ -244,6 +244,56 @@ impl Executor {
|
||||
self.assign_paragraph_shape(shape, global, files)
|
||||
}
|
||||
|
||||
pub(super) fn read_line_penalties(&mut self, kind: LinePenaltyKind) -> &[i32] {
|
||||
self.reads.insert(Dependency::LinePenalties(kind));
|
||||
self.state.line_penalties(kind)
|
||||
}
|
||||
|
||||
fn assign_line_penalties(
|
||||
&mut self,
|
||||
kind: LinePenaltyKind,
|
||||
values: Vec<i32>,
|
||||
global: bool,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
let equivalent = values.is_empty() && self.state.line_penalties(kind).is_empty();
|
||||
self.assign_equivalence(Key::LinePenalties(kind), global, equivalent, files, |state| {
|
||||
state.assign_line_penalties(kind, values, global);
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn scan_line_penalties(
|
||||
&mut self,
|
||||
kind: LinePenaltyKind,
|
||||
global: bool,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
self.optional_equals(files)?;
|
||||
let count = self.integer(files)?.max(0) as usize;
|
||||
if count > self.limits.tokens {
|
||||
return self.fail("native line penalty array capacity exceeded");
|
||||
}
|
||||
let mut values = Vec::new();
|
||||
for _ in 0..count {
|
||||
values.push(self.integer(files)?);
|
||||
}
|
||||
self.assign_line_penalties(kind, values, global, files)
|
||||
}
|
||||
|
||||
pub(super) fn line_penalty_value(
|
||||
&mut self,
|
||||
kind: LinePenaltyKind,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<i32, Error> {
|
||||
let index = self.integer(files)?;
|
||||
let values = self.read_line_penalties(kind);
|
||||
Ok(match index {
|
||||
..0 => 0,
|
||||
0 => values.len() as i32,
|
||||
_ => super::super::paragraph::line_penalty_at(values, index as usize).unwrap_or(0),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn paragraph_shape_dimension(
|
||||
&mut self,
|
||||
primitive: Primitive,
|
||||
@@ -493,6 +543,11 @@ impl Executor {
|
||||
self.reads.insert(Dependency::Parameter(*p));
|
||||
}
|
||||
self.reads.insert(Dependency::ParagraphShape);
|
||||
self.reads.extend([
|
||||
Dependency::LinePenalties(LinePenaltyKind::Interline),
|
||||
Dependency::LinePenalties(LinePenaltyKind::Club),
|
||||
Dependency::LinePenalties(LinePenaltyKind::for_widow_parameter(final_widow)),
|
||||
]);
|
||||
self.reads.insert(Dependency::Hyphenation);
|
||||
for n in &b.nodes {
|
||||
let text = match n {
|
||||
@@ -636,6 +691,9 @@ impl Executor {
|
||||
if !self.read_paragraph_shape().is_empty() {
|
||||
self.assign_paragraph_shape(Vec::new(), false, files)?;
|
||||
}
|
||||
if !self.read_line_penalties(LinePenaltyKind::Interline).is_empty() {
|
||||
self.assign_line_penalties(LinePenaltyKind::Interline, Vec::new(), false, files)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub(super) fn horizontal_command(
|
||||
|
||||
Reference in new issue
Block a user