mirror of
https://github.com/typst/typst
synced 2025-08-24 03:34:14 +08:00
Add support for fractional spacing in inline math
This commit is contained in:
parent
fb9db2e695
commit
ce746528b3
@ -319,6 +319,24 @@ impl MathRun {
|
|||||||
|
|
||||||
let mut iter = self.0.into_iter().peekable();
|
let mut iter = self.0.into_iter().peekable();
|
||||||
while let Some(fragment) = iter.next() {
|
while let Some(fragment) = iter.next() {
|
||||||
|
if let MathFragment::Fractional(fr) = fragment {
|
||||||
|
if !empty {
|
||||||
|
let mut frame_prev =
|
||||||
|
std::mem::replace(&mut frame, Frame::soft(Size::zero()));
|
||||||
|
|
||||||
|
finalize_frame(&mut frame_prev, x, ascent, descent);
|
||||||
|
items.push(InlineItem::Frame(frame_prev));
|
||||||
|
empty = true;
|
||||||
|
|
||||||
|
x = Abs::zero();
|
||||||
|
ascent = Abs::zero();
|
||||||
|
descent = Abs::zero();
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push(InlineItem::Fractional(fr));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let class = fragment.class();
|
let class = fragment.class();
|
||||||
let y = fragment.ascent();
|
let y = fragment.ascent();
|
||||||
|
|
||||||
|
BIN
tests/ref/math-spacing-fractional-inline.png
Normal file
BIN
tests/ref/math-spacing-fractional-inline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
tests/ref/math-spacing-mixed-inline.png
Normal file
BIN
tests/ref/math-spacing-mixed-inline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -87,6 +87,22 @@ Hello $#box(width: 40%)$ world \
|
|||||||
$mtext("Hello") #h(40%) space mtext("world")$ \
|
$mtext("Hello") #h(40%) space mtext("world")$ \
|
||||||
$mtext("Hello") #box(width: 40%) mtext("world")$
|
$mtext("Hello") #box(width: 40%) mtext("world")$
|
||||||
|
|
||||||
|
--- math-spacing-fractional-inline ---
|
||||||
|
// Test fractional spacing in inline math.
|
||||||
|
Hello #h(1fr) world \
|
||||||
|
Hello $#h(1fr)$ world
|
||||||
|
|
||||||
|
x #h(1fr) y \
|
||||||
|
$x #h(1fr) y$
|
||||||
|
|
||||||
|
Blah #h(1.5fr) long$#h(0.5fr) x - #h(1fr) y$ line. \
|
||||||
|
Blah #h(1.5fr) long $#h(0.5fr) x - #h(1fr) y$ line.
|
||||||
|
|
||||||
|
--- math-spacing-mixed-inline ---
|
||||||
|
// Test mixture of different kinds of spacing in inline math.
|
||||||
|
Some #h(30%) inline $x + #h(5%) y - #h(1fr) sum_(1 #h(1fr) 2) $ spacing #h(2fr) blah.
|
||||||
|
Long $(a #h(1fr) z) #h(1em, weak: true)$ #h(1%) $#h(0.5fr) sqrt(1 + #h(0.5fr) y)$.
|
||||||
|
|
||||||
--- issue-1052-math-number-spacing ---
|
--- issue-1052-math-number-spacing ---
|
||||||
// Test spacing after numbers in math.
|
// Test spacing after numbers in math.
|
||||||
$
|
$
|
||||||
|
Loading…
x
Reference in New Issue
Block a user