From 784bd422d60c51ad763a087ce1709092b16264ac Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Mon, 27 Mar 2023 17:36:32 +0200 Subject: [PATCH] name-parser: Set UniqueID [why] When we rename a font we should always also change the unique ID. [how] Take the fullname and the Nerd Font version number. In general we do not have the version number in the NameParser object; but we have the 'Version' name and we loot the last word (which we have set to the Nerd Font version already in the patcher) as version descriptor. Signed-off-by: Fini Jastrow --- bin/scripts/name_parser/FontnameParser.py | 7 ++++++- font-patcher | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/scripts/name_parser/FontnameParser.py b/bin/scripts/name_parser/FontnameParser.py index 0c3652016..0f41fd12d 100644 --- a/bin/scripts/name_parser/FontnameParser.py +++ b/bin/scripts/name_parser/FontnameParser.py @@ -299,20 +299,25 @@ class FontnameParser: # and it is actually embedded as empty string, but empty strings are not # shown if you query the sfnt_names *rolleyes* + version_tag = '' sfnt_list = [] TO_DEL = ['Family', 'SubFamily', 'Fullname', 'Postscriptname', 'Preferred Family', - 'Preferred Styles', 'Compatible Full', 'WWS Family', 'WWS Subfamily'] + 'Preferred Styles', 'Compatible Full', 'WWS Family', 'WWS Subfamily', + 'UniqueID'] # Remove these entries in all languages and add (at least the vital ones) some # back, but only as 'English (US)'. This makes sure we do not leave contradicting # names over different languages. for l, k, v in list(font.sfnt_names): if not k in TO_DEL: sfnt_list += [( l, k, v )] + if k == 'Version' and l == 'English (US)': + version_tag = ' ' + v.split()[-1] sfnt_list += [( 'English (US)', 'Family', self.family() )] sfnt_list += [( 'English (US)', 'SubFamily', self.subfamily() )] sfnt_list += [( 'English (US)', 'Fullname', self.fullname() )] sfnt_list += [( 'English (US)', 'PostScriptName', self.psname() )] + sfnt_list += [( 'English (US)', 'UniqueID', self.fullname() + version_tag )] p_fam = self.preferred_family() if len(p_fam): diff --git a/font-patcher b/font-patcher index 01a10b96c..82c138389 100755 --- a/font-patcher +++ b/font-patcher @@ -734,6 +734,7 @@ class font_patcher: self.sourceFont.version = str(self.sourceFont.cidversion) + ";" + projectName + " " + version self.sourceFont.sfntRevision = None # Auto-set (refreshed) by fontforge self.sourceFont.appendSFNTName(str('English (US)'), str('Version'), "Version " + self.sourceFont.version) + # The Version SFNT name is later reused by the NameParser for UniqueID # print("Version now is {}".format(sourceFont.version))