summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-29 20:44:33 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-29 20:44:33 +0100
commitd9d2c021d62abb4fe6d12b994334bd211e462cde (patch)
treeee82597e2ce1237a30a40054ac65c8aaf9ea1e4a /library/src
parent5f4f507ecf02e580bac2d62253ebf4a6d0a44783 (diff)
Fix inline math bounding box
Diffstat (limited to 'library/src')
-rw-r--r--library/src/math/mod.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 65baf7ac..f24b8078 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -223,7 +223,20 @@ impl Layout for FormulaNode {
};
let mut ctx = MathContext::new(vt, styles, regions, &font, self.block);
- let frame = ctx.layout_frame(self)?;
+ let mut frame = ctx.layout_frame(self)?;
+
+ if !self.block {
+ let slack = styles.get(ParNode::LEADING) * 0.7;
+ let top_edge = styles.get(TextNode::TOP_EDGE).resolve(styles, font.metrics());
+ let bottom_edge =
+ -styles.get(TextNode::BOTTOM_EDGE).resolve(styles, font.metrics());
+
+ let ascent = top_edge.max(frame.ascent() - slack);
+ let descent = bottom_edge.max(frame.descent() - slack);
+ frame.translate(Point::with_y(ascent - frame.baseline()));
+ frame.size_mut().y = ascent + descent;
+ }
+
Ok(Fragment::frame(frame))
}
}