Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Cleanup font_manager.#15250
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.
Cleanup font_manager.#15250
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -941,12 +941,11 @@ def _normalize_font_family(family): | ||
class FontManager: | ||
""" | ||
On import, the `FontManager` singleton instance creates a list of ttf and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. These refs need leading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. no, because we're refering to stuff in the same module There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That is correct. Personally, I put dots almost everywhere because I usually don't know or care to check if the the reference lives in the same module. | ||
afm fonts and caches their `FontProperties`. The `FontManager.findfont` | ||
method does a nearest neighbor search to find the font that most closely | ||
matches the specification. If no good enough match is found, the default | ||
font is returned. | ||
""" | ||
# Increment this version number whenever the font cache data | ||
# format or behavior has changed and requires a existing font | ||
@@ -1196,12 +1195,15 @@ def findfont(self, prop, fontext='ttf', directory=None, | ||
directory : str, optional | ||
If given, only search this directory and its subdirectories. | ||
fallback_to_default : bool | ||
If True, will fallback to the default font family (usually | ||
"DejaVu Sans" or "Helvetica") if the first lookup hard-fails. | ||
rebuild_if_missing : bool | ||
Whether to rebuild the font cache and search again if the first | ||
match appears to point to a nonexisting font (i.e., the font cache | ||
contains outdated entries). | ||
Returns | ||
------- | ||
@@ -1225,7 +1227,6 @@ def findfont(self, prop, fontext='ttf', directory=None, | ||
.. _fontconfig patterns: | ||
https://www.freedesktop.org/software/fontconfig/fontconfig-user.html | ||
""" | ||
# Pass the relevant rcParams (and the font manager, as `self`) to | ||
# _findfont_cached so to prevent using a stale cache entry after an | ||
@@ -1282,7 +1283,8 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default, | ||
prop.get_family(), self.defaultFamily[fontext]) | ||
default_prop = prop.copy() | ||
default_prop.set_family(self.defaultFamily[fontext]) | ||
return self.findfont(default_prop, fontext, directory, | ||
fallback_to_default=False) | ||
else: | ||
# This is a hard fail -- we can't find anything reasonable, | ||
# so just return the DejaVuSans.ttf | ||
@@ -1300,7 +1302,7 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default, | ||
'findfont: Found a missing font file. Rebuilding cache.') | ||
_rebuild() | ||
return fontManager.findfont( | ||
prop, fontext, directory,rebuild_if_missing=False) | ||
else: | ||
raise ValueError("No valid font could be found") | ||