Preserve conditional math glue through native layout

This commit is contained in:
gloamxun committed 2026-11-29 02:16:50 +08:00
1 parent 91bb864d8c
commit 745c33fd44
18 files changed
+152 -25

No files matched your search

@@ -180,7 +180,8 @@ impl Executor {
displacement = (width - b.width - e + 1).div_euclid(2);
if matches!(
material.first(),
Some(TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _) | TextNode::Leaders(_))
Some(TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _)
| TextNode::ConditionalMathGlue | TextNode::Leaders(_))
) {
displacement = 0;
}
@@ -20,6 +20,7 @@ impl Tail {
TextNode::Glue(g) | TextNode::FontSpace(g, _, _)
| TextNode::NamedGlue(g, _)
| TextNode::Leaders(LeaderGlue { glue: g, .. }) => Self::Glue(*g, false),
TextNode::ConditionalMathGlue => Self::Glue(Glue::default(), false),
TextNode::Kern { width, .. } | TextNode::AccentKern(width) | TextNode::AutoKern(width) | TextNode::SpaceAdjustment(width) => {
Self::Kern(*width)
}
@@ -61,6 +62,7 @@ impl Tail {
match node {
MathNode::Leaders(leader) => Self::Glue(leader.glue, false),
MathNode::Glue(g) => Self::Glue(*g, true),
MathNode::ConditionalMathGlue => Self::Glue(Glue::default(), false),
MathNode::ExplicitSpace(g, _) => Self::Glue(*g, false),
MathNode::Kern { amount, .. } => Self::Kern(*amount),
MathNode::Penalty(n) => Self::Penalty(*n),
@@ -799,6 +799,9 @@ impl Executor {
.push(MathNode::ExplicitSpace(g, None));
}
Leaders | Cleaders | Xleaders => self.scan_leaders(*p, files)?,
Nonscript => {
self.math.last_mut().unwrap().nodes.push(MathNode::ConditionalMathGlue);
}
Mskip => {
let g = self.skip_glue(*p, files)?;
self.math.last_mut().unwrap().nodes.push(MathNode::Glue(g));