chore: change batteries

This commit is contained in:
github-actions[bot] 2024-01-01 00:32:17 +00:00
parent d45cbcf7ab
commit 683734abba
3 changed files with 17 additions and 36 deletions

View file

@ -180,24 +180,10 @@ class FontnameParser:
sub = FontnameTools.postscript_char_filter(sub) sub = FontnameTools.postscript_char_filter(sub)
return self._make_ps_name(fam + sub, False) return self._make_ps_name(fam + sub, False)
def long_family(self):
"""Get unabbreviated Familyname"""
(name, rest) = self._shortened_name()
return FontnameTools.concat(name, rest, self.other_token, self.family_suff)
def long_subfamily(self):
"""Get unabbreviated Styles"""
return FontnameTools.concat(self.weight_token, self.style_token)
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()
other = self.other_token pfn = FontnameTools.concat(name, rest, self.other_token, self.family_suff)
weights = self.weight_token
aggressive = self.use_short_families[2]
if self.use_short_families[1]:
[ other, weights ] = FontnameTools.short_styles([ other, weights ], aggressive)
pfn = FontnameTools.concat(name, rest, other, self.short_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 ''

View file

@ -1,14 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
# coding=utf8 # coding=utf8
# Nerd Fonts Version: 3.1.0 # Nerd Fonts Version: 3.1.1
# Script version is further down # Script version is further down
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
# Change the script version when you edit this script: # Change the script version when you edit this script:
script_version = "4.8.1" script_version = "4.8.3"
version = "3.1.0" version = "3.1.1"
projectName = "Nerd Fonts" projectName = "Nerd Fonts"
projectNameAbbreviation = "NF" projectNameAbbreviation = "NF"
projectNameSingular = projectName[:-1] projectNameSingular = projectName[:-1]
@ -306,20 +306,16 @@ def get_old_average_x_width(font):
s += font[g].width * weights[g] s += font[g].width * weights[g]
return int(s / 1000) return int(s / 1000)
def create_filename(patcher, fonts): def create_filename(fonts):
""" Determine filename from font object(s) """ """ Determine filename from font object(s) """
pfam = patcher.long_family
psubfam = patcher.long_subfamily
sfnt = { k: v for l, k, v in fonts[0].sfnt_names } sfnt = { k: v for l, k, v in fonts[0].sfnt_names }
if not pfam: sfnt_pfam = sfnt.get('Preferred Family', sfnt['Family'])
pfam = sfnt.get('Preferred Family', sfnt['Family']) sfnt_psubfam = sfnt.get('Preferred Styles', sfnt['SubFamily'])
if not psubfam or len(psubfam) < 1:
psubfam = sfnt.get('Preferred Styles', sfnt['SubFamily'])
if len(fonts) > 1: if len(fonts) > 1:
return pfam.replace(' ', '') return sfnt_pfam
if len(psubfam) > 0: if len(sfnt_psubfam) > 0:
psubfam = '-' + psubfam sfnt_psubfam = '-' + sfnt_psubfam
return (pfam + psubfam).replace(' ', '') return (sfnt_pfam + sfnt_psubfam).replace(' ', '')
class font_patcher: class font_patcher:
@ -337,8 +333,6 @@ class font_patcher:
self.essential = set() self.essential = set()
self.config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True) self.config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True)
self.xavgwidth = [] # list of ints self.xavgwidth = [] # list of ints
self.long_family = None
self.long_subfamily = None
def patch(self, font): def patch(self, font):
self.sourceFont = font self.sourceFont = font
@ -432,11 +426,11 @@ class font_patcher:
break break
outfile = os.path.normpath(os.path.join( outfile = os.path.normpath(os.path.join(
sanitize_filename(self.args.outputdir, True), sanitize_filename(self.args.outputdir, True),
sanitize_filename(create_filename(self, sourceFonts)) + ".ttc")) sanitize_filename(create_filename(sourceFonts)) + ".ttc"))
sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer) sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer)
message = " Generated {} fonts\n \===> '{}'".format(len(sourceFonts), outfile) message = " Generated {} fonts\n \===> '{}'".format(len(sourceFonts), outfile)
else: else:
fontname = create_filename(self, sourceFonts) fontname = create_filename(sourceFonts)
if not fontname: if not fontname:
fontname = sourceFont.cidfontname fontname = sourceFont.cidfontname
outfile = os.path.normpath(os.path.join( outfile = os.path.normpath(os.path.join(
@ -755,8 +749,6 @@ class font_patcher:
# inject_suffix(family, ps_fontname, short_family) # inject_suffix(family, ps_fontname, short_family)
n.inject_suffix(verboseAdditionalFontNameSuffix, ps_suffix, short_family) n.inject_suffix(verboseAdditionalFontNameSuffix, ps_suffix, short_family)
n.rename_font(font) n.rename_font(font)
self.long_family = n.long_family()
self.long_subfamily = n.long_subfamily()
font.comment = projectInfo font.comment = projectInfo
font.fontlog = projectInfo font.fontlog = projectInfo
@ -1220,7 +1212,7 @@ class font_patcher:
'height': self.sourceFont.descent + self.sourceFont.ascent, 'height': self.sourceFont.descent + self.sourceFont.ascent,
} }
our_btb = self.sourceFont.descent + self.sourceFont.ascent our_btb = self.sourceFont.descent + self.sourceFont.ascent
elif self.font_dim['height'] < 0: if self.font_dim['height'] <= 0:
logger.critical("Can not detect sane font height") logger.critical("Can not detect sane font height")
sys.exit(1) sys.exit(1)
@ -1274,6 +1266,9 @@ class font_patcher:
if self.font_dim['width'] < self.font_dim['xmax']: if self.font_dim['width'] < self.font_dim['xmax']:
logger.debug("Font has negative right side bearing in extended glyphs") logger.debug("Font has negative right side bearing in extended glyphs")
self.font_dim['xmax'] = self.font_dim['width'] # In fact 'xmax' is never used self.font_dim['xmax'] = self.font_dim['width'] # In fact 'xmax' is never used
if self.font_dim['width'] <= 0:
logger.critical("Can not detect sane font width")
sys.exit(1)
logger.debug("Final font cell dimensions %d w x %d h", self.font_dim['width'], self.font_dim['height']) logger.debug("Final font cell dimensions %d w x %d h", self.font_dim['width'], self.font_dim['height'])
self.xavgwidth.append(self.args.xavgwidth) self.xavgwidth.append(self.args.xavgwidth)

Binary file not shown.