Skip to content

Commit 4756fa2

Browse files
authored
Merge pull request #22909 from Croadden/main
FIX: skip sub directories when finding fonts on windows
2 parents aa6e797 + e800616 commit 4756fa2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/matplotlib/font_manager.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,16 @@ def list_fonts(directory, extensions):
196196
recursively under the directory.
197197
"""
198198
extensions = ["." + ext for ext in extensions]
199-
return [os.path.join(dirpath, filename)
200-
# os.walk ignores access errors, unlike Path.glob.
201-
for dirpath, _, filenames in os.walk(directory)
202-
for filename in filenames
203-
if Path(filename).suffix.lower() in extensions]
199+
if sys.platform == 'win32' and directory == win32FontDirectory():
200+
return [os.path.join(directory, filename)
201+
for filename in os.listdir(directory)
202+
if os.path.isfile(filename)]
203+
else:
204+
return [os.path.join(dirpath, filename)
205+
# os.walk ignores access errors, unlike Path.glob.
206+
for dirpath, _, filenames in os.walk(directory)
207+
for filename in filenames
208+
if Path(filename).suffix.lower() in extensions]
204209

205210

206211
def win32FontDirectory():

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy