Center large operators on axis (#1735)

This commit is contained in:
damaxwell 2023-07-19 23:47:29 -08:00 committed by GitHub
parent 0e04d46e31
commit 6a396ae214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View File

@ -167,24 +167,29 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
{
// A single letter that is available in the math font.
match self.style.size {
MathSize::Display => {
let class = self.style.class.as_custom().or(glyph.class);
if class == Some(MathClass::Large) {
let height = scaled!(self, display_operator_min_height);
glyph.stretch_vertical(self, height, Abs::zero()).into()
} else {
glyph.into()
}
}
MathSize::Script => {
glyph.make_scriptsize(self);
glyph.into()
}
MathSize::ScriptScript => {
glyph.make_scriptscriptsize(self);
glyph.into()
}
_ => glyph.into(),
_ => (),
}
let class = self.style.class.as_custom().or(glyph.class);
if class == Some(MathClass::Large) {
let mut variant = if self.style.size == MathSize::Display {
let height = scaled!(self, display_operator_min_height);
glyph.stretch_vertical(self, height, Abs::zero())
} else {
glyph.into_variant()
};
// TeXbook p 155. Large operators are always vertically centered on the axis.
let h = variant.frame.height();
variant.frame.set_baseline(h / 2.0 + scaled!(self, axis_height));
variant.into()
} else {
glyph.into()
}
} else if text.chars().all(|c| c.is_ascii_digit()) {
// Numbers aren't that difficult.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB