Skip to content

Commit 31a5341

Browse files
committed
name-parser: Sort Widths before Weights
Signed-off-by: Fini Jastrow <[email protected]>
1 parent f2862d4 commit 31a5341

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bin/scripts/name_parser/FontnameTools.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,12 @@ def parse_font_name(name):
393393
# Weights end up as Typographic Family parts ('after the dash')
394394
# Styles end up as Family parts (for classic grouping of four)
395395
# Others also end up in Typographic Family ('before the dash')
396+
widths = [ m + s
397+
for s in list(FontnameTools.known_widths)
398+
for m in list(FontnameTools.known_modifiers) + ['']
399+
]
396400
weights = [ m + s
397-
for s in list(FontnameTools.known_weights2) + list(FontnameTools.known_widths)
401+
for s in list(FontnameTools.known_weights2)
398402
for m in list(FontnameTools.known_modifiers) + [''] if m != s
399403
] + list(FontnameTools.known_weights1) + list(FontnameTools.known_slopes)
400404
weights = [ w for w in weights if w not in FontnameTools.known_styles ]
@@ -408,9 +412,11 @@ def parse_font_name(name):
408412
r'(?:uni-)?1[14]', # GohuFont uni
409413
]
410414

415+
( style, width_token ) = FontnameTools.get_name_token(style, widths)
411416
( style, weight_token ) = FontnameTools.get_name_token(style, weights)
412417
( style, style_token ) = FontnameTools.get_name_token(style, FontnameTools.known_styles)
413418
( style, other_token ) = FontnameTools.get_name_token(style, other)
419+
weight_token = width_token + weight_token
414420
while 'Regular' in style_token and len(style_token) > 1:
415421
# Correct situation where "Regular" and something else is given
416422
style_token.remove('Regular')

0 commit comments

Comments
 (0)