Skip to content

Use extended shape information for glyph text_like-ness - #5483

Merged
laurmaedje merged 1 commit into
typst:mainfrom
mkorje:fix-scripts-text-likeness
Nov 27, 2024
Merged

laurmaedje merged 1 commit into
typst:mainfrom
mkorje:fix-scripts-text-likeness

Conversation

@mkorje

@mkorje mkorje commented Nov 27, 2024

Copy link
Copy Markdown
Collaborator

Fixes #2342.

This changes how the text_like property is set for glyph and variant fragments. Instead of checking if they aren't of class "large", we use the extended shape information in the font and check if they aren't an extended shape.

According to this, if the base is a single character and not an extended shape, then the baseline of the script is shifted by a font constant. Otherwise, the script is shifted above/below the base by a font constant. I've retained the behaviour introduced in #4545, where sequences of text-like stuff use the constant script shift. Thus the current Typst behaviour now sits somewhere between TeX engines (which don't use extended shape information at all) and Microsoft's implementation (which follows the algorithm from above). I think this is a fine state to be in, given we find the behaviour in #4545 desirable. Also, the continued use of the text_like property, introduced in #3059 (which superseded #1129), lets us preserve it through accent, cancel, and op elements.

@laurmaedje
laurmaedje added this pull request to the merge queue Nov 27, 2024
@laurmaedje

Copy link
Copy Markdown
Member

Thanks for the deep investigation and fix!

Merged via the queue into typst:main with commit f29fbea Nov 27, 2024
@mkorje
mkorje deleted the fix-scripts-text-likeness branch November 27, 2024 11:17
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
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.

Scripts are sometimes in the wrong position with lr()

2 participants