You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is probably a font issue not a typesetting engine one. Whether it is a bug or a style choice I'm not actually sure. I'm the maintainer of Libertinus fonts project but was not the original author of the Math companion font. Either way please feel free to file an issue over here.
Can you post the MathML version here so I can experiment with this in SILE? I can experiment with a couple different versions of the font at once that way.
I'm not much of a math expert, but I'm pretty sure that MathML is kindo of borked. In any case I think I got a working example in SILE's math variant syntax (an alternative to having it work on MathML directly). The result is that Libertinus Math looks differently there than in Typst. Here are my inputs comparing STIX Two Math with Libertinus Math in both SILE and Typst:
Using the SILE side of things to check font versions:
$ sile -d versions prime.silSILE v0.14.13 (LuaJIT 2.1.1696562864)<prime.sil> as sil[1]Harfbuzz version: 8.3.0Shapers enabled: graphite2, ot, fallbackICU support enabledFonts used:/usr/share/fonts/OTF/STIXTwoMath-Regular.otf:0 Version 2.13 b170/usr/share/fonts/gentium/GentiumPlus-Regular.ttf:0 Version 6.200/usr/share/fonts/OTF/STIXTwoMath-Regular.otf:0 Version 2.13 b170/usr/share/fonts/libertinus/LibertinusMath-Regular.otf:0 Version 7.040;RELEASE/usr/share/fonts/libertinus/LibertinusMath-Regular.otf:0 Version 7.040;RELEASE
Presumably the Typst example being compiled locally is also picking up the same fonts from my system. I'm honestly not sure if perhaps it is preferring an embedded version or not. Assuming not, that's an interesting difference that suggests you might be right and this is Typst related and not the font.
Even in SILE it looks smaller than I expect, even if the position is more correct. The MathML rendering looks right.
I suspect this is an issue with how the prime is implemented in the font. The same thing is present with Noto Sans Math. There's some info in this issue @alerque
I stumbled upon this issue as I use Libertinus Math as my primary math font (in LaTeX). It worked fine in LaTeX (with unicode-math), but is broke in Typst.
I suspect it's an issue in the typst side because directly using the prime unicode character U+2032 ′ fixes the issue.
Comparing all different variations, only x prime and directly using the prime unicode without ^ works:
and it really highlights how "bad" the f'(x) looks when compared to the rendering for sile and xelatex.
I don't know if the best response is to suggest to Polytype that they use the "ssty" mentioned above (or write f prime instead of f'), or if effort should be spent identifying some alternative fix
But since this seems like it might be presenting Typst in a poor light in a fairly visible website (Polytype was recently featured on hackernews), it might be worth looking into.
While in Libertinus Math it is a single substitution lookup. I don’t know why Typst is accessing the raw lookup from ttf_parser, instead of enabling the feature through rustybuzz which should be more bullet-proof.
OTOH in pdflatex and xelatex, with or without newtx, it renders fine. I took a look at libertinus-otf and libertinus-type1 package sources and was unable to find anything ssty related.
I'm not sure whether you're planning switching to Libertinus Math alongside #1257 but in that case it would be better to fix this OTB.
OTOH in pdflatex and xelatex, with or without newtx, it renders fine. I took a look at libertinus-otf and libertinus-type1 package sources and was unable to find anything ssty related.
I'm not sure whether you're planning switching to Libertinus Math alongside #1257 but in that case it would be better to fix this OTB.
I don't think there's any plan to change the math font.
@schuelermine The changes that fixed this are currently only on the development version. When the next release is made it will be available. You can, in the web app, change the compiler version to the development version.
Activity
alerque commentedon Dec 4, 2023
This is probably a font issue not a typesetting engine one. Whether it is a bug or a style choice I'm not actually sure. I'm the maintainer of Libertinus fonts project but was not the original author of the Math companion font. Either way please feel free to file an issue over here.
schuelermine commentedon Dec 5, 2023
I am fairly sure this is a typst-specific issue. I have recreated this equation in MathML and it looks fine.

Perhaps this is a version difference?
alerque commentedon Dec 5, 2023
Can you post the MathML version here so I can experiment with this in SILE? I can experiment with a couple different versions of the font at once that way.
schuelermine commentedon Dec 5, 2023
I made the MathML with MathJax and got the CSS link from MDN/Frédéric Wang
MathMLLibertinus.txt
schuelermine commentedon Dec 5, 2023
However I opened it with a Chromium browser and a similar issue appears.

