diff --git a/bin/scripts/name_parser/FontnameParser.py b/bin/scripts/name_parser/FontnameParser.py index 248f0d1540..2c5aff4b10 100644 --- a/bin/scripts/name_parser/FontnameParser.py +++ b/bin/scripts/name_parser/FontnameParser.py @@ -7,8 +7,8 @@ class FontnameParser: """Parse a font name and generate all kinds of names""" - def __init__(self, filename, logger): - """Parse a font filename and store the results""" + def __init__(self, fontname, logger): + """Parse a fontname and store the results""" self.parse_ok = False self.use_short_families = (False, False, False) # ( camelcase name, short styles, aggressive ) self.keep_regular_in_family = None # None = auto, True, False @@ -17,7 +17,7 @@ def __init__(self, filename, logger): self.ps_fontname_suff = '' self.short_family_suff = '' self.name_subst = [] - [ self.parse_ok, self._basename, self.weight_token, self.style_token, self.other_token, self._rest ] = FontnameTools.parse_font_name(filename) + [ self.parse_ok, self._basename, self.weight_token, self.style_token, self.other_token, self._rest ] = FontnameTools.parse_font_name(fontname) self.basename = self._basename self.rest = self._rest self.add_name_substitution_table(FontnameTools.SIL_TABLE) diff --git a/bin/scripts/name_parser/FontnameTools.py b/bin/scripts/name_parser/FontnameTools.py index f4a9c13da4..b58d4dde6b 100644 --- a/bin/scripts/name_parser/FontnameTools.py +++ b/bin/scripts/name_parser/FontnameTools.py @@ -5,7 +5,7 @@ import sys class FontnameTools: - """Deconstruct a font filename to get standardized name parts""" + """Deconstruct a fontname to get standardized name parts""" @staticmethod def front_upper(word): @@ -69,15 +69,7 @@ def unify_style_names(style_name): 'text': '', 'ce': 'CE', #'semibold': 'Demi', - 'ob': 'Oblique', - 'it': 'Italic', - 'i': 'Italic', - 'b': 'Bold', 'normal': 'Regular', - 'c': 'Condensed', - 'r': 'Regular', - 'm': 'Medium', - 'l': 'Light', } if style_name in known_names: return known_names[style_name.lower()] @@ -306,8 +298,9 @@ def is_keep_regular(basename): @staticmethod def _parse_simple_font_name(name): - """Parse a filename that does not follow the 'FontFamilyName-FontStyle' pattern""" - # No dash in name, maybe we have blanc separated filename? + """Parse a fontname that does not follow the 'FontFamilyName-FontStyle' pattern""" + # This is the usual case, because the font-patcher usually uses the fullname and + # not the PS name if ' ' in name: return FontnameTools.parse_font_name(name.replace(' ', '-')) # Do we have a number-name boundary? @@ -322,7 +315,8 @@ def _parse_simple_font_name(name): @staticmethod def parse_font_name(name): - """Expects a filename following the 'FontFamilyName-FontStyle' pattern and returns ... parts""" + """Expects a fontname following the 'FontFamilyName-FontStyle' pattern and returns ... parts""" + # This could parse filenames in the beginning but that was never used in production; code removed with this commit name = re.sub(r'\bsemi-condensed\b', 'SemiCondensed', name, 1, re.IGNORECASE) # Just for "3270 Semi-Condensed" :-/ name = re.sub('[_\s]+', ' ', name) matches = re.match(r'([^-]+)(?:-(.*))?', name) @@ -353,19 +347,9 @@ def parse_font_name(name): r'(?:uni-)?1[14]', # GohuFont uni ] - # Sometimes used abbreviations - weight_abbrevs = [ 'ob', 'c', 'm', 'l', ] - style_abbrevs = [ 'it', 'r', 'b', 'i', ] - ( style, weight_token ) = FontnameTools.get_name_token(style, weights) ( style, style_token ) = FontnameTools.get_name_token(style, styles) ( style, other_token ) = FontnameTools.get_name_token(style, other, True) - if (len(style) < 4 - and style.lower() != 'pro'): # Prevent 'r' of Pro to be detected as style_abbrev - ( style, weight_token_abbrevs ) = FontnameTools.get_name_token(style, weight_abbrevs) - ( style, style_token_abbrevs ) = FontnameTools.get_name_token(style, style_abbrevs) - weight_token += weight_token_abbrevs - style_token += style_token_abbrevs while 'Regular' in style_token and len(style_token) > 1: # Correct situation where "Regular" and something else is given style_token.remove('Regular') diff --git a/font-patcher b/font-patcher index 0434458ea2..f471cf4a51 100755 --- a/font-patcher +++ b/font-patcher @@ -6,7 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals # Change the script version when you edit this script: -script_version = "4.3.2" +script_version = "4.3.3" version = "3.0.1" projectName = "Nerd Fonts"