Keep sum superscripts above the operator

Large-operator limits used the ordinary-base superscript gap, which could
leave N just below the sum baseline. Use a negative gap for large operators
so both limits straddle the operator, and add a unit test asserting the
subscript is below and the superscript above the base within 12pt.

Test count is 1080.
This commit is contained in:
gloamxun committed 2026-10-28 08:28:17 +08:00
1 parent 02742d201f
commit 676eb7f323
6 files changed
+41 -8

No files matched your search

+6 -1
View File
@@ -1591,11 +1591,16 @@ impl Page {
let small = (size as f64 * 0.7) as i64;
if let Some(sup) = sup {
let sup_box = math::script_metrics(math::layout_math(sup, font));
let sup_gap = if Self::large_operator(base) {
-96_993
} else {
96_993
};
Self::paint_math(
sup,
font,
x + (base_box.width - sup_box.width).max(0) / 2,
baseline - base_box.height - sup_box.depth + 96_993,
baseline - base_box.height - sup_box.depth + sup_gap,
small,
list,
);