Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
QuLogic merged 1 commit intomatplotlib:masterfromanntzer:font_manager
Sep 18, 2019
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletionslib/matplotlib/font_manager.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -941,12 +941,11 @@ def _normalize_font_family(family):

class FontManager:
"""
On import, the :class:`FontManager` singleton instance creates a
list of TrueType fonts based on the font properties: name, style,
variant, weight, stretch, and size. The :meth:`findfont` method
does a nearest neighbor search to find the font that most closely
matches the specification. If no good enough match is found, a
default font is returned.
On import, the `FontManager` singleton instance creates a list of ttf and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These refs need leading., no?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

no, because we're refering to stuff in the same module

Copy link
Member

Choose a reason for hiding this comment

The 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
Expand DownExpand Up@@ -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 no match
is found.
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
-------
Expand All@@ -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
Expand DownExpand Up@@ -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, False)
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
Expand All@@ -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,True,False)
prop, fontext, directory,rebuild_if_missing=False)
else:
raise ValueError("No valid font could be found")

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp