Adjust the baseline of root radicand frame (#4736)

This commit is contained in:
Leedehai 2024-08-15 16:08:40 -04:00 committed by GitHub
parent c43997de0a
commit d221a89a40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View File

@ -70,8 +70,20 @@ fn layout(
let raise_factor = percent!(ctx, radical_degree_bottom_raise_percent);
// Layout radicand.
let cramped = style_cramped();
let radicand = ctx.layout_into_frame(radicand, styles.chain(&cramped))?;
let radicand = {
let cramped = style_cramped();
let styles = styles.chain(&cramped);
let run = ctx.layout_into_run(radicand, styles)?;
let multiline = run.is_multiline();
let mut radicand = run.into_fragment(ctx, styles).into_frame();
if multiline {
// Align the frame center line with the math axis.
radicand.set_baseline(
radicand.height() / 2.0 + scaled!(ctx, styles, axis_height),
);
}
radicand
};
// Layout root symbol.
let target = radicand.height() + thickness + gap;

View File

@ -353,7 +353,7 @@ impl MathRun {
items
}
fn is_multiline(&self) -> bool {
pub fn is_multiline(&self) -> bool {
self.iter().any(|frag| matches!(frag, MathFragment::Linebreak))
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -30,6 +30,7 @@ $ sqrt([|x|]^2 + [|y|]^2) < [|z|] $
$ v = sqrt((1/2) / (4/5))
= root(3, (1/2/3) / (4/5/6))
= root(4, ((1/2) / (3/4)) / ((1/2) / (3/4))) $
$ v = sqrt(a +\ b) $
--- math-root-large-index ---
// Test large index.