-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Accents positioning looks wrong #4561
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
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. |
Closing as this now looks correct in 1.5.1 |
Doesn't look correct on my machine, running 1.5.1. Could you try the following snippet it on your machine, too? import matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set_xlabel(r'$\tilde{f}$', fontsize=24)
ax.set_ylabel(r'$\tilde{y}$', fontsize=24)
ax.set_title("matplotlib " + matplotlib.__version__)
fig.tight_layout() |
I was looking at the docs which look ok both for 1.5.1 and current master http://matplotlib.org/users/mathtext.html#accents but they do not hit related to #5999 attn @zblz |
Also the tilde on the |
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? |
Hmm, yes, I think this is probably the same as #5999. For reference, using a very simple LaTeX document: \documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
Text: \~f \~y
\vspace*{1cm}
Math: $\tilde{f} \tilde{y}$
\end{document} the accents are shifted a bit to the right in math mode: |
It's exactly how @QuLogic describes it, in LaTeX the tilde doesn't look right-aligned, but definitely slightly shifted to the right. |
@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? |
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 |
Another example, which shows that the problem is not just about italic (in roman the accents seem too much to the right: from pylab import *
figtext(.49, .7, r"$\mathrm{\ddot{e}\acute{e}\grave{e}\hat{e}\breve{e}\bar{e}\tilde{n}}$",
ha="right", size=30)
figtext(.51, .7, "ëéèêĕēñ", ha="left", size=30)
figtext(.49, .5, r"$\mathsf{\ddot{e}\acute{e}\grave{e}\hat{e}\breve{e}\bar{e}\tilde{n}}$",
ha="right", size=40, usetex=True)
figtext(.51, .5, "ëéèêĕēñ", ha="left", size=40, usetex=True)
figtext(.49, .3, "e" + chr(0x302), ha="right", size=30)
figtext(.51, .3, chr(0xea), ha="left", size=30)
show()
My guess is that a fix would be to run 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. |
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! |
Accents seem positioned wrongly on top of letters.
This is already visible in the documentation, but it's perhaps more evident with some letters, like
f
, than with others.How it looks:

how it should look:

The text was updated successfully, but these errors were encountered: