Repository navigation
Explain how to use multiple fonts in sub/superscript docs - #8095
Merged
Merged
Conversation
YDX-2147483647
force-pushed
the
docs-super-align
branch
from
April 11, 2026 16:33
4a43c8a to
2b3a9a4
Compare
MDLC01
reviewed
Apr 11, 2026
Collaborator
|
I think it would be nice to also show the result without the set rule to help users understand the problem. |
Contributor
Author
Collaborator
|
What about showing the same example, but clearly identifying it as wrong, similar to what is already done in the Accessibility Guide? |
Contributor
Author
Collaborator
|
I think this is great! |
Member
|
Thanks, it's indeed nice! |
gpradofe
pushed a commit
to gpradofe/typst
that referenced
this pull request
Apr 18, 2026
Co-authored-by: Malo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves #8090
The baseline and size of sub/superscripts are determined by the font.
If you use multiple fonts with incompatible metrics, then the result will be poor, unless the metrics are overridden.
It looks like a bug, but there's nothing that Typst can do. Therefore, I'm submitting this PR.
About the added example
Outdated screenshots
With
set super(…):Without
set super(…):The example added in this PR is kind of atypical, but I can't come up with better ones.
In the original scenario that triggered this problem, the superscript contained both Chinese and English, so it was natural to use multiple fonts (KaiTi for Chinese and TeX Gyre Termes for English).
However, fonts in typst-assets and typst-dev-assets are quite limited.
It looks like Roboto and Ubuntu are the only two text fonts (excluding math, emoji, and programming fonts) that have metrics incompatible with other fonts.
Fonts in typst-dev-assets and their metrics
======= ./IBMPlexSans-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./IBMPlexSansDevanagari-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./IBMPlexMath-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./IBMPlexSerif-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./CascadiaCode-Regular.ttf ======== <unitsPerEm value="2048"/> <ySuperscriptYSize value="1229"/> <ySuperscriptYOffset value="717"/> ======= ./IBMPlexSans-Bold.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./Concrete-Math.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="699"/> <ySuperscriptYOffset value="479"/> ======= ./Asana-Math.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="699"/> <ySuperscriptYOffset value="360"/> ======= ./Garamond-Math.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="699"/> <ySuperscriptYOffset value="479"/> ======= ./IBMPlexSans-Light.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./IBMPlexSans-Medium.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./InriaSerif-BoldItalic.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./IBMPlexSansCondensed-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSansArabic-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./InriaSerif-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./InriaSerif-Bold.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSansThai-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSansSymbols2-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./LibertinusMath-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./InriaSerif-Italic.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSansMath-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSerifCJKjp-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoColorEmoji-Regular-COLR.subset.ttf ======== <unitsPerEm value="1024"/> <ySuperscriptYSize value="614"/> <ySuperscriptYOffset value="358"/> ======= ./NotoSerifHebrew-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSerifHebrew-Bold.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSerifCJKtc-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSerifCJKtc-Bold.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSerifCJKsc-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./NotoSerifCJKsc-Bold.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./PTSans-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./Roboto-Regular.ttf ======== <unitsPerEm value="2048"/> <ySuperscriptYSize value="1331"/> <ySuperscriptYOffset value="977"/> ======= ./STIXTwoMath-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="500"/> <ySuperscriptYOffset value="500"/> ======= ./NotoSerifCJKkr-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./SourceSerif4-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="600"/> <ySuperscriptYOffset value="350"/> ======= ./TwitterColorEmoji.ttf ======== <unitsPerEm value="2048"/> <ySuperscriptYSize value="1433"/> <ySuperscriptYOffset value="983"/> ======= ./XITSMath-Regular.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="500"/> <ySuperscriptYOffset value="500"/> ======= ./texgyrebonum-math.otf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="699"/> <ySuperscriptYOffset value="479"/> ======= ./PennstanderMath-Regular.otf ======== <unitsPerEm value="2000"/> <ySuperscriptYSize value="1200"/> <ySuperscriptYOffset value="700"/> ======= ./Ubuntu-Regular.ttf ======== <unitsPerEm value="1000"/> <ySuperscriptYSize value="650"/> <ySuperscriptYOffset value="477"/>Fonts in typst-dev-assets and their metrics, organized by AI