font3d -> ABC3D
This commit is contained in:
parent
a7632a9c03
commit
8ce5e6c816
4 changed files with 187 additions and 185 deletions
58
butils.py
58
butils.py
|
@ -382,8 +382,8 @@ def load_font_from_filepath(filepath):
|
|||
ShowMessageBox(f"{bl_info['name']} Font loading error", 'ERROR', f"Filepath({filepath}) is not a *.glb or *.gltf file")
|
||||
return False
|
||||
|
||||
font3d_data = bpy.context.scene.font3d_data
|
||||
for f in bpy.context.scene.font3d_data.available_fonts.values():
|
||||
abc3d_data = bpy.context.scene.abc3d_data
|
||||
for f in bpy.context.scene.abc3d_data.available_fonts.values():
|
||||
print(f"inside available font: {f.font_name} {f.face_name}")
|
||||
allObjectsBefore = []
|
||||
for ob in bpy.data.objects:
|
||||
|
@ -392,18 +392,18 @@ def load_font_from_filepath(filepath):
|
|||
bpy.ops.import_scene.gltf(filepath=filepath)
|
||||
|
||||
print(f"after import available fonts:")
|
||||
for f in bpy.context.scene.font3d_data.available_fonts.values():
|
||||
for f in bpy.context.scene.abc3d_data.available_fonts.values():
|
||||
print(f"after import available font: {f.font_name} {f.face_name}")
|
||||
|
||||
fontcollection = bpy.data.collections.get("Font3D")
|
||||
fontcollection = bpy.data.collections.get("ABC3D")
|
||||
if fontcollection is None:
|
||||
fontcollection = bpy.data.collections.new("Font3D")
|
||||
fontcollection = bpy.data.collections.new("ABC3D")
|
||||
|
||||
remove_list = []
|
||||
all_objects = []
|
||||
for o in bpy.data.objects:
|
||||
all_objects.append(o)
|
||||
for f in bpy.context.scene.font3d_data.available_fonts.values():
|
||||
for f in bpy.context.scene.abc3d_data.available_fonts.values():
|
||||
print(f"before loop available font: {f.font_name} {f.face_name}")
|
||||
for o in all_objects:
|
||||
if o.name not in allObjectsBefore:
|
||||
|
@ -414,7 +414,7 @@ def load_font_from_filepath(filepath):
|
|||
and not ("type" in o.keys() and o["type"] == "metrics")
|
||||
and not is_metrics_object(o)
|
||||
):
|
||||
for f in bpy.context.scene.font3d_data.available_fonts.values():
|
||||
for f in bpy.context.scene.abc3d_data.available_fonts.values():
|
||||
print(f"super inside available font: {f.font_name} {f.face_name}")
|
||||
glyph_id = o["glyph"]
|
||||
font_name = o["font_name"]
|
||||
|
@ -437,13 +437,13 @@ def load_font_from_filepath(filepath):
|
|||
remove_list.append(o)
|
||||
|
||||
# found = False
|
||||
# for f in font3d_data.available_fonts.values():
|
||||
# for f in abc3d_data.available_fonts.values():
|
||||
# print(f"has in availables {f.font_name} {f.face_name}")
|
||||
# if f.font_name == font_name and f.face_name == face_name:
|
||||
# found = True
|
||||
# break
|
||||
# if not found:
|
||||
# f = font3d_data.available_fonts.add()
|
||||
# f = abc3d_data.available_fonts.add()
|
||||
# f.font_name = font_name
|
||||
# f.face_name = face_name
|
||||
# print(f"{__name__} added {font_name} {face_name}")
|
||||
|
@ -455,36 +455,36 @@ def load_font_from_filepath(filepath):
|
|||
update_available_fonts()
|
||||
|
||||
def update_available_fonts():
|
||||
font3d_data = bpy.context.scene.font3d_data
|
||||
abc3d_data = bpy.context.scene.abc3d_data
|
||||
|
||||
for font_name in Font.fonts.keys():
|
||||
for face_name in Font.fonts[font_name].faces.keys():
|
||||
found = False
|
||||
for f in font3d_data.available_fonts.values():
|
||||
for f in abc3d_data.available_fonts.values():
|
||||
if font_name == f.font_name and face_name == f.face_name:
|
||||
found = True
|
||||
if not found:
|
||||
f = font3d_data.available_fonts.add()
|
||||
f = abc3d_data.available_fonts.add()
|
||||
f.font_name = font_name
|
||||
f.face_name = face_name
|
||||
print("{__name__} added {font_name} {face_name}")
|
||||
print(f"{__name__} added {font_name} {face_name}")
|
||||
|
||||
def update_available_texts():
|
||||
font3d_data = bpy.context.scene.font3d_data
|
||||
for o in bpy.context.scene.objects:
|
||||
if "linked_textobject" in o.keys():
|
||||
i = o["linked_textobject"]
|
||||
found = False
|
||||
if len(font3d_data.available_texts) > i:
|
||||
if font3d_data.available_texts[i].glyphs
|
||||
# def update_available_texts():
|
||||
# abc3d_data = bpy.context.scene.abc3d_data
|
||||
# for o in bpy.context.scene.objects:
|
||||
# if "linked_textobject" in o.keys():
|
||||
# i = o["linked_textobject"]
|
||||
# found = False
|
||||
# if len(abc3d_data.available_texts) > i:
|
||||
# if abc3d_data.available_texts[i].glyphs
|
||||
|
||||
def getPreferences(context):
|
||||
preferences = context.preferences
|
||||
return preferences.addons['font3d'].preferences
|
||||
return preferences.addons['abc3d'].preferences
|
||||
|
||||
# clear available fonts
|
||||
def clear_available_fonts():
|
||||
bpy.context.scene.font3d_data.available_fonts.clear()
|
||||
bpy.context.scene.abc3d_data.available_fonts.clear()
|
||||
|
||||
def load_available_fonts():
|
||||
|
||||
|
@ -496,7 +496,7 @@ def load_available_fonts():
|
|||
font_path = os.path.join(font_dir, file)
|
||||
ShowMessageBox("Loading Font", "INFO", f"loading font from {font_path}")
|
||||
print(f"loading font from {font_path}")
|
||||
for f in bpy.context.scene.font3d_data.available_fonts.values():
|
||||
for f in bpy.context.scene.abc3d_data.available_fonts.values():
|
||||
print(f"available font: {f.font_name} {f.face_name}")
|
||||
load_font_from_filepath(font_path)
|
||||
|
||||
|
@ -598,10 +598,10 @@ def set_text_on_curve(text_properties):
|
|||
or type(g.glyph_object.parent) == type(None)
|
||||
or g.glyph_object.parent.users_collection != g.glyph_object.users_collection):
|
||||
regenerate = True
|
||||
if len(text_properties.text) > i and g.glyph_id != text_properties.text[i]:
|
||||
elif len(text_properties.text) > i and g.glyph_id != text_properties.text[i]:
|
||||
regenerate = True
|
||||
if len(text_properties.text) > i and (g.font_name != text_properties.text[i].font_name
|
||||
or g.face_name != text_properties.text[i].face_name):
|
||||
elif len(text_properties.text) > i and (g.glyph_object['font_name'] != text_properties.font_name
|
||||
or g.glyph_object['face_name'] != text_properties.face_name):
|
||||
regenerate = True
|
||||
|
||||
if len(text_properties.text) != len(text_properties.glyphs):
|
||||
|
@ -661,8 +661,10 @@ def set_text_on_curve(text_properties):
|
|||
if regenerate:
|
||||
ob = bpy.data.objects.new(f"{glyph_id}", glyph.data)
|
||||
ob['linked_textobject'] = text_properties.text_id
|
||||
ob['font_name'] = text_properties.font_name
|
||||
ob['face_name'] = text_properties.face_name
|
||||
else:
|
||||
ob = text_properties.glyphs[i]['glyph_object']
|
||||
ob = text_properties.glyphs[i].glyph_object
|
||||
|
||||
distribution_type = 'CALCULATE'
|
||||
if distribution_type == 'FOLLOW_PATH':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue