Fix root index placement again

This commit is contained in:
Laurenz 2023-02-02 19:50:14 +01:00
parent 10675cd6d5
commit 3f85d005bb
3 changed files with 4 additions and 5 deletions

View File

@ -1,7 +1,5 @@
use super::*;
const MIN_INDEX_SHIFT: Em = Em::new(0.35);
/// # Square Root
/// A square root.
///
@ -123,12 +121,12 @@ fn layout(
let inner_ascent = extra_ascender + thickness + gap + radicand.ascent();
let mut sqrt_offset = Abs::zero();
let mut shift_up = Abs::zero();
let mut ascent = inner_ascent;
let mut shift_up = raise_factor * sqrt.height() - descent;
if let Some(index) = &index {
sqrt_offset = kern_before + index.width() + kern_after;
shift_up.set_max(index.descent() + MIN_INDEX_SHIFT.scaled(ctx));
shift_up = raise_factor * sqrt.height() - descent + index.descent();
ascent.set_max(shift_up + index.ascent());
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -35,4 +35,5 @@ $ v = sqrt((1/2) / (4/5))
// Test large index.
$ root(2, x) quad
root(3/(2/1), x) quad
root(1/11, x) $
root(1/11, x) quad
root(1/2/3, 1) $