Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1148d94

Browse files
committed
font_manager: Fixed problems with Path(...).suffix
The problem is that `Path(...).suffix` includes the dot, so ``.ttf` in 'ttf'` gives `False`. Also fixed other suffix usages.
1 parent 6b4048d commit 1148d94

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def list_fonts(directory, extensions):
154154
extensions = ["." + ext for ext in extensions]
155155
return [str(path)
156156
for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
157-
if path.suffix in extensions]
157+
if path.suffix.lower() in extensions]
158158

159159

160160
def win32FontDirectory():
@@ -201,7 +201,7 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
201201
# is fixed in Py>=3.6.1.
202202
direc = direc.split("\0", 1)[0]
203203
path = Path(directory, direc).resolve()
204-
if path.suffix.lower() in fontext:
204+
if path.suffix.lower().split('.', 1)[-1] in fontext:
205205
items.add(str(path))
206206
return list(items)
207207
except (OSError, MemoryError):
@@ -242,7 +242,7 @@ def get_fontconfig_fonts(fontext='ttf'):
242242
"""
243243
fontext = get_fontext_synonyms(fontext)
244244
return [fname for fname in _call_fc_list()
245-
if Path(fname).suffix[1:] in fontext]
245+
if Path(fname).suffix.lower().split('.', 1)[-1] in fontext]
246246

247247

248248
def findSystemFonts(fontpaths=None, fontext='ttf'):

0 commit comments

Comments
 (0)