load used glyphs on file load

This commit is contained in:
themancalledjakob 2024-08-28 17:45:27 +02:00
parent cd1af39985
commit 460bbc8574
2 changed files with 15 additions and 1 deletions

View file

@ -1418,6 +1418,18 @@ def detect_text():
a = test_availability(o["font_name"], o["face_name"], o["text"])
butils.transfer_blender_object_to_text_properties(o, t)
def load_used_glyphs():
print("LOAD USED GLYPHS")
scene = bpy.context.scene
abc3d_data = scene.abc3d_data
for t in abc3d_data.available_texts:
a = Font.test_availability(t.font_name,
t.face_name,
t.text)
if len(a["maybe"]) > 0:
for fp in a["filepaths"]:
butils.load_font_from_filepath(fp, a["maybe"])
@persistent
def load_handler(self, dummy):
@ -1425,6 +1437,7 @@ def load_handler(self, dummy):
bpy.app.timers.register(butils.execute_queued_functions)
butils.run_in_main_thread(butils.update_available_fonts)
butils.run_in_main_thread(bpy.ops.abc3d.load_installed_fonts)
butils.run_in_main_thread(load_used_glyphs)
def load_handler_unload():
if bpy.app.timers.is_registered(butils.execute_queued_functions):

View file

@ -234,13 +234,14 @@ def test_availability(font_name, face_name, text):
return MISSING_FONT
if fonts[font_name].faces.get(face_name) == None:
return MISSING_FACE
loaded, missing, maybe = test_glyphs_availability(font_name,
loaded, missing, maybe, filepaths = test_glyphs_availability(font_name,
face_name,
text)
return {
"loaded": loaded,
"missing": missing,
"maybe": maybe,
"filepaths": filepaths,
}