Skip to content

font_manager: Fixed problems with Path(...).suffix #12212

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2018
Merged
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
8 changes: 4 additions & 4 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def list_fonts(directory, extensions):
extensions = ["." + ext for ext in extensions]
return [str(path)
for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
if path.suffix in extensions]
if path.suffix.lower() in extensions]


def win32FontDirectory():
Expand Down Expand Up @@ -187,7 +187,7 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
if directory is None:
directory = win32FontDirectory()

fontext = get_fontext_synonyms(fontext)
fontext = ['.' + ext for ext in get_fontext_synonyms(fontext)]

items = set()
for fontdir in MSFontDirectories:
Expand Down Expand Up @@ -240,9 +240,9 @@ def _call_fc_list():
def get_fontconfig_fonts(fontext='ttf'):
"""List the font filenames known to `fc-list` having the given extension.
"""
fontext = get_fontext_synonyms(fontext)
fontext = ['.' + ext for ext in get_fontext_synonyms(fontext)]
return [fname for fname in _call_fc_list()
if Path(fname).suffix[1:] in fontext]
if Path(fname).suffix.lower() in fontext]


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