Paint math limits above and below their base

This commit is contained in:
gloamxun committed 2026-10-20 18:51:49 +08:00
1 parent b004cd2efb
commit 3f1dd0c077
2 files changed
+47 -1

No files matched your search

+27 -1
View File
@@ -682,9 +682,35 @@ impl Page {
list,
);
}
MathAtom::Limits { base, sub, sup } => {
let base_box = math::layout_math(base, font);
Self::paint_math(base, font, x, baseline, size, list);
let small = (size as f64 * 0.7) as i64;
if let Some(sup) = sup {
let sup_box = math::layout_math(sup, font);
Self::paint_math(
sup,
font,
x + (base_box.width - sup_box.width).max(0) / 2,
baseline - base_box.height - small,
small,
list,
);
}
if let Some(sub) = sub {
let sub_box = math::layout_math(sub, font);
Self::paint_math(
sub,
font,
x + (base_box.width - sub_box.width).max(0) / 2,
baseline + base_box.depth + small,
small,
list,
);
}
}
MathAtom::Brace { base, .. }
| MathAtom::Smash { body: base, .. }
| MathAtom::Limits { base, .. }
| MathAtom::Classed { body: base, .. } => {
Self::paint_math(base, font, x, baseline, size, list)
}