mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-12-25 20:18:01 +02:00
name-parser: Revert file name change
[why] It is better to have a not-abbreviated file name so that one can make sense out of the name parts, especially when doing a partial patch. With the previous commit we ended up with all abbreviated names. The filename length is hopefully not limited, at least not as severe as the SFNT table entries. [how] We need to store the answers somewhere because the naming is only understood by the FontnameParser object which we throw away soon. As fallback we still can parse the SFNT table, for example when the old renaming is used. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
d3ee35db8e
commit
784e892575
@ -180,6 +180,15 @@ 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()
|
||||||
|
28
font-patcher
28
font-patcher
@ -6,7 +6,7 @@
|
|||||||
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.7.0"
|
script_version = "4.7.1"
|
||||||
|
|
||||||
version = "3.0.2"
|
version = "3.0.2"
|
||||||
projectName = "Nerd Fonts"
|
projectName = "Nerd Fonts"
|
||||||
@ -306,16 +306,20 @@ 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(fonts):
|
def create_filename(patcher, 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 }
|
||||||
sfnt_pfam = sfnt.get('Preferred Family', sfnt['Family'])
|
if not pfam:
|
||||||
sfnt_psubfam = sfnt.get('Preferred Styles', sfnt['SubFamily'])
|
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:
|
if len(fonts) > 1:
|
||||||
return sfnt_pfam
|
return pfam.replace(' ', '')
|
||||||
if len(sfnt_psubfam) > 0:
|
if len(psubfam) > 0:
|
||||||
sfnt_psubfam = '-' + sfnt_psubfam
|
psubfam = '-' + psubfam
|
||||||
return (sfnt_pfam + sfnt_psubfam).replace(' ', '')
|
return (pfam + psubfam).replace(' ', '')
|
||||||
|
|
||||||
|
|
||||||
class font_patcher:
|
class font_patcher:
|
||||||
@ -333,6 +337,8 @@ 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
|
||||||
@ -426,11 +432,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(sourceFonts)) + ".ttc"))
|
sanitize_filename(create_filename(self, 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(sourceFonts)
|
fontname = create_filename(self, 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(
|
||||||
@ -749,6 +755,8 @@ 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
|
||||||
|
Loading…
Reference in New Issue
Block a user