alerque commentedon Dec 5, 2023
I'm not much of a math expert, but I'm pretty sure that MathML is kindo of borked. In any case I think I got a working example in SILE's math variant syntax (an alternative to having it work on MathML directly). The result is that Libertinus Math looks differently there than in Typst. Here are my inputs comparing STIX Two Math with Libertinus Math in both SILE and Typst:
prime.sil):Details
main.typ):Details
Using the SILE side of things to check font versions:
Presumably the Typst example being compiled locally is also picking up the same fonts from my system. I'm honestly not sure if perhaps it is preferring an embedded version or not. Assuming not, that's an interesting difference that suggests you might be right and this is Typst related and not the font.
Enivex commentedon Dec 5, 2023
Even in SILE it looks smaller than I expect, even if the position is more correct. The MathML rendering looks right.
I suspect this is an issue with how the prime is implemented in the font. The same thing is present with Noto Sans Math. There's some info in this issue @alerque
notofonts/math#42
Specifically this comment notofonts/math#42 (comment)
khaledhosny commentedon Dec 6, 2023
This usually happens when the
sstyfeature is not applied as appropriate.Zeta611 commentedon May 19, 2024
I stumbled upon this issue as I use Libertinus Math as my primary math font (in LaTeX). It worked fine in LaTeX (with unicode-math), but is broke in Typst.
I suspect it's an issue in the typst side because directly using the prime unicode character U+2032
′fixes the issue.Comparing all different variations, only
x primeand directly using the prime unicode without^works:lumi-a commentedon May 23, 2024
Following @khaledhosny's comment, using
seems to render primes correctly for me in Typst 0.11.1.
Zeta611 commentedon May 24, 2024
@lumi-a Well, it now works well for$x'$ , but not anymore for $x '$ --it is the opposite now. But the shape & size of the prime is now "normal."
pnkfelix commentedon Jun 25, 2024
On Polytype, the self-proclaimed "Rosetta stone for typesetting engines", I think this issue is manifesting itself.
The second item in their "Sample Gallery" shows Typst output for:
and it really highlights how "bad" the
f'(x)looks when compared to the rendering for sile and xelatex.I don't know if the best response is to suggest to Polytype that they use the
"ssty"mentioned above (or writef primeinstead off'), or if effort should be spent identifying some alternative fixBut since this seems like it might be presenting Typst in a poor light in a fairly visible website (Polytype was recently featured on hackernews), it might be worth looking into.
khaledhosny commentedon Jun 25, 2024
Looking into the code, it seems that Typst expects
sstylookup to be an alternate substitution lookup:typst/crates/typst/src/math/ctx.rs
Line 60 in 45366c0
While in Libertinus Math it is a single substitution lookup. I don’t know why Typst is accessing the raw lookup from ttf_parser, instead of enabling the feature through rustybuzz which should be more bullet-proof.
laurmaedje commentedon Jun 26, 2024
Typst doesn't currently pass single chars in math through rustybuzz and this was patched on top. Maybe we should always go through RB.
khaledhosny commentedon Jun 26, 2024
Yes, I think all text should go through the shaper for consistency.
memeplex commentedon Aug 12, 2024
Related discussion for ConTeXT https://mailman.ntg.nl/archives/list/[email protected]/thread/274EKUHM5JW3Z7Q25SLIF5OLUND4YRN2/
OTOH in pdflatex and xelatex, with or without newtx, it renders fine. I took a look at libertinus-otf and libertinus-type1 package sources and was unable to find anything ssty related.
I'm not sure whether you're planning switching to Libertinus Math alongside #1257 but in that case it would be better to fix this OTB.
Enivex commentedon Aug 12, 2024
I don't think there's any plan to change the math font.
schuelermine commentedon Dec 14, 2024
mkorje commentedon Dec 15, 2024
@schuelermine Could you share the Typst code and compiler version you used to produce that image?
schuelermine commentedon Dec 16, 2024
mkorje commentedon Dec 16, 2024
@schuelermine The changes that fixed this are currently only on the development version. When the next release is made it will be available. You can, in the web app, change the compiler version to the development version.