mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Fixing the baseline in math content (#2220)
This commit is contained in:
parent
50b0318434
commit
04b4536772
@ -187,6 +187,7 @@ pub struct GlyphFragment {
|
|||||||
pub font: Font,
|
pub font: Font,
|
||||||
pub lang: Lang,
|
pub lang: Lang,
|
||||||
pub fill: Paint,
|
pub fill: Paint,
|
||||||
|
pub shift: Abs,
|
||||||
pub width: Abs,
|
pub width: Abs,
|
||||||
pub ascent: Abs,
|
pub ascent: Abs,
|
||||||
pub descent: Abs,
|
pub descent: Abs,
|
||||||
@ -225,6 +226,7 @@ impl GlyphFragment {
|
|||||||
font: ctx.font.clone(),
|
font: ctx.font.clone(),
|
||||||
lang: TextElem::lang_in(ctx.styles()),
|
lang: TextElem::lang_in(ctx.styles()),
|
||||||
fill: TextElem::fill_in(ctx.styles()),
|
fill: TextElem::fill_in(ctx.styles()),
|
||||||
|
shift: TextElem::baseline_in(ctx.styles()),
|
||||||
style: ctx.style,
|
style: ctx.style,
|
||||||
font_size: ctx.size,
|
font_size: ctx.size,
|
||||||
width: Abs::zero(),
|
width: Abs::zero(),
|
||||||
@ -309,7 +311,7 @@ impl GlyphFragment {
|
|||||||
let size = Size::new(self.width, self.ascent + self.descent);
|
let size = Size::new(self.width, self.ascent + self.descent);
|
||||||
let mut frame = Frame::new(size);
|
let mut frame = Frame::new(size);
|
||||||
frame.set_baseline(self.ascent);
|
frame.set_baseline(self.ascent);
|
||||||
frame.push(Point::with_y(self.ascent), FrameItem::Text(item));
|
frame.push(Point::with_y(self.ascent + self.shift), FrameItem::Text(item));
|
||||||
frame.meta_iter(self.meta);
|
frame.meta_iter(self.meta);
|
||||||
frame
|
frame
|
||||||
}
|
}
|
||||||
|
BIN
tests/ref/bugs/math-shift.png
Normal file
BIN
tests/ref/bugs/math-shift.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
5
tests/typ/bugs/math-shift.typ
Normal file
5
tests/typ/bugs/math-shift.typ
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// https://github.com/typst/typst/issues/2214
|
||||||
|
// The math content should also be affected by the TextElem baseline.
|
||||||
|
|
||||||
|
hello #text(baseline: -5pt)[123 #sym.WW\orld]\
|
||||||
|
hello #text(baseline: -5pt)[$123 WW#text[or]$ld]\
|
Loading…
x
Reference in New Issue
Block a user