font-patcher: Pull 'Mono' to front in names

[why]
When we crate a font we take the OriginalName, add "Nerd Font" and which
patches we applied, and add "Mono" if --mono has been specified:

OriginalName Nerd Font Complete Mono
OriginalName Nerd Font plus Weather Mono

But the 'Mono' part is quite important, but this scheme will put it in a
place where it is easily out of view or has been removed (to keep the
name short).

This truncation is especially bad on Windows Compatiple and when the
user installs both the 'Nerd Font' and the 'Nerd Font Mono':

    SomeVeryLongFontName Nerd Font Complete
    SomeVeryLongFontName Nerd Font Complete Mono

become after truncation
    SomeVeryLongFontName Nerd Font Comp.ttf
    SomeVeryLongFontName Nerd Font Comp.ttf

[how]
Always put the "Mono" directly after "Nerd Font" and all the other name
components come later.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-12-21 21:24:40 +01:00
parent 51c1aa5904
commit 80f602e805
2 changed files with 15 additions and 11 deletions

View file

@ -111,7 +111,7 @@ jobs:
- name: Check if patched font generated
run: |
[ -e "$GITHUB_WORKSPACE/temp/Hack Regular Nerd Font Complete Mono.ttf" ] && echo "File exists" || exit 1
[ -e "$GITHUB_WORKSPACE/temp/Hack Regular Nerd Font Mono Complete.ttf" ] && echo "File exists" || exit 1
- name: Patcher OTF, Bold variant, and RFN compliance
run: |

View file

@ -488,11 +488,8 @@ class font_patcher:
font.fullname = font.persistent["fullname"]
if isinstance(font.persistent["familyname"], str):
font.familyname = font.persistent["familyname"]
verboseAdditionalFontNameSuffix = " " + projectNameSingular
if self.args.windows: # attempt to shorten here on the additional name BEFORE trimming later
additionalFontNameSuffix = " " + projectNameAbbreviation
else:
additionalFontNameSuffix = verboseAdditionalFontNameSuffix
verboseAdditionalFontNameSuffix = ""
additionalFontNameSuffix = ""
if not self.args.complete:
# NOTE not all symbol fonts have appended their suffix here
if self.args.fontawesome:
@ -525,13 +522,20 @@ class font_patcher:
# if all source glyphs included simplify the name
else:
additionalFontNameSuffix = " " + projectNameSingular + " Complete"
verboseAdditionalFontNameSuffix = " " + projectNameSingular + " Complete"
additionalFontNameSuffix = " Complete"
verboseAdditionalFontNameSuffix = " Complete"
# add mono signifier to end of name
# add mono signifier to beginning of name suffix
if self.args.single:
additionalFontNameSuffix += " M"
verboseAdditionalFontNameSuffix += " Mono"
additionalFontNameSuffix = " M" + additionalFontNameSuffix
verboseAdditionalFontNameSuffix = " Mono" + verboseAdditionalFontNameSuffix
# add 'Nerd Font' to beginning of name suffix
verboseAdditionalFontNameSuffix = " " + projectNameSingular + verboseAdditionalFontNameSuffix
if self.args.windows: # attempt to shorten here on the additional name BEFORE trimming later
additionalFontNameSuffix = " " + projectNameAbbreviation + additionalFontNameSuffix
else:
additionalFontNameSuffix = " " + projectNameSingular + additionalFontNameSuffix
if FontnameParserOK and self.args.makegroups:
use_fullname = isinstance(font.fullname, str) # Usually the fullname is better to parse