From e97e7959d6f5ac0ecf0ed21ce9c9ab623935f585 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Fri, 13 Jan 2023 07:53:22 +0100 Subject: [PATCH] font-patcher: Fix unexpected 'Book' SubFamily [why] Sometimes we set an empty string as SubFamily name. That ends up as 'Book' which is unexpected. [how] The translation from empty to "Book" is done by Fontforge, at least with version 20220308. Make sure we always have a SubFamily, and if we don't that must be a 'Regular'. [note] This was only a problem with the old naming engine. --makegroups got this right always. Fixes: #1046 Signed-off-by: Fini Jastrow --- bin/scripts/name_parser/FontnameParser.py | 3 +++ font-patcher | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/scripts/name_parser/FontnameParser.py b/bin/scripts/name_parser/FontnameParser.py index db92bccb3..0c3652016 100644 --- a/bin/scripts/name_parser/FontnameParser.py +++ b/bin/scripts/name_parser/FontnameParser.py @@ -302,6 +302,9 @@ class FontnameParser: sfnt_list = [] TO_DEL = ['Family', 'SubFamily', 'Fullname', 'Postscriptname', 'Preferred Family', 'Preferred Styles', 'Compatible Full', 'WWS Family', 'WWS Subfamily'] + # 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 )] diff --git a/font-patcher b/font-patcher index 934f49edc..746942b83 100755 --- a/font-patcher +++ b/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 = "3.4.0" +script_version = "3.4.1" version = "2.3.0-RC" projectName = "Nerd Fonts" @@ -512,13 +512,16 @@ class font_patcher: subFamily = fallbackStyle # some fonts have inaccurate 'SubFamily', if it is Regular let us trust the filename more: - if subFamily == "Regular": + if subFamily == "Regular" and len(fallbackStyle): subFamily = fallbackStyle # This is meant to cover the case where the SubFamily is "Italic" and the filename is *-BoldItalic. if len(subFamily) < len(fallbackStyle): subFamily = fallbackStyle + if len(subFamily) == 0: + subFamily = "Regular" + if self.args.windows: maxFamilyLength = 31 maxFontLength = maxFamilyLength - len('-' + subFamily)