Fix inline math bounding box

This commit is contained in:
Laurenz 2023-01-29 20:44:33 +01:00
parent 5f4f507ecf
commit d9d2c021d6
3 changed files with 14 additions and 1 deletions

View File

@ -223,7 +223,20 @@ impl Layout for FormulaNode {
}; };
let mut ctx = MathContext::new(vt, styles, regions, &font, self.block); 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)) Ok(Fragment::frame(frame))
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB