-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use DejaVu fonts as default for text and mathtext #5214
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
Conversation
@mdboom asked to do a PR to add DejaVu, but did not have a chance to do that yet. I believe this takes care of that, so I won't duplicate. Also, I agree that STIX should be the fallback for missing fonts, when DejaVu does not have them. There is also a LaTeX math font called arev that I use for presentations (using LaTeXit) that looks nice (http://mirrors.rit.edu/CTAN/info/Free_Math_Font_Survey/en/survey.pdf). However, I am not sure how complicated it would be to use in matplotlib. But that may be yet another option that could be used instead of falling back to computer modern. |
Looks good, thanks! |
@hetland: No, this PR does not actually add DejaVu or make it default, it only allows to use AFAIK, the |
I think the idea was to make DejaVu (was Arev) the default font for text I agree that the area package is identical to DejaVu (actually, DejaVu may On Thu, Oct 8, 2015 at 3:16 PM, Victor Zabalza notifications@github.com
Prof. Rob Hetland |
Ok, I'll close your PR and change the title for this one. I'll take a look at consistency with selecting the font for usetex, but if Mathtext is definitely preferred --it's much faster and portable-- but |
Just a comment about TeX fonts: I think http://www.tug.dk/FontCatalogue/mathfonts.html is the most complete list of fonts that have TeX math support. |
<family>Bitstream Vera Sans Mono</family> | ||
</prefer> | ||
</alias> | ||
</fontconfig> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually didn't realize this was here. I think this should be updated to use DejaVu rather than just deleted. It sets the default font types if a user is opting for the font-config mode rather than using matplotlib's own font lookup system.
It's not strictly necessary, but removing this will certainly change behavior for those that are relying on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was part of the Vera release and not being actually used. If it is used I will definitely put it back and modify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any particular reason for removing the old fonts is stead of just adding the new ones and changing the defaults. For all other changes we have made them backwards compatible and added the old default to the classic style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DejaVu are a superset of Bitstream Vera, so it would be redundant to ship them both. The classic style can still have mathtext.fontset : cm
. However, it is true that it might cause problems with matplotlibrc that have been modified to have a single font.sans-serif : Bitstream Vera Sans
rather than a list...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding shipping them both, I just realised that even though the DejaVu fonts are 5.3 MB, the Vera fonts are only 600 KB, so from a distribution size perspective it is not a huge difference shipping them both rather than removing Vera.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jenshnielsen: As @zblz said, since DejaVu is a superset of Vera, using DejaVu whenever Vera is requested should have no visible impact other than missing characters now being present, which I'd call a bugfix, not a behavior change. I don't think there's any benefit to keeping the old font, particularly with font subsetting working so well in all backends.
That said, it might be worth adding a built-in mapping from Vera to DejaVu, so that if a user was explicitly setting Vera (rather than just leaving the defaults), and they don't have it installed system wide, they will get DejaVu and things continue to work. This is the kind of thing where some extra release candidate testing may be necessary to catch all of the environmental gotchas about this change.
Note to distributors: @sandrotosi, @jspaleta, others: I think Debian and Fedora are removing the fonts vendored with matplotlib and requiring the system packages of those fonts instead. Just a heads up that we are changing our main vendored font from "Bitstream Vera" to "DejaVu" and that package requirement will need to be updated as well. (And this is expected to land in matplotlib 2.0) @zblz: This should get a "What's New" entry. |
On Oct 13, 2015 2:36 PM, "Michael Droettboom" notifications@github.com
Is this something they are doing by hand? If so, might this be something |
thanks a ton @mdboom for the heads up! we are indeed (trying to) use the debian font files where possible instead of distributed ones, so it's important to know. @toddrjen yes, at least in debian we are doing it by hand, as we inspect the shipped fonts, then we need to match with the currenctly available debian fonts, add the dependencies to the binary package and then create the symlinks in the mpl namespace |
9282dfc
to
e1c6003
Compare
I have added the mathtext baseline images, squashed a few commits, rebased with master to fix a doc-building warning, and added a what's new file. I have changed a bit the mathtext fontset classes to reuse code and fix the fallback for alternative sized symbols, which was broken (and one of the main reasons to fallback onto STIX). |
The advance of the point glyph in mathtext with this PR is slightly too large. It doesn't happen on regular text. I'll look a bit deeper and try to find the reason. |
To support the classic mpl style Vera should not be removed. Btw wonderful work, i really disliked vera. |
@Tillsten -- DejaVu is a superset of Vera, so that the only difference between the new and old default (for regular text) will be when Vera falls back to CM. That could be argued to be a bug, so I'm not sure we should retain the option of a small character set in the classic mpl style. |
@Tillsten: Deja Vu is the same font as Vera under a new name, with additional glyphs added and bugs fixed (I think historically it was a fork). There is no need to retain the old font for the classic style. |
This should hopefully address the long-reported "Too many open files" error message (Fix matplotlib#3315). To reproduce: On a Mac or Windows box with starvation for file handles (Linux has a much higher file handle limit by default), build the docs, then immediately build again. This will trigger the caching bug. The font cache in the mathtext renderer was broken. It was caching a font file once for every *combination* of font properties, including things like size. Therefore, in a complex math expression containing many different sizes of the same font, the font file was opened once for each of those sizes. Font files are opened and kept open (rather than opened, read, and closed) so that FreeType only needs to load the actual glyphs that are used, rather than the entire font. In an era of cheap memory and fast disk, it probably doesn't matter for our current fonts, but once matplotlib#5214 is merged, we will have larger font files with many more glyphs and this loading time will matter more. The solution here is to do all font file loading in one place and to use `lru_cache` (available since Python 3.2) to do the caching, and to use only the file name and hinting parameters as a cache key. For earlier versions of Python, the functools32 backport package is required. (Or we can discuss whether we want to vendor it).
Yes, I was waiting to rebase on #5306 and regenerate the images. |
#5306 is in so this can be rebased now |
Add mathtext options to use dejavu use dejavusans as default subsuper metric for custom set dejavusans as default mathtext.fontset fix sized alternatives in dejavu mathtext
Add DejaVu as default font change other mentions to default font to DejaVu modify rcsetup and rc template add DejaVu to seaborn styles and examples
see comments in matplotlib#4873 and matplotlib#4987: Primes in stix and DejaVu are already superscripted, so the TeX way of setting a prime as $f^\prime$ results in doubly-superscripted primes. For consistency with TeX, here we use the CM prime symbol.
I rebased, rebuilt with local freetype, and regenerated images, but just realized that there is a problem with some characters in dejavuserif mathtext showing a box rather than falling back to STIX serif. I'll look into it tomorrow. |
Thanks, @zblz. |
I think that the problem was that under FreeType 2.6.1 the TrueType font would return a |
Actually I think the relevant change was |
@mdboom - that makes more sense, I had not checked your latest font PRs. I changed it as you suggested and now everything should be fine. |
Use DejaVu fonts as default for text and mathtext
Use DejaVu fonts as default for text and mathtext
Thanks! |
This needs to be backported to 2.0.x? |
Backported to 2.0.x as 4a2a186 |
In preparation for #4636 and #5128, this PR adds options to use DejaVu fonts as mathtext fonts. In case glyphs are missing, the fallback is STIX, given that they will have a more similar weight than CM.
DejaVu fonts are not included here, they should be added in a PR that sets DejaVu as default replacing Vera (#4636 or replacement). Do not merge before #4636!
edit: this initial message is outdated, the PR does add the DejaVu fonts and mathtext DejaVu options and sets them as default. See below messages for details.