| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
This seems too simple to be true... Do you know of an open ttc font we can install on travis (either by 'hand' or through apt-get)? |
Sorry, something went wrong.
|
It looks like freetype does indeed do this for us, it looks like for free! http://www.freetype.org/freetype2/ |
Sorry, something went wrong.
|
There are some widely used free chinese fonts: package 'ttf-wqy-zenhei' and 'ttf-wqy-microhei' in ubuntu repo. They are located in /usr/share/fonts/truetype/wqy after installation. |
Sorry, something went wrong.
|
matplotlib.rcParams['font.family'] = 'WenQuanYi Zen Hei' |
Sorry, something went wrong.
|
Can you put together an image test with Chinese labels? Please don't spend too much time on it until feedback from @mdboom (is this a bad idea?). |
Sorry, something went wrong.
|
However test_font_priority failed in my system(cmmi10.ttf is available) |
Sorry, something went wrong.
|
Ah, your test is much better than what I had in mind 👍 |
Sorry, something went wrong.
|
I think you will have to modify the .travis.yaml file to install which ever ubuntu package installs Zen Hei. The default vms are very bare bones. |
Sorry, something went wrong.
|
Specifically, just add the proper package to https://github.com/matplotlib/matplotlib/blob/master/.travis.yml#L27 |
Sorry, something went wrong.
|
This does work for Agg and SVG, but it doesn't work for PDF or PS. (Didn't check macosx, but it has a completely different code path for fonts, so we'd need to check that, too). There are two ways fonts are handled in PDF and PS in matplotlib. One, is we just shove the whole font file in the output. This works only for "standard" ttf fonts, not ttc (which is a TrueType collection -- really just a packaging of multiple ttf fonts). The other way is that we subset the font and convert it to a Type 3 font and save that in the file. For this, we use the ttconv library, which only supports regular TTF files. So, we can commit this now, but we'd, at a minimum, need to add checks to not use these fonts when outputting PDF or PS. The long term plan is to move the font subsetting to a new implementation similar to what SVG does, where it just gets the curves from FreeType (and thus would support any font that FreeType supports, which is very comprehensive). That would let us put any kind of font in PDF and SVG. Just haven't found the resources to do that yet. |
Sorry, something went wrong.
|
I should also add a couple of things about the test: This test will fail if this special font isn't installed. That's fine for Travis, but for end-user-developers, there will always be a failing test. The test should instead check for the presence of the file, and not finding it, mark as xfail. Also, the test should actually do something with the font -- that would catch the brokenness on PDF. |
Sorry, something went wrong.
|
I don't know how to achieve this right now. It will take me some time to be more familiar with matplotlib codebase. Or we can merge this pull request for now( the font is loaded but #3135 with pdf issue unsolved) , and let some one more familiar to add this logic. @mdboom test_font_priority will also fail if a special font ('cmmi10.ttf') is not installed. |
Sorry, something went wrong.
|
@tacaswell: I don't think we should merge this without fixing the pdf/ps issues. I might be able to find some time in the near future to add this. Having looked at this problem even more, it seems this fix only allows one to access the first font in a ttc file. So, even as ttc support, I'd say this is pretty limited. As much as it isn't great, I think the recommendation for users at this time should be to split the ttc file into separate ttf files, using a tool such as fontforge, and pull them into matplotlib that way. @luoq: test_font_priority relies on a font that ships with cmmi10.ttf, so it's guaranteed to always be found. Not so with the ttc font in the new test. |
Sorry, something went wrong.
|
Superseded by #9787.. Thanks for getting the ball rolling... |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
solve #3135
I found this solution in various web posts.
You may need to clean the cache in ~/.cache/matplotlib.