| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Sorry, something went wrong.
|
Could one use something like pathname[1] as caching key if there are multiple fonts in a file? |
Sorry, something went wrong.
|
I'd rather just do it properly and switch everything to (pathname, index) (which is the standard representation FreeType uses, see https://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. |
Sorry, something went wrong.
|
What's blocking? May I help here? |
Sorry, something went wrong.
|
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: ________________________________ test_find_ttc _________________________________
[gw1] linux -- Python 3.7.0 /home/travis/virtualenv/python3.7.0/bin/python
@pytest.mark.xfail(not os.environ.get("TRAVIS"), reason="Font may be missing.")
def test_find_ttc():
fp = FontProperties(family=["WenQuanYi Zen Hei"])
font = findfont(fp)
> assert os.path.basename(font) == "wqy-zenhei.ttc"
E AssertionError: assert 'DejaVuSans.ttf' == 'wqy-zenhei.ttc'
E - DejaVuSans.ttf
E + wqy-zenhei.ttc
lib/matplotlib/tests/test_font_manager.py:106: AssertionError
This has to be investigated before merging. Is the font missing there? |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
Some 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 YaHei light, and there's no way to specifically get the normal weight version. |
Sorry, something went wrong.
|
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.) |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Oh, I see. I think it's basically the same issue as #8550? (in which case once again it's orthogonal to ttc support) |
Sorry, something went wrong.
|
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 'ttc' in font.fname, I see sfnt full of unreadable bytes, as opposed to when it loads a .ttf font where it's full of ASCII strings. Do you not see this same behavior? |
Sorry, something went wrong.
|
No, the family name (as loaded by FreeType into the family_name field of FT_FaceRec) is 'Microsoft YaHei'. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
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).
|
@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) |
Sorry, something went wrong.
|
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? :)). |
Sorry, something went wrong.
|
Sure, I just wanted to make sure you were around to do it. If now is good, here it goes... |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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