add offset

This commit is contained in:
themancalledjakob 2024-08-21 17:31:19 +02:00
parent 01c116c321
commit 850377e0f5
2 changed files with 26 additions and 8 deletions

View file

@ -137,6 +137,11 @@ class ABC3D_settings(bpy.types.PropertyGroup):
default=(1.5707963267948966, 0.0, 0.0), # 90 degrees in radians default=(1.5707963267948966, 0.0, 0.0), # 90 degrees in radians
subtype='EULER', subtype='EULER',
) )
offset: bpy.props.FloatProperty(
name="Offset",
default=0.0,
subtype='NONE',
)
class ABC3D_available_font(bpy.types.PropertyGroup): class ABC3D_available_font(bpy.types.PropertyGroup):
font_name: bpy.props.StringProperty(name="") font_name: bpy.props.StringProperty(name="")
@ -230,6 +235,12 @@ class ABC3D_text_properties(bpy.types.PropertyGroup):
default=1.0, default=1.0,
subtype='NONE', subtype='NONE',
) )
offset: bpy.props.FloatProperty(
update=update_callback,
name="Offset",
default=0.0,
subtype='NONE',
)
compensate_curvature: bpy.props.BoolProperty( compensate_curvature: bpy.props.BoolProperty(
update=update_callback, update=update_callback,
name="Compensate Curvature", name="Compensate Curvature",
@ -453,6 +464,7 @@ class ABC3D_PT_TextManagement(bpy.types.Panel):
delif(mom,f"{utils.prefix()}_letter_spacing") delif(mom,f"{utils.prefix()}_letter_spacing")
delif(mom,f"{utils.prefix()}_orientation") delif(mom,f"{utils.prefix()}_orientation")
delif(mom,f"{utils.prefix()}_translation") delif(mom,f"{utils.prefix()}_translation")
delif(mom,f"{utils.prefix()}_offset")
abc3d_data.available_texts.remove(i) abc3d_data.available_texts.remove(i)
for i, t in enumerate(abc3d_data.available_texts): for i, t in enumerate(abc3d_data.available_texts):
@ -575,6 +587,7 @@ class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
layout.row().prop(props, "text") layout.row().prop(props, "text")
layout.row().prop(props, "letter_spacing") layout.row().prop(props, "letter_spacing")
layout.row().prop(props, "font_size") layout.row().prop(props, "font_size")
layout.row().prop(props, "offset")
layout.row().prop(props, "compensate_curvature") layout.row().prop(props, "compensate_curvature")
layout.row().prop(props, "ignore_orientation") layout.row().prop(props, "ignore_orientation")
layout.column().prop(props, "translation") layout.column().prop(props, "translation")
@ -792,6 +805,7 @@ class ABC3D_OT_RemoveText(bpy.types.Operator):
delif(mom,f"{utils.prefix()}_letter_spacing") delif(mom,f"{utils.prefix()}_letter_spacing")
delif(mom,f"{utils.prefix()}_orientation") delif(mom,f"{utils.prefix()}_orientation")
delif(mom,f"{utils.prefix()}_translation") delif(mom,f"{utils.prefix()}_translation")
delif(mom,f"{utils.prefix()}_offset")
if self.remove_objects: if self.remove_objects:
remove_list = [] remove_list = []
for g in abc3d_data.available_texts[i].glyphs: for g in abc3d_data.available_texts[i].glyphs:
@ -852,6 +866,11 @@ class ABC3D_OT_PlaceText(bpy.types.Operator):
default=1.0, default=1.0,
subtype='NONE', subtype='NONE',
) )
offset: bpy.props.FloatProperty(
name="Offset",
default=0.0,
subtype='NONE',
)
translation: bpy.props.FloatVectorProperty( translation: bpy.props.FloatVectorProperty(
name="Translation", name="Translation",
default=(0.0, 0.0, 0.0), default=(0.0, 0.0, 0.0),
@ -902,6 +921,7 @@ class ABC3D_OT_PlaceText(bpy.types.Operator):
t['text'] = self.text t['text'] = self.text
t['letter_spacing'] = self.letter_spacing t['letter_spacing'] = self.letter_spacing
t['font_size'] = self.font_size t['font_size'] = self.font_size
t['offset'] = self.offset
t['translation'] = self.translation t['translation'] = self.translation
t['orientation'] = self.orientation t['orientation'] = self.orientation
t['distribution_type'] = distribution_type t['distribution_type'] = distribution_type
@ -1258,6 +1278,7 @@ class ABC3D_PT_RightPropertiesPanel(bpy.types.Panel):
layout.row().prop(available_text, "text") layout.row().prop(available_text, "text")
layout.row().prop(available_text, "letter_spacing") layout.row().prop(available_text, "letter_spacing")
layout.row().prop(available_text, "font_size") layout.row().prop(available_text, "font_size")
layout.row().prop(available_text, "offset")
layout.row().prop(available_text, "compensate_curvature") layout.row().prop(available_text, "compensate_curvature")
layout.row().prop(available_text, "ignore_orientation") layout.row().prop(available_text, "ignore_orientation")
layout.column().prop(available_text, "translation") layout.column().prop(available_text, "translation")

View file

@ -416,24 +416,24 @@ def load_font_from_filepath(filepath, glyphs="", font_name="", face_name=""):
modified_font_faces = [] modified_font_faces = []
all_glyph_os = [] all_glyph_os = []
remove_list = []
all_objects = [] all_objects = []
for o in bpy.context.scene.objects: for o in bpy.context.scene.objects:
if marker_property in o: if marker_property in o:
if "type" in o and o["type"] == "glyph": if "type" in o and o["type"] == "glyph":
all_glyph_os.append(o) all_glyph_os.append(o)
else:
remove_list.append(o)
for o in all_glyph_os: for o in all_glyph_os:
glyph_id = o["glyph"] glyph_id = o["glyph"]
font_name = o["font_name"] font_name = o["font_name"]
face_name = o["face_name"] face_name = o["face_name"]
del o[marker_property]
glyph_obj = move_in_fontcollection( glyph_obj = move_in_fontcollection(
o, o,
fontcollection) fontcollection)
if glyph_obj == o:
del o[marker_property]
Font.add_glyph( Font.add_glyph(
font_name, font_name,
face_name, face_name,
@ -446,9 +446,6 @@ def load_font_from_filepath(filepath, glyphs="", font_name="", face_name=""):
modified_font_faces.append({"font_name": font_name, modified_font_faces.append({"font_name": font_name,
"face_name": face_name}) "face_name": face_name})
if glyph_obj != o:
remove_list.append(o)
for mff in modified_font_faces: for mff in modified_font_faces:
glyphs = [] glyphs = []
face = Font.fonts[mff["font_name"]].faces[mff["face_name"]] face = Font.fonts[mff["font_name"]].faces[mff["face_name"]]
@ -675,7 +672,7 @@ def set_text_on_curve(text_properties, recursive=True):
selected_objects = [] selected_objects = []
curve_length = get_curve_length(mom) curve_length = get_curve_length(mom)
advance = 0 advance = text_properties.offset
glyph_advance = 0 glyph_advance = 0
is_command = False is_command = False
for i, c in enumerate(text_properties.text): for i, c in enumerate(text_properties.text):