Backport PR #24655 on branch v3.7.x (Update font_manager to only use registry on Win) by meeseeksmachine · Pull Request #24941 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions doc/api/next_api_changes/behavior/24655-AK.rst
17 changes: 6 additions & 11 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,11 @@ def list_fonts(directory, extensions):
recursively under the directory.
"""
extensions = ["." + ext for ext in extensions]
if sys.platform == 'win32' and directory == win32FontDirectory():
return [os.path.join(directory, filename)
for filename in os.listdir(directory)
if os.path.isfile(os.path.join(directory, filename))]
else:
return [os.path.join(dirpath, filename)
# os.walk ignores access errors, unlike Path.glob.
for dirpath, _, filenames in os.walk(directory)
for filename in filenames
if Path(filename).suffix.lower() in extensions]
return [os.path.join(dirpath, filename)
# os.walk ignores access errors, unlike Path.glob.
for dirpath, _, filenames in os.walk(directory)
for filename in filenames
if Path(filename).suffix.lower() in extensions]


def win32FontDirectory():
Expand Down Expand Up @@ -275,7 +270,7 @@ def findSystemFonts(fontpaths=None, fontext='ttf'):
if fontpaths is None:
if sys.platform == 'win32':
installed_fonts = _get_win32_installed_fonts()
fontpaths = MSUserFontDirectories + [win32FontDirectory()]
fontpaths = []
else:
installed_fonts = _get_fontconfig_fonts()
if sys.platform == 'darwin':
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_font_manager.py