mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Adjust the baseline of root radicand frame (#4736)
This commit is contained in:
parent
c43997de0a
commit
d221a89a40
@ -70,8 +70,20 @@ fn layout(
|
|||||||
let raise_factor = percent!(ctx, radical_degree_bottom_raise_percent);
|
let raise_factor = percent!(ctx, radical_degree_bottom_raise_percent);
|
||||||
|
|
||||||
// Layout radicand.
|
// Layout radicand.
|
||||||
|
let radicand = {
|
||||||
let cramped = style_cramped();
|
let cramped = style_cramped();
|
||||||
let radicand = ctx.layout_into_frame(radicand, styles.chain(&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.
|
// Layout root symbol.
|
||||||
let target = radicand.height() + thickness + gap;
|
let target = radicand.height() + thickness + gap;
|
||||||
|
@ -353,7 +353,7 @@ impl MathRun {
|
|||||||
items
|
items
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_multiline(&self) -> bool {
|
pub fn is_multiline(&self) -> bool {
|
||||||
self.iter().any(|frag| matches!(frag, MathFragment::Linebreak))
|
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 |
@ -30,6 +30,7 @@ $ sqrt([|x|]^2 + [|y|]^2) < [|z|] $
|
|||||||
$ v = sqrt((1/2) / (4/5))
|
$ v = sqrt((1/2) / (4/5))
|
||||||
= root(3, (1/2/3) / (4/5/6))
|
= root(3, (1/2/3) / (4/5/6))
|
||||||
= root(4, ((1/2) / (3/4)) / ((1/2) / (3/4))) $
|
= root(4, ((1/2) / (3/4)) / ((1/2) / (3/4))) $
|
||||||
|
$ v = sqrt(a +\ b) $
|
||||||
|
|
||||||
--- math-root-large-index ---
|
--- math-root-large-index ---
|
||||||
// Test large index.
|
// Test large index.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user