From 850377e0f5f074822cea7a95bded7134ead12c6d Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Wed, 21 Aug 2024 17:31:19 +0200 Subject: [PATCH] add offset --- __init__.py | 21 +++++++++++++++++++++ butils.py | 13 +++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index b98d237..a0779d1 100644 --- a/__init__.py +++ b/__init__.py @@ -137,6 +137,11 @@ class ABC3D_settings(bpy.types.PropertyGroup): default=(1.5707963267948966, 0.0, 0.0), # 90 degrees in radians subtype='EULER', ) + offset: bpy.props.FloatProperty( + name="Offset", + default=0.0, + subtype='NONE', + ) class ABC3D_available_font(bpy.types.PropertyGroup): font_name: bpy.props.StringProperty(name="") @@ -230,6 +235,12 @@ class ABC3D_text_properties(bpy.types.PropertyGroup): default=1.0, subtype='NONE', ) + offset: bpy.props.FloatProperty( + update=update_callback, + name="Offset", + default=0.0, + subtype='NONE', + ) compensate_curvature: bpy.props.BoolProperty( update=update_callback, 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()}_orientation") delif(mom,f"{utils.prefix()}_translation") + delif(mom,f"{utils.prefix()}_offset") abc3d_data.available_texts.remove(i) 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, "letter_spacing") layout.row().prop(props, "font_size") + layout.row().prop(props, "offset") layout.row().prop(props, "compensate_curvature") layout.row().prop(props, "ignore_orientation") 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()}_orientation") delif(mom,f"{utils.prefix()}_translation") + delif(mom,f"{utils.prefix()}_offset") if self.remove_objects: remove_list = [] for g in abc3d_data.available_texts[i].glyphs: @@ -852,6 +866,11 @@ class ABC3D_OT_PlaceText(bpy.types.Operator): default=1.0, subtype='NONE', ) + offset: bpy.props.FloatProperty( + name="Offset", + default=0.0, + subtype='NONE', + ) translation: bpy.props.FloatVectorProperty( name="Translation", default=(0.0, 0.0, 0.0), @@ -902,6 +921,7 @@ class ABC3D_OT_PlaceText(bpy.types.Operator): t['text'] = self.text t['letter_spacing'] = self.letter_spacing t['font_size'] = self.font_size + t['offset'] = self.offset t['translation'] = self.translation t['orientation'] = self.orientation 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, "letter_spacing") 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, "ignore_orientation") layout.column().prop(available_text, "translation") diff --git a/butils.py b/butils.py index b93a5ea..7e4fe10 100644 --- a/butils.py +++ b/butils.py @@ -416,24 +416,24 @@ def load_font_from_filepath(filepath, glyphs="", font_name="", face_name=""): modified_font_faces = [] all_glyph_os = [] - remove_list = [] all_objects = [] for o in bpy.context.scene.objects: if marker_property in o: if "type" in o and o["type"] == "glyph": all_glyph_os.append(o) - else: - remove_list.append(o) for o in all_glyph_os: glyph_id = o["glyph"] font_name = o["font_name"] face_name = o["face_name"] - del o[marker_property] glyph_obj = move_in_fontcollection( o, fontcollection) + + if glyph_obj == o: + del o[marker_property] + Font.add_glyph( font_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, "face_name": face_name}) - if glyph_obj != o: - remove_list.append(o) - for mff in modified_font_faces: glyphs = [] 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 = [] curve_length = get_curve_length(mom) - advance = 0 + advance = text_properties.offset glyph_advance = 0 is_command = False for i, c in enumerate(text_properties.text):