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
Also the tilde on the a is slightly away from the center, but this is especially visible on the f and the y (and perhaps some other characters too, w, ...?).
They look centered to me (and that is what I believe is done in the accent function in mathtext.py), but our eye is very good at correcting for tilt of the main letter. Maybe we could try a correction so that on tilted letter the accents are right-aligned?
I gave it a shot trying various combinations of right-aligned and introducing padding as a function of the letter height above x-height. However, I didn't manage to find a way that didn't also introduce problems in other letter that look good now. There must be a way, though, so I will try again at some point.
In any case, I'm not sure whether this should hold 2.0. @mdboom?
This is just a shot in the dark: Some TTF fonts do have "Italic Angle" stored as metadata, which is accessible in our wrapper as the fifth element of get_ps_font_info(). Maybe that is useful?
(top: mathtext, mid: usetex, bottom: checking that FreeType handles decomposed characters just fine)
My guess is that a fix would be to run <accent> + <character> through unicodedata.normalize("NFC", ...) to get (if possible) a single precomposed character instead (https://en.wikipedia.org/wiki/Precomposed_character), when that character exists (both as unicode and as a glyph in the font). Or alternatively apparently FreeType is able to compose the characters itself (per the last line), not sure if we can use that.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
tacaswell commentedon Jul 5, 2015
attn @mdboom Is there anything we can do about this in the current text render? It looks like the accent is aligned with the left edge.
tacaswell commentedon Feb 15, 2016
Closing as this now looks correct in 1.5.1
themiurgo commentedon Feb 16, 2016
Doesn't look correct on my machine, running 1.5.1. Could you try the following snippet it on your machine, too?
tacaswell commentedon Feb 16, 2016
I was looking at the docs which look ok both for 1.5.1 and current master
http://matplotlib.org/users/mathtext.html#accents
http://matplotlib.org/devdocs/users/mathtext.html#accents
but they do not hit
'f'related to #5999
attn @zblz
themiurgo commentedon Feb 16, 2016
Also the tilde on the
ais slightly away from the center, but this is especially visible on thefand they(and perhaps some other characters too,w, ...?).zblz commentedon Feb 16, 2016
They look centered to me (and that is what I believe is done in the accent function in mathtext.py), but our eye is very good at correcting for tilt of the main letter. Maybe we could try a correction so that on tilted letter the accents are right-aligned?
QuLogic commentedon Feb 16, 2016
Hmm, yes, I think this is probably the same as #5999. For reference, using a very simple LaTeX document:
the accents are shifted a bit to the right in math mode:

It is definitely visible on the
fand very slightly on they.themiurgo commentedon Feb 17, 2016
It's exactly how @QuLogic describes it, in LaTeX the tilde doesn't look right-aligned, but definitely slightly shifted to the right.
efiring commentedon May 2, 2016
@mdboom, @zblz, is there a problem currently? I don't want this to hold up 2.0.
zblz commentedon May 3, 2016
@efiring: This has not been solved yet.
I gave it a shot trying various combinations of right-aligned and introducing padding as a function of the letter height above x-height. However, I didn't manage to find a way that didn't also introduce problems in other letter that look good now. There must be a way, though, so I will try again at some point.
In any case, I'm not sure whether this should hold 2.0. @mdboom?
mdboom commentedon May 9, 2016
This is just a shot in the dark: Some TTF fonts do have "Italic Angle" stored as metadata, which is accessible in our wrapper as the fifth element of
get_ps_font_info(). Maybe that is useful?anntzer commentedon Aug 28, 2020
Another example, which shows that the problem is not just about italic (in roman the accents seem too much to the right:
(top: mathtext, mid: usetex, bottom: checking that FreeType handles decomposed characters just fine)
My guess is that a fix would be to run
<accent> + <character>throughunicodedata.normalize("NFC", ...)to get (if possible) a single precomposed character instead (https://en.wikipedia.org/wiki/Precomposed_character), when that character exists (both as unicode and as a glyph in the font). Or alternatively apparently FreeType is able to compose the characters itself (per the last line), not sure if we can use that.Edit: although that may not work for Computer Modern fonts (which is the OP's case) which has no such combining charachers. I think the long-term solution is to switch to a more modern version of it, which likely means http://www.gust.org.pl/projects/e-foundry/lm-math. In the short term, if one does want to add a code path just for Bakoma (well, for TeX fonts, really), the algorithm is at http://cahiers.gutenberg.eu.org/cg-bin/article/CG_1998___28-29_44_0.pdf; we can either hardcode fontdimen1 (slant) or also extend the Tfm parser already in dviread (see http://www.tug.org/TUGboat/Articles/tb02-1/tb02fuchstfm.pdf) and ship cmmi.tfm; or just extract the fontdimens once and hard-code them.
github-actions commentedon Mar 14, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!