Repository navigation
font_manager: Fixed problems with Path(...).suffix - #12212
Conversation
b66cb41 to
1148d94
Compare
| # is fixed in Py>=3.6.1. | ||
| direc = direc.split("\0", 1)[0] | ||
| path = Path(directory, direc).resolve() | ||
| if path.suffix.lower() in fontext: |
There was a problem hiding this comment.
seems easier to prepend a dot to fontext at line 191 (as in list_fonts)?
There was a problem hiding this comment.
fontext can be either string or tuple of strings, it will require something like:
if isinstance(fontext, str):
fontext = '.' + fontext
else:
fontext = ['.' + ext for ext in fontext]Should I do it?
There was a problem hiding this comment.
You need to make it a list of strings so that we don't get false positives with extensionless files ("" not in [".ttf"] but "" in ".ttf")
Thanks for investigating.
| """ | ||
| fontext = get_fontext_synonyms(fontext) | ||
| return [fname for fname in _call_fc_list() | ||
| if Path(fname).suffix[1:] in fontext] |
There was a problem hiding this comment.
same as above: prepend a dot to fontext
The problem is that `Path(...).suffix` includes the dot, so ``.ttf` in 'ttf'` gives `False`. Also fixed other suffix usages.
1148d94 to
333dad1
Compare
|
Alternatively we can change the output of |
|
It probably shouldn't be public but it's nearly as simple to fix it without changing the API so let's not. |
|
ping @anntzer and @dopplershift about this one in anticipation of 3.0.1 |
…212-on-v3.0.x Backport PR #12212 on branch v3.0.x (font_manager: Fixed problems with Path(...).suffix)
The problem is that
Path(...).suffixincludes the dot, so'.ttf' in ('ttf',)givesFalse.Also fixed problems of other
.suffixusages.