mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
font-patcher: Add option to select postscript name as name source
[why] In the post we used these information sources to determine the name and weights/styles of the to-be-patched font: * The filename * The fullname (ID 4) * The postscriptname (ID 6) Usually it is best to use the Fullname of a font to determine its real name and styles/weights: The Postscript name has the advantage to have a hyphen between name and styles/weight; but as it can not contain blanks the correct name can not be determined by this. To get the styles/weights back we use a list of all possible (?!) weights and styles and sort all the string parts. This works reasonably well and the fullname is usually best. Not so with Input Mono Condensed. Here are its names: ID4: "InputMonoCondensed LightIta" IF6: "InputMonoConsensed-LightItalic" [how] Add option to select between fullname and postscriptname as font naming source. For special purposes, also allow a custom (arbitrary) name input. If that is given the specified name will be used to name the patched font without adding any suffix - the user has full control on the name. Fixes: #1314 Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
2f5c6ab6c6
commit
64cf3e9d93
1 changed files with 29 additions and 15 deletions
16
font-patcher
16
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.4.2"
|
||||
script_version = "4.5.0"
|
||||
|
||||
version = "3.0.2"
|
||||
projectName = "Nerd Fonts"
|
||||
|
@ -557,6 +557,7 @@ class font_patcher:
|
|||
additionalFontNameSuffix = " " + projectNameSingular + variant_full + additionalFontNameSuffix
|
||||
|
||||
if FontnameParserOK and self.args.makegroups > 0:
|
||||
if not isinstance(self.args.force_name, str):
|
||||
use_fullname = isinstance(font.fullname, str) # Usually the fullname is better to parse
|
||||
# Use fullname if it is 'equal' to the fontname
|
||||
if font.fullname:
|
||||
|
@ -568,6 +569,16 @@ class font_patcher:
|
|||
# Gohu fontnames hide the weight, but the file names are ok...
|
||||
if parser_name.startswith('Gohu'):
|
||||
parser_name = os.path.splitext(os.path.basename(self.args.font))[0]
|
||||
else:
|
||||
if self.args.force_name == 'full':
|
||||
parser_name = font.fullname
|
||||
elif self.args.force_name == 'postscript':
|
||||
parser_name = font.fontname
|
||||
else:
|
||||
parser_name = self.args.force_name
|
||||
if not isinstance(parser_name, str) or len(parser_name) < 1:
|
||||
logger.critical("Specified --name not usable because the name will be empty")
|
||||
sys.exit(2)
|
||||
n = FontnameParser(parser_name, logger)
|
||||
if not n.parse_ok:
|
||||
logger.warning("Have only minimal naming information, check resulting name. Maybe specify --makegroups 0")
|
||||
|
@ -719,6 +730,8 @@ class font_patcher:
|
|||
font.appendSFNTName(str('English (US)'), str('Compatible Full'), font.fullname)
|
||||
font.appendSFNTName(str('English (US)'), str('SubFamily'), subFamily)
|
||||
else:
|
||||
# Add Nerd Font suffix unless user specifically asked for some excplicit name via --name
|
||||
if not self.args.force_name or self.args.force_name == 'full' or self.args.force_name == 'postscript':
|
||||
short_family = projectNameAbbreviation + variant_abbrev if self.args.makegroups >= 4 else projectNameSingular + variant_full
|
||||
# inject_suffix(family, ps_fontname, short_family)
|
||||
n.inject_suffix(verboseAdditionalFontNameSuffix, ps_suffix, short_family)
|
||||
|
@ -1860,6 +1873,7 @@ def setup_arguments():
|
|||
# <none> - copy from sourcefont (default)
|
||||
# 0 - calculate from font according to OS/2-version-2
|
||||
# 500 - set to 500
|
||||
parser.add_argument('--name', dest='force_name', default=None, type=str, help='Specify naming source (\'full\', \'postscript\', or concrete free name-string)')
|
||||
|
||||
# symbol fonts to include arguments
|
||||
sym_font_group = parser.add_argument_group('Symbol Fonts')
|
||||
|
|
Loading…
Reference in a new issue