Skip to content

Wrapping with parens should not push superscripts higher - #4545

Merged
laurmaedje merged 3 commits into
typst:mainfrom
Leedehai:attach
Jul 15, 2024
Merged

laurmaedje merged 3 commits into
typst:mainfrom
Leedehai:attach

Conversation

@Leedehai

@Leedehai Leedehai commented Jul 11, 2024 •

Copy link
Copy Markdown
Contributor

A parenthesis glyph itself (i.e. ( or )) is a text-like [1], so superscripts attached to it should not be pushed higher, just like other non-large glyphs [2]

.max(if is_text_like { Abs::zero() } else { ascent - sup_drop_max })

As shown below, parenthesis glyphs of an LR that wraps around text-like glyphs are the same as standalone parenthesis glyphs, and should still be text-like. Therefore, the whole sequence of glyphs in the said LR are all text-like, and the superscripts attached to this sequence should still not be pushed higher.

This is addressed by marking the frame fragment built from a MathRun containing all text-like fragments text-like.

Comparisons:

Case 1 Case 2
Before the patch (1) (3)
After the patch (2) (4)

Taking figure (4) as an example. The 1st red box shows the superscript position when the base (an x character) is a non-large glyph. The 2nd box shows the superscript position when the base is a single parenthesis glyph. The 3rd box's base is a sequential combination of the these glyphs, so the superscript in the 3rd should have the same vertical position like before, instead of being pushed higher.

[1] MathFragment::is_text_like() is for the purpose of TeXBook Appendix G 18a's special handling to determine the vertical position for superscripts and subscripts.
[2] See MathFragment::is_text_like(). Large glyphs (i.e. MathClass::Large) are the ones like the big integral symbol.

Comment thread crates/typst/src/math/row.rs Resolved
@laurmaedje laurmaedje added the waiting-on-author Pull request waits on author label Jul 14, 2024
@Leedehai
Leedehai force-pushed the attach branch 3 times, most recently from eea2779 to f3eda63 Compare July 14, 2024 16:42
@laurmaedje
laurmaedje enabled auto-merge July 15, 2024 09:51
@laurmaedje

Copy link
Copy Markdown
Member

Thanks!

@laurmaedje laurmaedje removed the waiting-on-author Pull request waits on author label Jul 15, 2024
@laurmaedje
laurmaedje added this pull request to the merge queue Jul 15, 2024
Merged via the queue into typst:main with commit f0407d4 Jul 15, 2024
@Leedehai
Leedehai deleted the attach branch July 15, 2024 13:43
@laurmaedje

Copy link
Copy Markdown
Member

@Leedehai Since you've recently worked a bunch on AttachElem, I'd be curious about your thoughts on #1304 (comment).

@Leedehai

Copy link
Copy Markdown
Contributor Author

Sure, opened #4569

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