-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
WIP: Fix font selection #8800
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
WIP: Fix font selection #8800
Conversation
@@ -93,19 +93,26 @@ | |||
'ultra-expanded' : 900} |
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.
looks like you chmod+x'd the file accidentally.
lib/matplotlib/_tff_header_parse.py
Outdated
@@ -0,0 +1,401 @@ | |||
|
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 guess it was supposed to be called "_ttf_header_parse.py" (not tff)
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.
Yes, that would explain why imports were failing on me...
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 this always meant to be parsed with Python 3?
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.
It should be both py2 and py3 (but I work in 3 day-to-day). Did I accidentally use a py3 only feature?
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.
the lgtm PR check is flagging some encoding issue. Python 2 uses ascii
by default and Python 3 utf-8
so that would explain why that's not an issue for you, but in a 2 environment I think this would be a problem
Try get font information from Platform 3(Windows Unicode) if no information got from Platform 1, encoding 0(Mac Roman)
8651610
to
7a9183f
Compare
7a9183f
to
75aa38b
Compare
In things that are fun, I think I found a bug in the metadata in the ubuntu fonts
not that the family_name / sub family is inconsistent. One place it is ('Ubuntu', 'Medium') and another it is ('Ubuntu Light', 'Bold'), hence the extra cut-out. Have to sort out where upstream is to report a bug.... |
- “ -> " - ” -> " - ’ -> ' - — -> - copy-paste from websites is exciting!
FWIW, another case that would be nice to cover is the bold face in the computer modern unicode font (https://ctan.org/pkg/cm-unicode?lang=en, also available as ttf elsewhere online) which has a family name of "CMU Serif Bold Extended Roman"); the line
in font_manager.py will currently match the font as either weight = 500 (roman) or weight = 700 (bold) depending on the order of iteration on the weight_dict dictionary :-) (on Py3.6+, this means roman (which is incorrect), as it comes first in the dict). |
See also https://github.com/anntzer/mplfccache which relies on fontconfig to generate (once) the matplotlib font cache. |
Also https://github.com/anntzer/freetypybind/blob/master/lib/freetypybind/query_face.py#L499 for what is I think a mostly complete reimplementation of what fontconfig does, plus support for some common language tags (python ships a bunch of encodings without actually documenting them anywhere afaict (https://github.com/python/cpython/tree/master/Lib/encodings) :-)) |
Closing as very old and @anntzer has the font config algorithm in python. |
This pulls the commits from #8607 and #8551 together and starts to add starts to add code to standardize extracting the weight and style from the 4 places it could be stashed
Eventually this the weight / style selection code will look something like
attn @cy18 @Rufflewind