[without findfont diff] Parsing all families in font_manager #20549
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 |
doc/users/fonts.rst
Outdated
|
||
How does Matplotlib achieve this? | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Well, Matplotlib doesn't achieve this, *yet*. It was initially only designed to |
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, |
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.
Some suggestions:
find_fonts
find_orderedfonts
find_fontsdict
find_fontorder
find_fontset
find_fontfamilies
find_orderedfamily
find_familyordered
find_families
find_fontfamilies
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).The text was updated successfully, but these errors were encountered: