Skip to content

Fixing the baseline in math content#2220

Merged
laurmaedje merged 2 commits intotypst:mainfrom
LuxxxLucy:lucy-fix-math-baseline-br
Sep 25, 2023
Merged

Fixing the baseline in math content#2220
laurmaedje merged 2 commits intotypst:mainfrom
LuxxxLucy:lucy-fix-math-baseline-br

Conversation

@LuxxxLucy
Copy link
Copy Markdown
Contributor

Per #2214 , it turns out that in fn layout_text of math/ctx.rs, which handles the layout of math content, regular text is handled by the typst standard text layout (which will be calling the shaping engine), while the a single letter in a math font or a number is handled without going into the standard layout routines, but instead with an ad-hoc layout function in MathFragment::GlyphFragment.

The baseline shift is not taken consideration by the GlyphFragment which causes the issue of #2214. This PR fixes the issue as well as providing the bug's test case tests/typ/bugs/math-shift.typ.

hello #text(baseline: -5pt)[123 #sym.WW\orld]\
hello #text(baseline: -5pt)[$123 WW#text[or]$ld]\

result:
image

@laurmaedje laurmaedje merged commit 04b4536 into typst:main Sep 25, 2023
@laurmaedje
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants