mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-25 03:32:02 +02:00
font-patcher: Allow to run without Fontname* modules
[why] People might want to use the font-patcher with just the one script file. The error message does not help them to understand the problem. [how] Require the modules only if the user wants to use it (i.e. --makegroups). Give the expected path in the error message. We could also download the missing files instead, similar to #741 But that PR did not get any feedback yet, so I do not know if this is something we want. Anyhow, the fetching of missing parts should then be unified for both usecases (i.e. Fontname* and src/glyphs). And then, there is font-patcher.zip (which needs to be adapted), maybe that is the way to go. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
20609652ea
commit
c3363c8202
17
font-patcher
17
font-patcher
@ -36,10 +36,14 @@ except ImportError:
|
||||
)
|
||||
)
|
||||
|
||||
# This is (for experimenting) far far away...
|
||||
# This is for experimenting
|
||||
sys.path.insert(0, os.path.abspath(os.path.dirname(sys.argv[0])) + '/bin/scripts/name_parser/')
|
||||
from FontnameParser import FontnameParser
|
||||
from FontnameTools import FontnameTools
|
||||
try:
|
||||
from FontnameParser import FontnameParser
|
||||
from FontnameTools import FontnameTools
|
||||
FontnameParserOK = True
|
||||
except ImportError:
|
||||
FontnameParserOK = False
|
||||
|
||||
class TableHEADWriter:
|
||||
""" Access to the HEAD table without external dependencies """
|
||||
@ -334,6 +338,9 @@ class font_patcher:
|
||||
|
||||
self.args = parser.parse_args()
|
||||
|
||||
if self.args.makegroups and not FontnameParserOK:
|
||||
sys.exit(projectName + ": FontnameParser module missing (bin/scripts/name_parser/Fontname*), can not --makegroups".format(projectName))
|
||||
|
||||
# if you add a new font, set it to True here inside the if condition
|
||||
if self.args.complete:
|
||||
self.args.fontawesome = True
|
||||
@ -430,7 +437,7 @@ class font_patcher:
|
||||
additionalFontNameSuffix += " M"
|
||||
verboseAdditionalFontNameSuffix += " Mono"
|
||||
|
||||
if self.args.makegroups:
|
||||
if FontnameParserOK and self.args.makegroups:
|
||||
use_fullname = type(self.sourceFont.fullname) == str # Usually the fullname is better to parse
|
||||
# Use fullname if it is 'equal' to the fontname
|
||||
if self.sourceFont.fullname:
|
||||
@ -584,7 +591,7 @@ class font_patcher:
|
||||
fullname = replace_font_name(fullname, additionalFontNameReplacements2)
|
||||
fontname = replace_font_name(fontname, additionalFontNameReplacements2)
|
||||
|
||||
if not self.args.makegroups:
|
||||
if not (FontnameParserOK and self.args.makegroups):
|
||||
# replace any extra whitespace characters:
|
||||
self.sourceFont.familyname = " ".join(familyname.split())
|
||||
self.sourceFont.fullname = " ".join(fullname.split())
|
||||
|
Loading…
x
Reference in New Issue
Block a user