diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-07-10 16:06:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 16:06:24 +0200 |
| commit | 9f4e397947fd0d1978fbef687e7cab9b6d98ea52 (patch) | |
| tree | bbb26cd27e009bbcb6fb6515b0f425ac0b7faa56 /lib/lettering/font.py | |
| parent | ef6df385c30f85c739dc5c5098134529ed52d160 (diff) | |
Lettering: skip font with corrupt json file (#3071)
* lettering: warn about corrupt/missing json file
* ignore hidden directories and files placed directly in the font folder
Diffstat (limited to 'lib/lettering/font.py')
| -rw-r--r-- | lib/lettering/font.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/lettering/font.py b/lib/lettering/font.py index 17c6f0f9..431dc8d4 100644 --- a/lib/lettering/font.py +++ b/lib/lettering/font.py @@ -91,7 +91,19 @@ class Font(object): with open(os.path.join(self.path, "font.json"), encoding="utf-8-sig") as metadata_file: self.metadata = json.load(metadata_file) except IOError: - pass + path = os.path.join(self.path, "font.json") + msg = _("JSON file missing. Expected a JSON file at the following location:") + msg += f"\n{path}\n\n" + msg += _("Generate the JSON file through:\nExtensions > Ink/Stitch > Font Management > Generate JSON...") + msg += '\n\n' + inkex.errormsg(msg) + except json.decoder.JSONDecodeError as exception: + path = os.path.join(self.path, "font.json") + msg = _("Corrupt JSON file") + msg += f" ({exception}):\n{path}\n\n" + msg += _("Regenerate the JSON file through:\nExtensions > Ink/Stitch > Font Management > Generate JSON...") + msg += '\n\n' + inkex.errormsg(msg) def _load_license(self): try: |
