1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-11-19 16:39:20 +02:00

font-patcher: Do not rely on args.configfile

[why]
We now have two places where we can detect if a config file is given.
This should be unified.

Also handling of missing (?) sections in the config file is not always
handled gracefully.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2024-04-20 09:49:26 +02:00
parent 098fa410a6
commit 6c6177d6a5

View File

@ -773,28 +773,28 @@ class font_patcher:
# let's deal with ligatures (mostly for monospaced fonts)
# Usually removes 'fi' ligs that end up being only one cell wide, and 'ldot'
if self.args.removeligatures:
if self.args.configfile:
logger.info("Removing ligatures from configfile `Subtables` section")
ligature_subtables = json.loads(self.config.get("Subtables", "ligatures"))
for subtable in ligature_subtables:
logger.debug("Removing subtable: %s", subtable)
try:
self.sourceFont.removeLookupSubtable(subtable)
logger.debug("Successfully removed subtable: %s", subtable)
except Exception:
logger.error("Failed to remove subtable: %s", subtable)
else:
logger.error("No configfile, unable to remove ligatures")
logger.info("Removing ligatures from configfile `Subtables` section")
if 'Subtables' not in self.config:
logger.warning("No ligature data (config file missing?)")
return
ligature_subtables = json.loads(self.config.get('Subtables', 'ligatures', fallback='[]'))
for subtable in ligature_subtables:
logger.debug("Removing subtable: %s", subtable)
try:
self.sourceFont.removeLookupSubtable(subtable)
logger.debug("Successfully removed subtable: %s", subtable)
except Exception:
logger.error("Failed to remove subtable: %s", subtable)
def manipulate_hints(self):
""" Redo the hinting on some problematic glyphs """
if not self.args.configfile:
if 'Hinting' not in self.config:
return
redo = json.loads(self.config.get("Hinting", "re_hint"))
redo = json.loads(self.config.get('Hinting', 're_hint', fallback='[]'))
if not len(redo):
return
logger.debug("Working on {} rehinting rules".format(len(redo)))
logger.debug("Working on {} rehinting rules (this may create a lot of fontforge warnings)".format(len(redo)))
count = 0
for gname in self.sourceFont:
for regex in redo: