Skip to content

Commit

Permalink
name-parser: Sort Widths before Weights
Browse files Browse the repository at this point in the history
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
  • Loading branch information
Finii committed Apr 2, 2024
1 parent f2862d4 commit 31a5341
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bin/scripts/name_parser/FontnameTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,12 @@ def parse_font_name(name):
# Weights end up as Typographic Family parts ('after the dash')
# Styles end up as Family parts (for classic grouping of four)
# Others also end up in Typographic Family ('before the dash')
widths = [ m + s
for s in list(FontnameTools.known_widths)
for m in list(FontnameTools.known_modifiers) + ['']
]
weights = [ m + s
for s in list(FontnameTools.known_weights2) + list(FontnameTools.known_widths)
for s in list(FontnameTools.known_weights2)
for m in list(FontnameTools.known_modifiers) + [''] if m != s
] + list(FontnameTools.known_weights1) + list(FontnameTools.known_slopes)
weights = [ w for w in weights if w not in FontnameTools.known_styles ]
Expand All @@ -408,9 +412,11 @@ def parse_font_name(name):
r'(?:uni-)?1[14]', # GohuFont uni
]

( style, width_token ) = FontnameTools.get_name_token(style, widths)
( style, weight_token ) = FontnameTools.get_name_token(style, weights)
( style, style_token ) = FontnameTools.get_name_token(style, FontnameTools.known_styles)
( style, other_token ) = FontnameTools.get_name_token(style, other)
weight_token = width_token + weight_token
while 'Regular' in style_token and len(style_token) > 1:
# Correct situation where "Regular" and something else is given
style_token.remove('Regular')
Expand Down

0 comments on commit 31a5341

Please sign in to comment.