Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Support (first font of) TTC files.#9787
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
anntzer commentedNov 15, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
77c0e34
tob67da2b
CompareCould one use something like |
I'd rather just do it properly and switch everything to (pathname, index) (which is the standard representation FreeType uses, seehttps://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_New_Face (pathname, face_index)). But that's out of scope for this PR. |
3ea2f9a
tod653bc1
Compareclouds56 commentedNov 25, 2018
What's blocking? May I help here? |
We need a second positive review from one of the matplotlib reviewers before the PR can be merged. @anntzer Travis Python 3.7 now fails with:
This has to be investigated before merging. Is the font missing there? |
That's because I need to temporarily force the use of new font caches. Added a second commit that does so; then we can later revert that commit. |
72d25de
toccd00ac
CompareSome of the metadata seems to end up wrong when using this. FT2Font.get_sfnt() gives back garbage on most (with a few odd exceptions) .TTC fonts. This makes certain fonts inaccessible - in my specific case, I'm asking for Microsoft YaHei and ending up with Microsoft YaHeilight, and there's no way to specifically get the normal weight version. |
I guess that may be because YaHei has the light font at index 0 and the regular one at index 1? (I don't have access to it.) |
Stephen-Chilcote commentedDec 6, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
No, light and normal are separate TTCs (the whole point of .ttc is that it efficiently stores fonts that have many of the same glyphs; packing completely different versions of the same font doesn't do you any good.) The problem is that MatPlotLib can't load their metadata aside from the font family and sees them as identical. YaHei should come preinstalled on every Windows machine with 8 or later. I see similar issues with most .ttcs on my system, though maybe it's something unique Microsoft is doing. I only saw it work correctly with non-CJK fonts though I imagine that's coincidence. |
Oh, I see. I think it's basically the same issue as#8550? (in which case once again it's orthogonal to ttc support) |
Stephen-Chilcote commentedDec 6, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
No; it's the same end result, but in that case the issue was failure to correctly interpret the metadata, whereas here the metadata comes back as junk. The font is named "YaHei Light;" if it could read the name it would assign it the correct weight, it just can't read the name. With a conditional breakpoint on font_manager.py:342 with the condition set to |
No, the family name (as loaded by FreeType into the family_name field of FT_FaceRec) is 'Microsoft YaHei'. |
Stephen-Chilcote commentedDec 6, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ah, I get it now. Okay, this is a Microsoft being weird issue, not a .ttc issue. Weird how it worked before the .ttc switch, but it's not your problem. Thanks for the info. |
TTC is a TrueType Collection file (a collection of TTFs). Currently,ft2font only supports getting the first font from the collection, andneither the pdf nor ps backends are able to use them (due to limitationsof ttconv). Still, it seems better than nothing to support them for Aggand SVG (that comes for free via FreeType).
jklymak commentedJan 4, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@anntzer Looks like you need to do a commit/revert dance on this PR because of the cache? If so, I think you can self-merge, and then do the revert commit soon after? (not sure how big a deal it is to leave master in an uncahched state) |
I'll open a PR to restore the cache (that's what tests that the cache actually works...) immediately after this is merged (e.g. by you? :)). |
Sure, I just wanted to make sure you were around to do it. If now is good, here it goes... |
TTC is a TrueType Collection file (a collection of TTFs). Currently,
ft2font only supports getting the first font from the collection, and
neither the pdf nor ps backends are able to use them (due to limitations
of ttconv). Still, it seems better than nothing to support them for Agg
and SVG (that comes for free via FreeType).
xref#3135,#3912.
PR Summary
PR Checklist