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
mathtext: Use DejaVu display symbols when available #5612
Conversation
Wow. This is super helpful. Very cool.
That's a good idea. Linux packagers will probably want to remove our DejaVu and substitute their own package. Providing our own custom fonts for just these extra characters is going to be much better received than modifying DejaVu directly.
I think
I agree. They look much much better. |
I added a small usage string for |
Maybe also add a note that fontforge must be installed... |
c0dbdd2
to
10dedd8
Compare
In the end I added a small script that makes the two calls to subset.py and checks before that fontforge is importable. |
10dedd8
to
214e388
Compare
214e388
to
d540f43
Compare
mathtext: Use DejaVu display symbols when available
Backported to 2.0.x as a77bb83 |
mathtext: Use DejaVu display symbols when available
With the new DejaVu font default many of the symbols (most notably the integral, product, and summation symbol) are very small, as they are designed for inline math. The DejaVu fonts include display-sized variants for some of the math symbols outside of the unicode range. According to @mdboom, it is currently non-trivial to access these variants in a consistent manner from matplotlib, so here I did a bit of hack so we can always access them:
.display
and move them to the unicode index corresponding to the regular glyph. I created two ttf files with this:DejaVuSansDisplay.ttf
andDejaVuSerifDisplay.ttf
. The family names have an additionalDisplay
at the end to differentiate them from the regular fonts. These are pretty small, as they only have a dozen characters.subset.py
with the fonts inlib/matplotlib/mpl-data/fonts/ttf
. I think it's good to keep it so this modification can be done in the future if we update the version of DejaVu fonts, but I am not sure this is the right place. A better location might betools
. Ideas? It has an Apache license, so AFAICT it's ok to distribute it.mathtext.py
will now look first for a glyph in the display version of the fonts (I have added them as fontnameex
, following thecmex
example), and if not found will use the regular version.The baseline images definitely look better, specially the ones that include fractions and integrals.