Skip to content

Commit

Permalink
name_parser: Fix weight_string_to_number()
Browse files Browse the repository at this point in the history
[why]
Some PS weights have a dash in the weight, like 'Extra-Light' in
Iosevka. The parser can not parse it because it expects 'ExtraLight'.

[how]
Filter out all '-' and ' ' from the PS weight string before actually
parsing the string.

Signed-off-by: Fini Jastrow <[email protected]>
  • Loading branch information
Finii committed Oct 7, 2023
1 parent 89f1325 commit 01569ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/scripts/name_parser/FontnameTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ def weight_string_to_number(w):
""" Convert a common string approximation to a PS/2 weight value """
if not isinstance(w, str) or len(w) < 1:
return 400
w = w.lower().replace('-', '').replace(' ', '')
for num, strs in FontnameTools.equivalent_weights.items():
if w.lower() in strs:
if w in strs:
return num
return None

Expand Down

0 comments on commit 01569ca

Please sign in to comment.