Apply pdfTeX line box dimensions and restore output penalties

This commit is contained in:
gloamxun committed 2026-11-29 12:49:56 +08:00
1 parent 7f51f01bd4
commit fb557c09c6
13 files changed
+151 -14

No files matched your search

@@ -1535,6 +1535,16 @@ pub(super) fn finish(
let directions = super::direction::has_directions(&b.nodes);
let mut direction_stack = Vec::new();
let widow_kind = LinePenaltyKind::for_widow_parameter(final_widow);
let ignored_depth = state.ignored_depth();
let pdftex = state.input_profile() != super::InputProfile::XeTeX;
let line_dimension = |p| {
let value = parameters[&p].width();
(pdftex && value != ignored_depth).then_some(i64::from(value))
};
let each_height = line_dimension(Parameter::Pdfeachlineheight);
let each_depth = line_dimension(Parameter::Pdfeachlinedepth);
let first_height = line_dimension(Parameter::Pdffirstlineheight).or(each_height);
let last_depth = line_dimension(Parameter::Pdflastlinedepth).or(each_depth);
for (i, (point, bad)) in path.iter().enumerate() {
let mut material = line_material(
&b.nodes,
@@ -1558,7 +1568,7 @@ pub(super) fn finish(
// Keep a real breakpoint marker before the synthetic line closers.
super::direction::line(&mut material, &mut direction_stack);
}
let (line, line_box, adjustments, shrinking) = pack(
let (line, mut line_box, adjustments, shrinking) = pack(
&material,
&parameters,
dimensions,
@@ -1583,6 +1593,10 @@ pub(super) fn finish(
pre_display_size =
pre_display_line_size(material, line_box.setting, line_box.shift, quad);
}
let height = if i == 0 { first_height } else { each_height };
let depth = if i + 1 == path.len() { last_depth } else { each_depth };
line_box.height = height.unwrap_or(line_box.height);
line_box.depth = depth.unwrap_or(line_box.depth);
diagnostic_lines.push(super::diagnostics::box_view(&line_box));
line_boxes.push(line_box);
line_pre_adjustments.push(adjustments.pre);