mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-31 12:27:22 +02:00
name-parser: Rename parameters
[why] The variables' names are not really fitting (anymore). [how] No functional change. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
4394824977
commit
b40995275e
@ -13,9 +13,9 @@ class FontnameParser:
|
|||||||
self.use_short_families = (False, False) # ( camelcase name, short styles )
|
self.use_short_families = (False, False) # ( camelcase name, short styles )
|
||||||
self.keep_regular_in_family = None # None = auto, True, False
|
self.keep_regular_in_family = None # None = auto, True, False
|
||||||
self.suppress_preferred_if_identical = True
|
self.suppress_preferred_if_identical = True
|
||||||
self.fullname_suff = ''
|
|
||||||
self.fontname_suff = ''
|
|
||||||
self.family_suff = ''
|
self.family_suff = ''
|
||||||
|
self.ps_fontname_suff = ''
|
||||||
|
self.short_family_suff = ''
|
||||||
self.name_subst = []
|
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(filename)
|
||||||
self.basename = self._basename
|
self.basename = self._basename
|
||||||
@ -56,11 +56,11 @@ class FontnameParser:
|
|||||||
"""Suppress ID16/17 if it is identical to ID1/2 (True is default)"""
|
"""Suppress ID16/17 if it is identical to ID1/2 (True is default)"""
|
||||||
self.suppress_preferred_if_identical = suppress
|
self.suppress_preferred_if_identical = suppress
|
||||||
|
|
||||||
def inject_suffix(self, fullname, fontname, family):
|
def inject_suffix(self, family, ps_fontname, short_family):
|
||||||
"""Add a custom additonal string that shows up in the resulting names"""
|
"""Add a custom additonal string that shows up in the resulting names"""
|
||||||
self.fullname_suff = fullname.strip()
|
|
||||||
self.fontname_suff = fontname.replace(' ', '')
|
|
||||||
self.family_suff = family.strip()
|
self.family_suff = family.strip()
|
||||||
|
self.ps_fontname_suff = ps_fontname.replace(' ', '')
|
||||||
|
self.short_family_suff = short_family.strip()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def enable_short_families(self, camelcase_name, prefix):
|
def enable_short_families(self, camelcase_name, prefix):
|
||||||
@ -146,7 +146,7 @@ class FontnameParser:
|
|||||||
if self.use_short_families[1]:
|
if self.use_short_families[1]:
|
||||||
weights = FontnameTools.short_styles(weights)
|
weights = FontnameTools.short_styles(weights)
|
||||||
styles = FontnameTools.short_styles(styles)
|
styles = FontnameTools.short_styles(styles)
|
||||||
return FontnameTools.concat(name, rest, self.other_token, self.family_suff, weights, styles)
|
return FontnameTools.concat(name, rest, self.other_token, self.short_family_suff, weights, styles)
|
||||||
|
|
||||||
def psname(self):
|
def psname(self):
|
||||||
"""Get the SFNT PostScriptName (ID 6)"""
|
"""Get the SFNT PostScriptName (ID 6)"""
|
||||||
@ -154,7 +154,7 @@ class FontnameParser:
|
|||||||
(name, rest) = self._shortened_name()
|
(name, rest) = self._shortened_name()
|
||||||
styles = FontnameTools.short_styles(self.style_token)
|
styles = FontnameTools.short_styles(self.style_token)
|
||||||
weights = FontnameTools.short_styles(self.weight_token)
|
weights = FontnameTools.short_styles(self.weight_token)
|
||||||
fam = FontnameTools.camel_casify(FontnameTools.concat(name, rest, self.other_token, self.fontname_suff))
|
fam = FontnameTools.camel_casify(FontnameTools.concat(name, rest, self.other_token, self.ps_fontname_suff))
|
||||||
sub = FontnameTools.camel_casify(FontnameTools.concat(weights, styles))
|
sub = FontnameTools.camel_casify(FontnameTools.concat(weights, styles))
|
||||||
if len(sub) > 0:
|
if len(sub) > 0:
|
||||||
sub = '-' + sub
|
sub = '-' + sub
|
||||||
@ -165,7 +165,7 @@ class FontnameParser:
|
|||||||
def preferred_family(self):
|
def preferred_family(self):
|
||||||
"""Get the SFNT Preferred Familyname (ID 16)"""
|
"""Get the SFNT Preferred Familyname (ID 16)"""
|
||||||
(name, rest) = self._shortened_name()
|
(name, rest) = self._shortened_name()
|
||||||
pfn = FontnameTools.concat(name, rest, self.other_token, self.fullname_suff)
|
pfn = FontnameTools.concat(name, rest, self.other_token, self.family_suff)
|
||||||
if self.suppress_preferred_if_identical and pfn == self.family():
|
if self.suppress_preferred_if_identical and pfn == self.family():
|
||||||
# Do not set if identical to ID 1
|
# Do not set if identical to ID 1
|
||||||
return ''
|
return ''
|
||||||
@ -192,7 +192,7 @@ class FontnameParser:
|
|||||||
if self.use_short_families[1]:
|
if self.use_short_families[1]:
|
||||||
other = FontnameTools.short_styles(other)
|
other = FontnameTools.short_styles(other)
|
||||||
weight = FontnameTools.short_styles(weight)
|
weight = FontnameTools.short_styles(weight)
|
||||||
return FontnameTools.concat(name, rest, other, self.family_suff, weight)
|
return FontnameTools.concat(name, rest, other, self.short_family_suff, weight)
|
||||||
|
|
||||||
def subfamily(self):
|
def subfamily(self):
|
||||||
"""Get the SFNT SubFamily (ID 2)"""
|
"""Get the SFNT SubFamily (ID 2)"""
|
||||||
|
@ -722,6 +722,7 @@ class font_patcher:
|
|||||||
font.appendSFNTName(str('English (US)'), str('Compatible Full'), font.fullname)
|
font.appendSFNTName(str('English (US)'), str('Compatible Full'), font.fullname)
|
||||||
font.appendSFNTName(str('English (US)'), str('SubFamily'), subFamily)
|
font.appendSFNTName(str('English (US)'), str('SubFamily'), subFamily)
|
||||||
else:
|
else:
|
||||||
|
# inject_suffix(family, ps_fontname, short_family)
|
||||||
n.inject_suffix(verboseAdditionalFontNameSuffix, ps_suffix, projectNameAbbreviation + variant_abbrev)
|
n.inject_suffix(verboseAdditionalFontNameSuffix, ps_suffix, projectNameAbbreviation + variant_abbrev)
|
||||||
n.rename_font(font)
|
n.rename_font(font)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user