font-patcher: Abort if fontforge did not generate patched font

[why]
Under certain circumjstances Fontforge can not create a font. As the API
does not give any feedback we trudge along afterwards giving confusing
messages.

One example is when the patched font contains too many glyphs.

[how]
Check if the patched font has indeed been generated and is not empty.

Fixes: #1342

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-09-23 11:17:59 +02:00
parent 75f785402d
commit 3053972f86

View file

@ -444,6 +444,9 @@ class font_patcher:
# Adjust flags that can not be changed via fontforge
if re.search('\\.[ot]tf$', self.args.font, re.IGNORECASE) and re.search('\\.[ot]tf$', outfile, re.IGNORECASE):
if not os.path.isfile(outfile) or os.path.getsize(outfile) < 1:
logger.critical("Something went wrong and Fontforge did not generate the new font - look for messages above")
sys.exit(1)
try:
source_font = TableHEADWriter(self.args.font)
dest_font = TableHEADWriter(outfile)