From 01569cad8e2cb5e3211d44e84f1ce94b6ce88349 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Sat, 7 Oct 2023 12:44:35 +0200 Subject: [PATCH] name_parser: Fix weight_string_to_number() [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 --- bin/scripts/name_parser/FontnameTools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/scripts/name_parser/FontnameTools.py b/bin/scripts/name_parser/FontnameTools.py index 93904d3254..2e848eed62 100644 --- a/bin/scripts/name_parser/FontnameTools.py +++ b/bin/scripts/name_parser/FontnameTools.py @@ -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