Skip to content

Commit

Permalink
Fixes #1879: Properly decode filenames that we get from fc-match
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Apr 18, 2013
1 parent 2920408 commit 2415c62
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/matplotlib/font_manager.py
Expand Up @@ -1289,11 +1289,12 @@ def fc_match(pattern, fontext):
if pipe.returncode == 0:
for match in _fc_match_regex.finditer(output):
file = match.group(1)
file = file.decode(sys.getfilesystemencoding())
if os.path.splitext(file)[1][1:] in fontexts:
return file
return None

_fc_match_regex = re.compile(r'\sfile:\s+"([^"]*)"')
_fc_match_regex = re.compile(rb'\sfile:\s+"([^"]*)"')
_fc_match_cache = {}

def findfont(prop, fontext='ttf'):
Expand Down

4 comments on commit 2415c62

@pferreir
Copy link

Choose a reason for hiding this comment

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

Was that b intentional?

@tacaswell
Copy link
Member

Choose a reason for hiding this comment

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

@mdboom
Copy link
Member Author

@mdboom mdboom commented on 2415c62 Apr 18, 2013

Choose a reason for hiding this comment

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

Yes -- but Python requires it to be br, not rb. Sorry about that.

@pelson
Copy link
Member

@pelson pelson commented on 2415c62 Apr 19, 2013

Choose a reason for hiding this comment

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

Ah - My bad for merging. Thanks for fixing @mdboom

Please sign in to comment.