fix install path issues and install by default

This commit is contained in:
themancalledjakob 2024-08-23 12:28:48 +02:00
parent 30235b565c
commit 2b442c09e4
2 changed files with 21 additions and 17 deletions

View file

@ -611,6 +611,7 @@ class ABC3D_OT_InstallFont(bpy.types.Operator):
install_in_assets: bpy.props.BoolProperty( install_in_assets: bpy.props.BoolProperty(
name="install in assets", name="install in assets",
description="install the font in the assets directory of the addon", description="install the font in the assets directory of the addon",
default=True,
) )
load_into_memory: bpy.props.BoolProperty(name="load font data into memory", load_into_memory: bpy.props.BoolProperty(name="load font data into memory",
@ -651,6 +652,7 @@ class ABC3D_OT_InstallFont(bpy.types.Operator):
target = os.path.join(preferences.assets_dir, "fonts", filename) target = os.path.join(preferences.assets_dir, "fonts", filename)
print(f"installing {scene.abc3d.font_path} -> {target}") print(f"installing {scene.abc3d.font_path} -> {target}")
import shutil import shutil
os.makedirs(os.path.dirname(target), exist_ok=True)
shutil.copyfile(scene.abc3d.font_path, target) shutil.copyfile(scene.abc3d.font_path, target)
# def register_load(target, load=False): # def register_load(target, load=False):
# print(f"registering installed fonts") # print(f"registering installed fonts")

View file

@ -507,6 +507,7 @@ def clear_available_fonts():
def load_installed_fonts(): def load_installed_fonts():
preferences = getPreferences(bpy.context) preferences = getPreferences(bpy.context)
font_dir = os.path.join(preferences.assets_dir,"fonts") font_dir = os.path.join(preferences.assets_dir,"fonts")
if os.path.exists(font_dir):
for file in os.listdir(font_dir): for file in os.listdir(font_dir):
if file.endswith(".glb") or file.endswith(".gltf"): if file.endswith(".glb") or file.endswith(".gltf"):
font_path = os.path.join(font_dir, file) font_path = os.path.join(font_dir, file)
@ -520,6 +521,7 @@ def load_installed_fonts():
def register_installed_fonts(): def register_installed_fonts():
preferences = getPreferences(bpy.context) preferences = getPreferences(bpy.context)
font_dir = os.path.join(preferences.assets_dir,"fonts") font_dir = os.path.join(preferences.assets_dir,"fonts")
if os.path.exists(font_dir):
for file in os.listdir(font_dir): for file in os.listdir(font_dir):
if file.endswith(".glb") or file.endswith(".gltf"): if file.endswith(".glb") or file.endswith(".gltf"):
font_path = os.path.join(font_dir, file) font_path = os.path.join(font_dir, file)