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
pull/3079/head dev-build-rejbasket-shapely-arm-fix
Kaalleen 2024-07-10 16:06:24 +02:00 zatwierdzone przez GitHub
rodzic ef6df385c3
commit 9f4e397947
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -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:

Wyświetl plik

@ -23,6 +23,8 @@ def get_font_list():
continue
for font_dir in font_dirs:
if not os.path.isdir(os.path.join(font_path, font_dir)) or font_dir.startswith('.'):
continue
font = Font(os.path.join(font_path, font_dir))
if font.marked_custom_font_name == "" or font.marked_custom_font_id == "":
continue