font-patcher: Fail with meaningful message if font can not be opened

[why]
When fontforge is not able to open the font we fail with a meaninless
exception. Users might think that the font-patcher script itself is
broken.

[how]
Exit the script with a hint how to get more information if fontforge was
not able to open the font.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2021-11-24 08:25:56 +01:00
parent f7d6fcb59c
commit 204a43aafb

View file

@ -51,7 +51,10 @@ class font_patcher:
self.extension = ""
self.setup_arguments()
self.config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True)
try:
self.sourceFont = fontforge.open(self.args.font, ("fstypepermitted",))
except Exception:
sys.exit(projectName + ": Can not open font, try to open with fontforge interactively to get more information")
self.setup_font_names()
self.remove_ligatures()
make_sure_path_exists(self.args.outputdir)