-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: mathtext not always rendering combining accents in the same way #23257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It looks like this happens with all fonts. I don't think it's specific to the SVG and PDF backends, since the differences in rendering are visible in the plot window. (I am using the GTK3Agg backend.)
The root of the problem is the difference in the way matplotlib/lib/matplotlib/_mathtext.py Lines 2122 to 2124 in c936ef5
By default, an |
Good catch. The behavior of |
I think that it is an error, yes. At least https://www.ctan.org/pkg/comprehensive writes with {} around the character for accents. (And I always was under the impression that it is the same, but indeed a less authoritative source...) Indeed a good catch @tfpf ! |
I agree with oscargus. LaTeX does not add that extra space at the end, so the behaviour of matplotlib/lib/matplotlib/_mathtext.py Line 2067 in c936ef5
The italic correction messes up the placement (which isn't obvious unless the text under the accent is long), while the extra space at the end is responsible for the difference between I should add that the point about the italic correction has already been noted in #19299. |
I think that #23189 actually solves this (and explains one of the failing tests). One can probably make a simpler patch that just handles this, something like: if not isinstance(sym, Char):
sym = sym.children[0] if it is expected that #23189 will take a long time to get ready (I think that it is probably worthwhile to spend the effort there if we are still planning to "break" how the accents are rendered...). |
This works well! However, if the group contains another group nested inside it (e.g. |
Yeah, you are right. Probably better to do something like: while isinstance(sym, Hlist):
sym = sym.children[0] |
Bug summary
In the reference figure https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_dejavuserif_00.pdf
the dot above the s is differently positioned. Not clear why as the expressions are
\dot s
and\dot{s}
respectively. This doesn't happen to all fonts (maybe only this?).It also happens in the svg image, although not as clear. Looking at the source, the x-position difference between the accent and character is 54.4 for the left and 57.5 for the right.
Code for reproduction
Actual outcome
Different rendering
Expected outcome
Identical rendering
Additional information
No response
Operating system
No response
Matplotlib Version
3.6.0.dev2642+g25292618a9.d20220612
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
git checkout
The text was updated successfully, but these errors were encountered: