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

@@ -65,6 +65,8 @@ pub enum TextNode {
},
Glue(Glue),
NamedGlue(Glue, Parameter),
/// Zero glue retained by the conversion of a conditional math marker.
ConditionalMathGlue,
Leaders(LeaderGlue),
Kern {
width: i32,
@@ -608,6 +610,7 @@ fn discardable(n: &TextNode) -> bool {
n,
TextNode::Glue(_) | TextNode::FontSpace(_, _, _)
| TextNode::NamedGlue(_, _)
| TextNode::ConditionalMathGlue
| TextNode::Leaders(_)
| TextNode::Kern { .. }
| TextNode::SpaceAdjustment(_)
@@ -822,7 +825,8 @@ fn metrics(nodes: &[TextNode], left: Glue, right: Glue) -> (i64, [i64; 4], i64)
.filter(|n| {
!matches!(
n,
TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _) | TextNode::Leaders(_)
TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _)
| TextNode::ConditionalMathGlue | TextNode::Leaders(_)
)
})
.map(width)
@@ -1423,7 +1427,8 @@ pub(super) fn finish(
if b.nodes.last().is_some_and(|n| {
matches!(
n,
TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _) | TextNode::Leaders(_)
TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _)
| TextNode::ConditionalMathGlue | TextNode::Leaders(_)
)
}) {
b.nodes.pop();
@@ -1718,7 +1723,8 @@ fn add_hyphens(
.is_some_and(|n| {
matches!(
n,
TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _) | TextNode::Leaders(_)
TextNode::Glue(_) | TextNode::FontSpace(_, _, _) | TextNode::NamedGlue(_, _)
| TextNode::ConditionalMathGlue | TextNode::Leaders(_)
)
})
&& !word.is_empty()
@@ -1751,6 +1757,7 @@ fn add_hyphens(
| TextNode::Output(_)
| TextNode::Glue(_) | TextNode::FontSpace(_, _, _)
| TextNode::NamedGlue(_, _)
| TextNode::ConditionalMathGlue
| TextNode::Leaders(_)
| TextNode::Penalty(_)
| TextNode::AccentKern(_)