-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[without findfont diff] Parsing all families in font_manager #20549
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
I added some inline comments, but my main request would be to add just a little high-level documentation on the proposed design (I talked about this on the call some time ago). How would this change how a user can control fonts? Say, I want to add text that includes both English and Russian, and I want to use two separate fonts. How would I specify the fonts? Or, my last name Of course the full implementation is not there yet so any code samples would be somewhat hypothetical. But having them would increase the confidence that this is solving the right problems, and perhaps guide the implementation so that they would eventually become test cases. Footnote (*): in reality it looks terrible to have the |
^^ Drop in the whole workflow/idea behind the per-glyph font fallback (not a lot of details, but on a user's perspective) |
Things yet to complete:
Apart from these, this PR could still use a re-review (because a major chunk of changes requested were based on |
06913db
to
3855f6c
Compare
3855f6c
to
6ffc56e
Compare
doc/users/fonts.rst
Outdated
|
||
How does Matplotlib achieve this? | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Well, Matplotlib doesn't achieve this, *yet*. It was initially only designed to |
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.
We aim for the writing in the docs to be more formal.
[We also discussed this on the phone]
@@ -1308,6 +1309,100 @@ def findfont(self, prop, fontext='ttf', directory=None, | |||
prop, fontext, directory, fallback_to_default, rebuild_if_missing, | |||
rc_params) | |||
|
|||
def find_fontsprop(self, prop, fontext='ttf', directory=None, |
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.
We talked on the phone about renaming this. The should invoke that is is going at a) find multiple fonts b) that the order of the returned fonts matters.
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.
Some suggestions:
find_fonts
find_orderedfonts
find_fontsdict
find_fontorder
find_fontset
find_fontfamilies
find_orderedfamily
find_familyordered
find_families
find_fontfamilies
I am going to try rebasing this so that we capture the docs. I think the code changes were made redundent by #20740 . |
Closing in favor of #23621 which is this PR rebased, with the code changes dropped and the documentation extended. |
PR Summary
Short Note:
This is a newer and more dynamic approach than #20496, which changed findfont's API, thus breaking a lot of backends.
A much more flexible approach would be to gradually move the different backends to
find_fontsprop
instead offindfont
, since the new function is built over the existing API and acts as a middleware.Quoting previous PR:
This is the beginning of migrating from Matplotlib's "Font-First" approach to a "Text-First" approach.
The very first step is to parse all families in font manager. Previously, we only parsed families until we find a font file, and the rest of the backends are accustomed to just a single font file (which needs changing)
OrderedDict would contain fonts defined by font.family
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).