glyph properties, orientation fixes

This commit is contained in:
jrkb 2025-05-18 17:23:38 +02:00
parent 6943a9189c
commit d56ca84236
2 changed files with 359 additions and 136 deletions

View file

@ -134,11 +134,26 @@ class ABC3D_available_font(bpy.types.PropertyGroup):
class ABC3D_glyph_properties(bpy.types.PropertyGroup):
def update_callback(self, context):
if self.text_id >= 0:
butils.set_text_on_curve(
context.scene.abc3d_data.available_texts[self.text_id]
)
glyph_id: bpy.props.StringProperty(maxlen=1)
text_id: bpy.props.IntProperty(
default=-1,
)
alternate: bpy.props.IntProperty(
default=-1,
update=update_callback,
)
glyph_object: bpy.props.PointerProperty(type=bpy.types.Object)
letter_spacing: bpy.props.FloatProperty(
name="Letter Spacing",
description="Letter Spacing",
update=update_callback,
)
class ABC3D_text_properties(bpy.types.PropertyGroup):
@ -704,14 +719,38 @@ class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
def get_active_text_properties(self):
# and bpy.context.object.select_get():
if type(bpy.context.active_object) != type(None):
for t in bpy.context.scene.abc3d_data.available_texts:
if bpy.context.active_object == t.text_object:
return t
if bpy.context.active_object.parent == t.text_object:
return t
a_o = bpy.context.active_object
if a_o is not None:
if f"{utils.prefix()}_linked_textobject" in a_o:
text_index = a_o[f"{utils.prefix()}_linked_textobject"]
return bpy.context.scene.abc3d_data.available_texts[text_index]
elif f"{utils.prefix()}_linked_textobject" in a_o.parent:
text_index = a_o.parent[f"{utils.prefix()}_linked_textobject"]
return bpy.context.scene.abc3d_data.available_texts[text_index]
else:
for t in bpy.context.scene.abc3d_data.available_texts:
if butils.is_or_has_parent(bpy.context.active_object, t.text_object, max_depth=4):
return t
return None
# NOTE: HERE
def get_active_glyph_properties(self):
a_o = bpy.context.active_object
if a_o is not None:
if (f"{utils.prefix()}_linked_textobject" in a_o
and f"{utils.prefix()}_glyph_index" in a_o):
text_index = a_o[f"{utils.prefix()}_linked_textobject"]
glyph_index = a_o[f"{utils.prefix()}_glyph_index"]
return bpy.context.scene.abc3d_data.available_texts[text_index].glyphs[glyph_index]
else:
for t in bpy.context.scene.abc3d_data.available_texts:
if butils.is_or_has_parent(a_o, t.text_object, if_is_parent=False, max_depth=4):
for g in t.glyphs:
if butils.is_or_has_parent(a_o, g.glyph_object, max_depth=4):
return g
return None
# def font_items_callback(self, context):
# items = []
# fonts = Font.get_loaded_fonts_and_faces()
@ -741,7 +780,7 @@ class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
@classmethod
def poll(self, context):
return type(self.get_active_text_properties(self)) != type(None)
return self.get_active_text_properties(self) is not None
def draw(self, context):
layout = self.layout
@ -750,11 +789,16 @@ class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
abc3d_data = scene.abc3d_data
props = self.get_active_text_properties()
glyph_props = self.get_active_glyph_properties()
if type(props) == type(None) or type(props.text_object) == type(None):
if props is None or props.text_object is None:
# this should not happen
# as then polling does not work
# however, we are paranoid
if props is None:
layout.label(text="props is none")
elif props.text_object is None:
layout.label(text="props.text_object is none")
return
layout.label(text=f"Mom: {props.text_object.name}")
@ -768,6 +812,13 @@ class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
layout.column().prop(props, "translation")
layout.column().prop(props, "orientation")
if glyph_props is None:
return
box = layout.box()
box.label(text=f"{glyph_props.glyph_id}")
box.row().prop(glyph_props, "letter_spacing")
class ABC3D_OT_InstallFont(bpy.types.Operator):
"""Install or load Fontfile from path above.