mirror of
https://github.com/daylinmorgan/monolisa-nerdfont-patch.git
synced 2024-11-12 18:03:14 -06:00
chore: change batteries
This commit is contained in:
parent
5ee7036b11
commit
d6de2b0e69
4 changed files with 36 additions and 13 deletions
|
@ -180,10 +180,24 @@ class FontnameParser:
|
|||
sub = FontnameTools.postscript_char_filter(sub)
|
||||
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):
|
||||
"""Get the SFNT Preferred Familyname (ID 16)"""
|
||||
(name, rest) = self._shortened_name()
|
||||
pfn = FontnameTools.concat(name, rest, self.other_token, self.family_suff)
|
||||
other = self.other_token
|
||||
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():
|
||||
# Do not set if identical to ID 1
|
||||
return ''
|
||||
|
|
|
@ -203,7 +203,6 @@ class FontnameTools:
|
|||
( 'IBM 3270', r'3270'), # for historical reasons and 'IBM' is a TM or something
|
||||
# Some name parts that are too long for us
|
||||
( '(.*sans ?m)ono', r'\1'), # Various SomenameSansMono fonts
|
||||
( '(.*code ?lat)in Expanded', r'\1X'), # for 'M PLUS Code Latin Expanded'
|
||||
( '(.*code ?lat)in', r'\1'), # for 'M PLUS Code Latin'
|
||||
( '(b)ig( ?)(b)lue( ?)(t)erminal', r'\1ig\3lue\5erm'), # Shorten BigBlueTerminal
|
||||
( '(.*)437TT', r'\g<1>437'), # Shorten BigBlueTerminal 437 TT even further
|
||||
|
|
32
font-patcher
32
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.6.1"
|
||||
script_version = "4.7.1"
|
||||
|
||||
version = "3.0.2"
|
||||
projectName = "Nerd Fonts"
|
||||
|
@ -306,16 +306,20 @@ def get_old_average_x_width(font):
|
|||
s += font[g].width * weights[g]
|
||||
return int(s / 1000)
|
||||
|
||||
def create_filename(fonts):
|
||||
def create_filename(patcher, fonts):
|
||||
""" 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_pfam = sfnt.get('Preferred Family', sfnt['Family'])
|
||||
sfnt_psubfam = sfnt.get('Preferred Styles', sfnt['SubFamily'])
|
||||
if not pfam:
|
||||
pfam = sfnt.get('Preferred Family', sfnt['Family'])
|
||||
if not psubfam or len(psubfam) < 1:
|
||||
psubfam = sfnt.get('Preferred Styles', sfnt['SubFamily'])
|
||||
if len(fonts) > 1:
|
||||
return sfnt_pfam
|
||||
if len(sfnt_psubfam) > 0:
|
||||
sfnt_psubfam = '-' + sfnt_psubfam
|
||||
return (sfnt_pfam + sfnt_psubfam).replace(' ', '')
|
||||
return pfam.replace(' ', '')
|
||||
if len(psubfam) > 0:
|
||||
psubfam = '-' + psubfam
|
||||
return (pfam + psubfam).replace(' ', '')
|
||||
|
||||
|
||||
class font_patcher:
|
||||
|
@ -333,6 +337,8 @@ class font_patcher:
|
|||
self.essential = set()
|
||||
self.config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True)
|
||||
self.xavgwidth = [] # list of ints
|
||||
self.long_family = None
|
||||
self.long_subfamily = None
|
||||
|
||||
def patch(self, font):
|
||||
self.sourceFont = font
|
||||
|
@ -426,11 +432,11 @@ class font_patcher:
|
|||
break
|
||||
outfile = os.path.normpath(os.path.join(
|
||||
sanitize_filename(self.args.outputdir, True),
|
||||
sanitize_filename(create_filename(sourceFonts)) + ".ttc"))
|
||||
sanitize_filename(create_filename(self, sourceFonts)) + ".ttc"))
|
||||
sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer)
|
||||
message = " Generated {} fonts\n \===> '{}'".format(len(sourceFonts), outfile)
|
||||
else:
|
||||
fontname = create_filename(sourceFonts)
|
||||
fontname = create_filename(self, sourceFonts)
|
||||
if not fontname:
|
||||
fontname = sourceFont.cidfontname
|
||||
outfile = os.path.normpath(os.path.join(
|
||||
|
@ -582,6 +588,8 @@ class font_patcher:
|
|||
parser_name = font.fullname
|
||||
elif self.args.force_name == 'postscript':
|
||||
parser_name = font.fontname
|
||||
elif self.args.force_name == 'filename':
|
||||
parser_name = os.path.basename(font.path).split('.')[0]
|
||||
else:
|
||||
parser_name = self.args.force_name
|
||||
user_supplied_name = True
|
||||
|
@ -747,6 +755,8 @@ class font_patcher:
|
|||
# inject_suffix(family, ps_fontname, short_family)
|
||||
n.inject_suffix(verboseAdditionalFontNameSuffix, ps_suffix, short_family)
|
||||
n.rename_font(font)
|
||||
self.long_family = n.long_family()
|
||||
self.long_subfamily = n.long_subfamily()
|
||||
|
||||
font.comment = projectInfo
|
||||
font.fontlog = projectInfo
|
||||
|
@ -1899,7 +1909,7 @@ def setup_arguments():
|
|||
expert_group.add_argument('--has-no-italic', dest='noitalic', default=False, action='store_true', help='Font family does not have Italic (but Oblique), to help create correct RIBBI set')
|
||||
expert_group.add_argument('-l', '--adjust-line-height', dest='adjustLineHeight', default=False, action='store_true', help='Whether to adjust line heights (attempt to center powerline separators more evenly)')
|
||||
expert_group.add_argument('--metrics', dest='metrics', default=None, choices=get_metrics_names(), help='Select vertical metrics source (for problematic cases)')
|
||||
expert_group.add_argument('--name', dest='force_name', default=None, type=str, help='Specify naming source (\'full\', \'postscript\', or concrete free name-string)')
|
||||
expert_group.add_argument('--name', dest='force_name', default=None, type=str, help='Specify naming source (\'full\', \'postscript\', \'filename\', or concrete free name-string)')
|
||||
expert_group.add_argument('--postprocess', dest='postprocess', default=False, type=str, help='Specify a Script for Post Processing')
|
||||
progressbars_group_parser = expert_group.add_mutually_exclusive_group(required=False)
|
||||
expert_group.add_argument('--removeligs', '--removeligatures', dest='removeligatures', default=False, action='store_true', help='Removes ligatures specificed in JSON configuration file (needs --configfile)')
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue