name-parser: Fix Oblique handling

[why]
Oblique is not detected correctly anymore.

[how]
With commit
  ae656bad8 name-parser: Further formalize style handling

'Oblique' has been taken out of the direct 'known_names' which has been
replaced by a more detailed list of known name parts. It ended up in
known_slopes.

But known_sloped is not taken into consideration as 'weight' when parsing
the font name - no it ends up in 'rest'.

This has been obviously overlooked.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-04-24 14:28:45 +02:00
parent fd416d480d
commit f603633536
2 changed files with 3 additions and 3 deletions

View file

@ -47,8 +47,7 @@ class FontnameParser:
if not self.use_short_families[0]: if not self.use_short_families[0]:
return (self.basename, self.rest) return (self.basename, self.rest)
else: else:
rest = self.rest.replace('Oblique', 'Obl') return (FontnameTools.concat(self.basename, self.rest).replace(' ', ''), '')
return (FontnameTools.concat(self.basename, rest).replace(' ', ''), '')
def set_keep_regular_in_family(self, keep): def set_keep_regular_in_family(self, keep):
"""Familyname may contain 'Regular' where it should normally be suppressed""" """Familyname may contain 'Regular' where it should normally be suppressed"""
@ -195,6 +194,7 @@ class FontnameParser:
aggressive = self.use_short_families[2] aggressive = self.use_short_families[2]
if self.use_short_families[1]: if self.use_short_families[1]:
[ other, weight ] = FontnameTools.short_styles([ other, weight ], aggressive) [ other, weight ] = FontnameTools.short_styles([ other, weight ], aggressive)
weight = [ w if w != 'Oblique' else 'Obl' for w in weight ]
return FontnameTools.concat(name, rest, other, self.short_family_suff, weight) return FontnameTools.concat(name, rest, other, self.short_family_suff, weight)
def subfamily(self): def subfamily(self):

View file

@ -338,7 +338,7 @@ class FontnameTools:
weights = [ m + s weights = [ m + s
for s in list(FontnameTools.known_weights2) + list(FontnameTools.known_widths) for s in list(FontnameTools.known_weights2) + list(FontnameTools.known_widths)
for m in list(FontnameTools.known_modifiers) + [''] if m != s for m in list(FontnameTools.known_modifiers) + [''] if m != s
] + list(FontnameTools.known_weights1) ] + list(FontnameTools.known_weights1) + list(FontnameTools.known_slopes)
styles = [ 'Bold', 'Italic', 'Regular', 'Normal', ] styles = [ 'Bold', 'Italic', 'Regular', 'Normal', ]
weights = [ w for w in weights if w not in styles ] weights = [ w for w in weights if w not in styles ]
# Some font specialities: # Some font specialities: