font3d -> ABC3D

This commit is contained in:
themancalledjakob 2024-08-14 11:26:19 +02:00
parent a7632a9c03
commit 8ce5e6c816
4 changed files with 187 additions and 185 deletions

View file

@ -8,7 +8,7 @@ pip install bpy
# install addon: # install addon:
```bash ```bash
cd <root directory> cd <root directory>
ln -s $(pwd) $HOME/git/tools/blender_git/build_linux_v4.1/bin/4.1/scripts/addons/font3d ln -s $(pwd) $HOME/git/tools/blender_git/build_linux_v4.1/bin/4.1/scripts/addons/abc3d
``` ```
# get blender addon path: # get blender addon path:

View file

@ -5,12 +5,12 @@ A 3D font helper
""" """
bl_info = { bl_info = {
"name": "Font3D", "name": "ABC3D",
"author": "Jakob Schlötter, Studio Pointer*", "author": "Jakob Schlötter, Studio Pointer*",
"version": (0, 0, 1), "version": (0, 0, 1),
"blender": (4, 1, 0), "blender": (4, 1, 0),
"location": "VIEW3D", "location": "VIEW3D",
"description": "Does Font3D stuff", "description": "Does ABC3D stuff",
"category": "Typography", "category": "Typography",
} }
@ -49,8 +49,8 @@ def getPreferences(context):
preferences = context.preferences preferences = context.preferences
return preferences.addons[__name__].preferences return preferences.addons[__name__].preferences
class FONT3D_addonPreferences(bpy.types.AddonPreferences): class ABC3D_addonPreferences(bpy.types.AddonPreferences):
"""Font3D Addon Preferences """ABC3D Addon Preferences
These are the preferences at Edit/Preferences/Add-ons""" These are the preferences at Edit/Preferences/Add-ons"""
@ -91,7 +91,7 @@ class FONT3D_addonPreferences(bpy.types.AddonPreferences):
layout.prop(self, "assets_dir") layout.prop(self, "assets_dir")
class FONT3D_settings(bpy.types.PropertyGroup): class ABC3D_settings(bpy.types.PropertyGroup):
font_path: bpy.props.StringProperty( font_path: bpy.props.StringProperty(
name="Font path", name="Font path",
description="Load a *.glb or *.gltf fontfile from disk", description="Load a *.glb or *.gltf fontfile from disk",
@ -136,11 +136,11 @@ class FONT3D_settings(bpy.types.PropertyGroup):
subtype='EULER', subtype='EULER',
) )
class FONT3D_available_font(bpy.types.PropertyGroup): class ABC3D_available_font(bpy.types.PropertyGroup):
font_name: bpy.props.StringProperty(name="") font_name: bpy.props.StringProperty(name="")
face_name: bpy.props.StringProperty(name="") face_name: bpy.props.StringProperty(name="")
class FONT3D_glyph_properties(bpy.types.PropertyGroup): class ABC3D_glyph_properties(bpy.types.PropertyGroup):
glyph_id: bpy.props.StringProperty(maxlen=1) glyph_id: bpy.props.StringProperty(maxlen=1)
glyph_object: bpy.props.PointerProperty(type=bpy.types.Object) glyph_object: bpy.props.PointerProperty(type=bpy.types.Object)
letter_spacing: bpy.props.FloatProperty( letter_spacing: bpy.props.FloatProperty(
@ -148,7 +148,7 @@ class FONT3D_glyph_properties(bpy.types.PropertyGroup):
description="Letter Spacing", description="Letter Spacing",
) )
class FONT3D_text_properties(bpy.types.PropertyGroup): class ABC3D_text_properties(bpy.types.PropertyGroup):
def font_name_items(self, context): def font_name_items(self, context):
out = [] out = []
for f in Font.fonts.keys(): for f in Font.fonts.keys():
@ -215,13 +215,13 @@ class FONT3D_text_properties(bpy.types.PropertyGroup):
default=False, default=False,
) )
distribution_type: bpy.props.StringProperty() distribution_type: bpy.props.StringProperty()
glyphs: bpy.props.CollectionProperty(type=FONT3D_glyph_properties) glyphs: bpy.props.CollectionProperty(type=ABC3D_glyph_properties)
#TODO: simply, merge, cut cut cut #TODO: simply, merge, cut cut cut
class FONT3D_data(bpy.types.PropertyGroup): class ABC3D_data(bpy.types.PropertyGroup):
available_fonts: bpy.props.CollectionProperty(type=FONT3D_available_font, name="name of the collection property") available_fonts: bpy.props.CollectionProperty(type=ABC3D_available_font, name="name of the collection property")
active_font_index: bpy.props.IntProperty() active_font_index: bpy.props.IntProperty()
available_texts: bpy.props.CollectionProperty(type=FONT3D_text_properties, name="") available_texts: bpy.props.CollectionProperty(type=ABC3D_text_properties, name="")
def active_text_index_update(self, context): def active_text_index_update(self, context):
if self.active_text_index != -1: if self.active_text_index != -1:
o = self.available_texts[self.active_text_index].text_object o = self.available_texts[self.active_text_index].text_object
@ -237,14 +237,14 @@ class FONT3D_data(bpy.types.PropertyGroup):
active_text_index: bpy.props.IntProperty(update=active_text_index_update) active_text_index: bpy.props.IntProperty(update=active_text_index_update)
class FONT3D_UL_fonts(bpy.types.UIList): class ABC3D_UL_fonts(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
layout.label(text=f"{index}: {item.font_name} {item.face_name}") # avoids renaming the item by accident layout.label(text=f"{index}: {item.font_name} {item.face_name}") # avoids renaming the item by accident
def invoke(self, context, event): def invoke(self, context, event):
pass pass
class FONT3D_UL_texts(bpy.types.UIList): class ABC3D_UL_texts(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
split = layout.split(factor=0.3) split = layout.split(factor=0.3)
split.label(text="Id: %d" % (item.text_id)) split.label(text="Id: %d" % (item.text_id))
@ -253,9 +253,9 @@ class FONT3D_UL_texts(bpy.types.UIList):
def invoke(self, context, event): def invoke(self, context, event):
pass pass
class FONT3D_PT_Panel(bpy.types.Panel): class ABC3D_PT_Panel(bpy.types.Panel):
bl_label = f"{__name__} panel" bl_label = f"{__name__} panel"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
@ -265,10 +265,10 @@ class FONT3D_PT_Panel(bpy.types.Panel):
layout.label(text=f"{__name__} panel") layout.label(text=f"{__name__} panel")
class FONT3D_PT_LoadFontPanel(bpy.types.Panel): class ABC3D_PT_LoadFontPanel(bpy.types.Panel):
bl_label = "Load a new font" bl_label = "Load a new font"
bl_parent_id = "FONT3D_PT_Panel" bl_parent_id = "ABC3D_PT_Panel"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
bl_options = {"DEFAULT_CLOSED"} bl_options = {"DEFAULT_CLOSED"}
@ -278,18 +278,18 @@ class FONT3D_PT_LoadFontPanel(bpy.types.Panel):
wm = context.window_manager wm = context.window_manager
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
layout.label(text="Load FontFile:") layout.label(text="Load FontFile:")
layout.row().prop(font3d, "font_path") layout.row().prop(abc3d, "font_path")
layout.row().operator('font3d.loadfont', text='Load Font') layout.row().operator('abc3d.loadfont', text='Load Font')
class FONT3D_PT_FontList(bpy.types.Panel): class ABC3D_PT_FontList(bpy.types.Panel):
bl_label = "Font List" bl_label = "Font List"
bl_parent_id = "FONT3D_PT_Panel" bl_parent_id = "ABC3D_PT_Panel"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
@ -298,16 +298,16 @@ class FONT3D_PT_FontList(bpy.types.Panel):
wm = context.window_manager wm = context.window_manager
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
layout.label(text="Loaded Fonts") layout.label(text="Loaded Fonts")
layout.template_list("FONT3D_UL_fonts", "", font3d_data, "available_fonts", font3d_data, "active_font_index") layout.template_list("ABC3D_UL_fonts", "", abc3d_data, "available_fonts", abc3d_data, "active_font_index")
class FONT3D_PT_TextPlacement(bpy.types.Panel): class ABC3D_PT_TextPlacement(bpy.types.Panel):
bl_label = "Place Text" bl_label = "Place Text"
bl_parent_id = "FONT3D_PT_Panel" bl_parent_id = "ABC3D_PT_Panel"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
@ -326,15 +326,15 @@ class FONT3D_PT_TextPlacement(bpy.types.Panel):
wm = context.window_manager wm = context.window_manager
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
layout.label(text="Set Properties Objects") layout.label(text="Set Properties Objects")
layout.row().prop(font3d, "text") layout.row().prop(abc3d, "text")
layout.row().prop(font3d, "letter_spacing") layout.row().prop(abc3d, "letter_spacing")
layout.row().prop(font3d, "font_size") layout.row().prop(abc3d, "font_size")
layout.column().prop(font3d, "translation") layout.column().prop(abc3d, "translation")
layout.column().prop(font3d, "orientation") layout.column().prop(abc3d, "orientation")
placerow = layout.row() placerow = layout.row()
placerow.enabled = self.can_place placerow.enabled = self.can_place
placerow.operator(f"{__name__}.placetext", text='Place Text') placerow.operator(f"{__name__}.placetext", text='Place Text')
@ -342,10 +342,10 @@ class FONT3D_PT_TextPlacement(bpy.types.Panel):
layout.label(text="Cannot place Text.") layout.label(text="Cannot place Text.")
layout.label(text="Select a curve as active object.") layout.label(text="Select a curve as active object.")
class FONT3D_PT_TextManagement(bpy.types.Panel): class ABC3D_PT_TextManagement(bpy.types.Panel):
bl_label = "Text Management" bl_label = "Text Management"
bl_parent_id = "FONT3D_PT_Panel" bl_parent_id = "ABC3D_PT_Panel"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
@ -353,15 +353,15 @@ class FONT3D_PT_TextManagement(bpy.types.Panel):
@classmethod @classmethod
def poll(self, context): def poll(self, context):
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
# TODO: update available_texts # TODO: update available_texts
def update(): def update():
if bpy.context.screen.is_animation_playing: if bpy.context.screen.is_animation_playing:
return return
active_text_index = -1 active_text_index = -1
remove_list = [] remove_list = []
for i, t in enumerate(font3d_data.available_texts): for i, t in enumerate(abc3d_data.available_texts):
if type(t.text_object) == type(None): if type(t.text_object) == type(None):
remove_list.append(i) remove_list.append(i)
continue continue
@ -389,17 +389,17 @@ class FONT3D_PT_TextManagement(bpy.types.Panel):
remove_list.append(i) remove_list.append(i)
for i in remove_list: for i in remove_list:
font3d_data.available_texts.remove(i) abc3d_data.available_texts.remove(i)
for i, t in enumerate(font3d_data.available_texts): for i, t in enumerate(abc3d_data.available_texts):
if context.active_object == t.text_object: if context.active_object == t.text_object:
active_text_index = i active_text_index = i
if (hasattr(context.active_object, "parent") and if (hasattr(context.active_object, "parent") and
context.active_object.parent == t.text_object): context.active_object.parent == t.text_object):
active_text_index = i active_text_index = i
if active_text_index != font3d_data.active_text_index: if active_text_index != abc3d_data.active_text_index:
font3d_data.active_text_index = active_text_index abc3d_data.active_text_index = active_text_index
butils.run_in_main_thread(update) butils.run_in_main_thread(update)
@ -410,16 +410,16 @@ class FONT3D_PT_TextManagement(bpy.types.Panel):
wm = context.window_manager wm = context.window_manager
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
layout.label(text="Text Objects") layout.label(text="Text Objects")
layout.template_list("FONT3D_UL_texts", "", font3d_data, "available_texts", font3d_data, "active_text_index") layout.template_list("ABC3D_UL_texts", "", abc3d_data, "available_texts", abc3d_data, "active_text_index")
class FONT3D_PT_FontCreation(bpy.types.Panel): class ABC3D_PT_FontCreation(bpy.types.Panel):
bl_label = "Font Creation" bl_label = "Font Creation"
bl_parent_id = "FONT3D_PT_Panel" bl_parent_id = "ABC3D_PT_Panel"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
bl_options = {"DEFAULT_CLOSED"} bl_options = {"DEFAULT_CLOSED"}
@ -429,12 +429,12 @@ class FONT3D_PT_FontCreation(bpy.types.Panel):
wm = context.window_manager wm = context.window_manager
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
layout.row().operator(f"{__name__}.create_font_from_objects", text='Create/Extend Font') layout.row().operator(f"{__name__}.create_font_from_objects", text='Create/Extend Font')
layout.row().operator(f"{__name__}.save_font_to_file", text='Save Font To File') layout.row().operator(f"{__name__}.save_font_to_file", text='Save Font To File')
layout.row().operator(f"{__name__}.toggle_font3d_collection", text='Toggle Collection') layout.row().operator(f"{__name__}.toggle_abc3d_collection", text='Toggle Collection')
box = layout.box() box = layout.box()
box.label(text="metrics") box.label(text="metrics")
box.row().operator(f"{__name__}.add_default_metrics", text='Add Default Metrics') box.row().operator(f"{__name__}.add_default_metrics", text='Add Default Metrics')
@ -443,16 +443,16 @@ class FONT3D_PT_FontCreation(bpy.types.Panel):
box.row().operator(f"{__name__}.align_metrics_to_active_object", text='Align Metrics to Active Object') box.row().operator(f"{__name__}.align_metrics_to_active_object", text='Align Metrics to Active Object')
layout.row().operator(f"{__name__}.temporaryhelper", text='Debug Function Do Not Use') layout.row().operator(f"{__name__}.temporaryhelper", text='Debug Function Do Not Use')
class FONT3D_PT_TextPropertiesPanel(bpy.types.Panel): class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
bl_label = "Text Properties" bl_label = "Text Properties"
bl_parent_id = "FONT3D_PT_TextManagement" bl_parent_id = "ABC3D_PT_TextManagement"
bl_category = "Font3D" bl_category = "ABC3D"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "UI" bl_region_type = "UI"
def get_active_text_properties(self): def get_active_text_properties(self):
if type(bpy.context.active_object) != type(None):# and bpy.context.object.select_get(): if type(bpy.context.active_object) != type(None):# and bpy.context.object.select_get():
for t in bpy.context.scene.font3d_data.available_texts: for t in bpy.context.scene.abc3d_data.available_texts:
if bpy.context.active_object == t.text_object: if bpy.context.active_object == t.text_object:
return t return t
if bpy.context.active_object.parent == t.text_object: if bpy.context.active_object.parent == t.text_object:
@ -467,8 +467,8 @@ class FONT3D_PT_TextPropertiesPanel(bpy.types.Panel):
layout = self.layout layout = self.layout
wm = context.window_manager wm = context.window_manager
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
props = self.get_active_text_properties() props = self.get_active_text_properties()
@ -487,7 +487,7 @@ class FONT3D_PT_TextPropertiesPanel(bpy.types.Panel):
layout.column().prop(props, "translation") layout.column().prop(props, "translation")
layout.column().prop(props, "orientation") layout.column().prop(props, "orientation")
class FONT3D_OT_LoadFont(bpy.types.Operator): class ABC3D_OT_LoadFont(bpy.types.Operator):
"""Load Fontfile from path above. """Load Fontfile from path above.
(Format must be *.glb or *.gltf)""" (Format must be *.glb or *.gltf)"""
bl_idname = f"{__name__}.loadfont" bl_idname = f"{__name__}.loadfont"
@ -504,7 +504,7 @@ class FONT3D_OT_LoadFont(bpy.types.Operator):
) )
return {'CANCELLED'} return {'CANCELLED'}
if not os.path.exists(scene.font3d.font_path): if not os.path.exists(scene.abc3d.font_path):
butils.ShowMessageBox( butils.ShowMessageBox(
title=f"{__name__} Warning", title=f"{__name__} Warning",
icon="ERROR", icon="ERROR",
@ -512,11 +512,11 @@ class FONT3D_OT_LoadFont(bpy.types.Operator):
) )
return {'CANCELLED'} return {'CANCELLED'}
butils.load_font_from_filepath(scene.font3d.font_path) butils.load_font_from_filepath(scene.abc3d.font_path)
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_AddDefaultMetrics(bpy.types.Operator): class ABC3D_OT_AddDefaultMetrics(bpy.types.Operator):
"""Add default metrics to selected objects""" """Add default metrics to selected objects"""
bl_idname = f"{__name__}.add_default_metrics" bl_idname = f"{__name__}.add_default_metrics"
bl_label = "Add default metrics" bl_label = "Add default metrics"
@ -527,7 +527,7 @@ class FONT3D_OT_AddDefaultMetrics(bpy.types.Operator):
butils.add_default_metrics_to_objects(objects) butils.add_default_metrics_to_objects(objects)
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_RemoveMetrics(bpy.types.Operator): class ABC3D_OT_RemoveMetrics(bpy.types.Operator):
"""Remove metrics from selected objects""" """Remove metrics from selected objects"""
bl_idname = f"{__name__}.remove_metrics" bl_idname = f"{__name__}.remove_metrics"
bl_label = "Remove metrics" bl_label = "Remove metrics"
@ -538,7 +538,7 @@ class FONT3D_OT_RemoveMetrics(bpy.types.Operator):
butils.remove_metrics_from_objects(objects) butils.remove_metrics_from_objects(objects)
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_AlignMetricsToActiveObject(bpy.types.Operator): class ABC3D_OT_AlignMetricsToActiveObject(bpy.types.Operator):
"""Align metrics of selected objects to metrics of active object""" """Align metrics of selected objects to metrics of active object"""
bl_idname = f"{__name__}.align_metrics_to_active_object" bl_idname = f"{__name__}.align_metrics_to_active_object"
bl_label = "Align metrics to active object" bl_label = "Align metrics to active object"
@ -549,7 +549,7 @@ class FONT3D_OT_AlignMetricsToActiveObject(bpy.types.Operator):
butils.align_metrics_of_objects_to_active_object(objects) butils.align_metrics_of_objects_to_active_object(objects)
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_AlignMetrics(bpy.types.Operator): class ABC3D_OT_AlignMetrics(bpy.types.Operator):
"""Align metrics of selected objects to each other""" """Align metrics of selected objects to each other"""
bl_idname = f"{__name__}.align_metrics" bl_idname = f"{__name__}.align_metrics"
bl_label = "Align metrics" bl_label = "Align metrics"
@ -560,7 +560,7 @@ class FONT3D_OT_AlignMetrics(bpy.types.Operator):
butils.align_metrics_of_objects(objects) butils.align_metrics_of_objects(objects)
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_TemporaryHelper(bpy.types.Operator): class ABC3D_OT_TemporaryHelper(bpy.types.Operator):
"""Temp Font 3D""" """Temp Font 3D"""
bl_idname = f"{__name__}.temporaryhelper" bl_idname = f"{__name__}.temporaryhelper"
bl_label = "Temp Font" bl_label = "Temp Font"
@ -569,9 +569,9 @@ class FONT3D_OT_TemporaryHelper(bpy.types.Operator):
def execute(self, context): def execute(self, context):
global shared global shared
scene = bpy.context.scene scene = bpy.context.scene
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
# butils.load_font_from_filepath("/home/jrkb/.config/blender/4.1/datafiles/font3d/fonts/NM_Origin.glb") # butils.load_font_from_filepath("/home/jrkb/.config/blender/4.1/datafiles/abc3d/fonts/NM_Origin.glb")
butils.update_available_fonts() butils.update_available_fonts()
# objects = bpy.context.selected_objects # objects = bpy.context.selected_objects
@ -587,7 +587,7 @@ class FONT3D_OT_TemporaryHelper(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_PlaceText(bpy.types.Operator): class ABC3D_OT_PlaceText(bpy.types.Operator):
"""Place Text 3D on active object""" """Place Text 3D on active object"""
bl_idname = f"{__name__}.placetext" bl_idname = f"{__name__}.placetext"
bl_label = "Place Text" bl_label = "Place Text"
@ -599,34 +599,34 @@ class FONT3D_OT_PlaceText(bpy.types.Operator):
selected = bpy.context.view_layer.objects.active selected = bpy.context.view_layer.objects.active
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
if font3d.target_object: if abc3d.target_object:
selected = font3d.target_object selected = abc3d.target_object
if selected: if selected:
font = font3d_data.available_fonts[font3d_data.active_font_index] font = abc3d_data.available_fonts[abc3d_data.active_font_index]
font_name = font.font_name font_name = font.font_name
face_name = font.face_name face_name = font.face_name
distribution_type = 'DEFAULT' distribution_type = 'DEFAULT'
text_id = 0 text_id = 0
for i, tt in enumerate(font3d_data.available_texts): for i, tt in enumerate(abc3d_data.available_texts):
while text_id == tt.text_id: while text_id == tt.text_id:
text_id = text_id + 1 text_id = text_id + 1
t = font3d_data.available_texts.add() t = abc3d_data.available_texts.add()
t.text_id = text_id t.text_id = text_id
t.font_name = font_name t.font_name = font_name
t.face_name = face_name t.face_name = face_name
t.text_object = selected t.text_object = selected
t.text = scene.font3d.text t.text = scene.abc3d.text
t.letter_spacing = scene.font3d.letter_spacing t.letter_spacing = scene.abc3d.letter_spacing
t.font_size = scene.font3d.font_size t.font_size = scene.abc3d.font_size
t.translation = scene.font3d.translation t.translation = scene.abc3d.translation
t.orientation = scene.font3d.orientation t.orientation = scene.abc3d.orientation
t.distribution_type = distribution_type t.distribution_type = distribution_type
else: else:
butils.ShowMessageBox( butils.ShowMessageBox(
@ -639,15 +639,15 @@ class FONT3D_OT_PlaceText(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_ToggleFont3DCollection(bpy.types.Operator): class ABC3D_OT_ToggleABC3DCollection(bpy.types.Operator):
"""Toggle Font3D Collection""" """Toggle ABC3D Collection"""
bl_idname = f"{__name__}.toggle_font3d_collection" bl_idname = f"{__name__}.toggle_abc3d_collection"
bl_label = "Toggle Collection visibility" bl_label = "Toggle Collection visibility"
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
def execute(self, context): def execute(self, context):
scene = context.scene scene = context.scene
fontcollection = bpy.data.collections.get("Font3D") fontcollection = bpy.data.collections.get("ABC3D")
if fontcollection is None: if fontcollection is None:
self.report({'INFO'}, f"{bl_info['name']}: There is no collection") self.report({'INFO'}, f"{bl_info['name']}: There is no collection")
@ -661,7 +661,7 @@ class FONT3D_OT_ToggleFont3DCollection(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
class FONT3D_OT_SaveFontToFile(bpy.types.Operator): class ABC3D_OT_SaveFontToFile(bpy.types.Operator):
"""Save font to file""" """Save font to file"""
bl_idname = f"{__name__}.save_font_to_file" bl_idname = f"{__name__}.save_font_to_file"
bl_label = "Save Font" bl_label = "Save Font"
@ -688,21 +688,21 @@ class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
def execute(self, context): def execute(self, context):
global shared global shared
scene = bpy.context.scene scene = bpy.context.scene
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
font3d = scene.font3d abc3d = scene.abc3d
fontcollection = bpy.data.collections.get("Font3D") fontcollection = bpy.data.collections.get("ABC3D")
# check if all is good to proceed # check if all is good to proceed
if fontcollection is None: if fontcollection is None:
self.report({'INFO'}, f"{bl_info['name']}: There is no collection") self.report({'INFO'}, f"{bl_info['name']}: There is no collection")
return {'CANCELLED'} return {'CANCELLED'}
if font3d_data.active_font_index < 0: if abc3d_data.active_font_index < 0:
self.report({'INFO'}, f"{bl_info['name']}: There is no active font") self.report({'INFO'}, f"{bl_info['name']}: There is no active font")
return {'CANCELLED'} return {'CANCELLED'}
if len(font3d_data.available_fonts) <= font3d_data.active_font_index: if len(abc3d_data.available_fonts) <= abc3d_data.active_font_index:
self.report({'INFO'}, f"{bl_info['name']}: Active font is not available") self.report({'INFO'}, f"{bl_info['name']}: Active font is not available")
return {'CANCELLED'} return {'CANCELLED'}
@ -716,7 +716,7 @@ class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
bpy.ops.object.select_all(action="DESELECT") bpy.ops.object.select_all(action="DESELECT")
# get save data # get save data
selected_font = font3d_data.available_fonts[font3d_data.active_font_index] selected_font = abc3d_data.available_fonts[abc3d_data.active_font_index]
# print(selected_font.font_name) # print(selected_font.font_name)
self.report({'INFO'}, f"{bl_info['name']}: {selected_font.font_name} {selected_font.face_name}") self.report({'INFO'}, f"{bl_info['name']}: {selected_font.font_name} {selected_font.face_name}")
@ -774,12 +774,12 @@ class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
self.report({'INFO'}, f"did it") self.report({'INFO'}, f"did it")
return {'FINISHED'} return {'FINISHED'}
# keep = ['io_anim_bvh', 'io_curve_svg', 'io_mesh_stl', 'io_mesh_uv_layout', 'io_scene_fbx', 'io_scene_gltf2', 'io_scene_x3d', 'cycles', 'pose_library', 'font3d'] # keep = ['io_anim_bvh', 'io_curve_svg', 'io_mesh_stl', 'io_mesh_uv_layout', 'io_scene_fbx', 'io_scene_gltf2', 'io_scene_x3d', 'cycles', 'pose_library', 'abc3d']
# for addon in keep: # for addon in keep:
# bpy.ops.preferences.addon_enable(module=addon) # bpy.ops.preferences.addon_enable(module=addon)
class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator): class ABC3D_OT_CreateFontFromObjects(bpy.types.Operator):
"""Create Font from selected objects""" """Create Font from selected objects"""
bl_idname = f"{__name__}.create_font_from_objects" bl_idname = f"{__name__}.create_font_from_objects"
bl_label = "Create Font" bl_label = "Create Font"
@ -853,15 +853,15 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
print(f"executing {self.bl_idname}") print(f"executing {self.bl_idname}")
global shared global shared
scene = bpy.context.scene scene = bpy.context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
fontcollection = bpy.data.collections.get("Font3D") fontcollection = bpy.data.collections.get("ABC3D")
if fontcollection is None: if fontcollection is None:
fontcollection = bpy.data.collections.new("Font3D") fontcollection = bpy.data.collections.new("ABC3D")
ifxsplit = font3d.import_infix.split('_') ifxsplit = abc3d.import_infix.split('_')
# if len(ifxsplit) != 4: # if len(ifxsplit) != 4:
# font_name = f"{ifxsplit[1]}_{ifxsplit[2]}" # font_name = f"{ifxsplit[1]}_{ifxsplit[2]}"
@ -870,7 +870,7 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
face_name = self.face_name face_name = self.face_name
# TODO: do not clear # TODO: do not clear
# font3d_data.available_fonts.clear() # abc3d_data.available_fonts.clear()
# Font.fonts = {} # Font.fonts = {}
currentObjects = [] currentObjects = []
for o in context.selected_objects: for o in context.selected_objects:
@ -887,7 +887,7 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
if butils.is_mesh(o) and not butils.is_metrics_object(o): if butils.is_mesh(o) and not butils.is_metrics_object(o):
uc = o.users_collection uc = o.users_collection
# regex = f"{font3d.import_infix}(.)*" # regex = f"{abc3d.import_infix}(.)*"
if self.fix_common_misspellings: if self.fix_common_misspellings:
o.name = Font.fix_glyph_name_misspellings(o.name) o.name = Font.fix_glyph_name_misspellings(o.name)
# name = re.sub(regex, "", o.name) # name = re.sub(regex, "", o.name)
@ -911,13 +911,13 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
#TODO: is there a better way to iterate over a CollectionProperty? #TODO: is there a better way to iterate over a CollectionProperty?
found = False found = False
for f in font3d_data.available_fonts.values(): for f in abc3d_data.available_fonts.values():
if (f.font_name == font_name if (f.font_name == font_name
and f.face_name == face_name): and f.face_name == face_name):
found = True found = True
break break
if not found: if not found:
f = font3d_data.available_fonts.add() f = abc3d_data.available_fonts.add()
f.font_name = font_name f.font_name = font_name
f.face_name = face_name f.face_name = face_name
@ -927,10 +927,10 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel): class ABC3D_PT_RightPropertiesPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window""" """Creates a Panel in the Object properties window"""
bl_label = f"{bl_info['name']}" bl_label = f"{bl_info['name']}"
bl_idname = "FONT3D_PT_RightPropertiesPanel" bl_idname = "ABC3D_PT_RightPropertiesPanel"
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
bl_context = "object" bl_context = "object"
@ -938,28 +938,28 @@ class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
@classmethod @classmethod
def poll(self,context): def poll(self,context):
# only show the panel, if it's a textobject or a glyph # only show the panel, if it's a textobject or a glyph
is_text = type(next((t for t in context.scene.font3d_data.available_texts if t.text_object == context.active_object), None)) != type(None) is_text = type(next((t for t in context.scene.abc3d_data.available_texts if t.text_object == context.active_object), None)) != type(None)
is_glyph = type(next((t for t in context.scene.font3d_data.available_texts if t.text_object == context.active_object.parent), None)) != type(None) is_glyph = type(next((t for t in context.scene.abc3d_data.available_texts if t.text_object == context.active_object.parent), None)) != type(None)
return is_text or is_glyph return is_text or is_glyph
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
scene = context.scene scene = context.scene
font3d = scene.font3d abc3d = scene.abc3d
font3d_data = scene.font3d_data abc3d_data = scene.abc3d_data
obj = context.active_object obj = context.active_object
def is_it_text(): def is_it_text():
return type(next((t for t in context.scene.font3d_data.available_texts if t.text_object == context.active_object), None)) != type(None) return type(next((t for t in context.scene.abc3d_data.available_texts if t.text_object == context.active_object), None)) != type(None)
def is_it_glyph(): def is_it_glyph():
return type(next((t for t in context.scene.font3d_data.available_texts if t.text_object == context.active_object.parent), None)) != type(None) return type(next((t for t in context.scene.abc3d_data.available_texts if t.text_object == context.active_object.parent), None)) != type(None)
is_text = is_it_text() is_text = is_it_text()
is_glyph = is_it_glyph() is_glyph = is_it_glyph()
textobject = obj if is_text else obj.parent if is_glyph else obj textobject = obj if is_text else obj.parent if is_glyph else obj
available_text = font3d_data.available_texts[font3d_data.active_text_index] available_text = abc3d_data.available_texts[abc3d_data.active_text_index]
# row = layout.row() # row = layout.row()
# row.label(text="Hello world!", icon='WORLD_DATA') # row.label(text="Hello world!", icon='WORLD_DATA')
@ -968,7 +968,7 @@ class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
# row = layout.row() # row = layout.row()
# row.label(text="text object is: " + textobject.name) # row.label(text="text object is: " + textobject.name)
row = layout.row() row = layout.row()
row.label(text=f"active text index is: {font3d_data.active_text_index}") row.label(text=f"active text index is: {abc3d_data.active_text_index}")
layout.row().label(text="Text Properties:") layout.row().label(text="Text Properties:")
layout.row().prop(available_text, "text") layout.row().prop(available_text, "text")
@ -982,7 +982,7 @@ class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
if is_glyph: if is_glyph:
layout.row().label(text="Glyph Properties:") layout.row().label(text="Glyph Properties:")
class FONT3D_OT_Reporter(bpy.types.Operator): class ABC3D_OT_Reporter(bpy.types.Operator):
bl_idname = f"{__name__}.reporter" bl_idname = f"{__name__}.reporter"
bl_label = "Report" bl_label = "Report"
@ -1004,33 +1004,33 @@ class FONT3D_OT_Reporter(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
classes = ( classes = (
FONT3D_addonPreferences, ABC3D_addonPreferences,
FONT3D_available_font, ABC3D_available_font,
FONT3D_glyph_properties, ABC3D_glyph_properties,
FONT3D_text_properties, ABC3D_text_properties,
FONT3D_data, ABC3D_data,
FONT3D_settings, ABC3D_settings,
FONT3D_UL_fonts, ABC3D_UL_fonts,
FONT3D_UL_texts, ABC3D_UL_texts,
FONT3D_PT_Panel, ABC3D_PT_Panel,
FONT3D_PT_LoadFontPanel, ABC3D_PT_LoadFontPanel,
FONT3D_PT_FontList, ABC3D_PT_FontList,
FONT3D_PT_TextPlacement, ABC3D_PT_TextPlacement,
FONT3D_PT_TextManagement, ABC3D_PT_TextManagement,
FONT3D_PT_FontCreation, ABC3D_PT_FontCreation,
FONT3D_PT_TextPropertiesPanel, ABC3D_PT_TextPropertiesPanel,
FONT3D_OT_AddDefaultMetrics, ABC3D_OT_AddDefaultMetrics,
FONT3D_OT_RemoveMetrics, ABC3D_OT_RemoveMetrics,
FONT3D_OT_AlignMetricsToActiveObject, ABC3D_OT_AlignMetricsToActiveObject,
FONT3D_OT_AlignMetrics, ABC3D_OT_AlignMetrics,
FONT3D_OT_TemporaryHelper, ABC3D_OT_TemporaryHelper,
FONT3D_OT_PlaceText, ABC3D_OT_PlaceText,
FONT3D_OT_LoadFont, ABC3D_OT_LoadFont,
FONT3D_OT_ToggleFont3DCollection, ABC3D_OT_ToggleABC3DCollection,
FONT3D_OT_SaveFontToFile, ABC3D_OT_SaveFontToFile,
FONT3D_OT_CreateFontFromObjects, ABC3D_OT_CreateFontFromObjects,
FONT3D_PT_RightPropertiesPanel, ABC3D_PT_RightPropertiesPanel,
FONT3D_OT_Reporter, ABC3D_OT_Reporter,
) )
@persistent @persistent
@ -1045,10 +1045,10 @@ def load_handler_unload():
@persistent @persistent
def on_frame_changed(self, dummy): def on_frame_changed(self, dummy):
for t in bpy.context.scene.font3d_data.available_texts: for t in bpy.context.scene.abc3d_data.available_texts:
# TODO PERFORMANCE: only on demand # TODO PERFORMANCE: only on demand
butils.set_text_on_curve(t) butils.set_text_on_curve(t)
# for i, t in enumerate(bpy.context.scene.font3d_data.available_texts): # for i, t in enumerate(bpy.context.scene.abc3d_data.available_texts):
# # TODO PERFORMANCE: only on demand # # TODO PERFORMANCE: only on demand
# # butils.set_text_on_curve(t) # # butils.set_text_on_curve(t)
# pass # pass
@ -1056,8 +1056,8 @@ def on_frame_changed(self, dummy):
def register(): def register():
for cls in classes: for cls in classes:
bpy.utils.register_class(cls) bpy.utils.register_class(cls)
bpy.types.Scene.font3d = bpy.props.PointerProperty(type=FONT3D_settings) bpy.types.Scene.abc3d = bpy.props.PointerProperty(type=ABC3D_settings)
bpy.types.Scene.font3d_data = bpy.props.PointerProperty(type=FONT3D_data) bpy.types.Scene.abc3d_data = bpy.props.PointerProperty(type=ABC3D_data)
# bpy.types.Object.__del__ = lambda self: print(f"Bye {self.name}") # bpy.types.Object.__del__ = lambda self: print(f"Bye {self.name}")
print(f"REGISTER {bl_info['name']}") print(f"REGISTER {bl_info['name']}")
@ -1089,8 +1089,8 @@ def unregister():
if on_frame_changed in bpy.app.handlers.frame_change_post: if on_frame_changed in bpy.app.handlers.frame_change_post:
bpy.app.handlers.frame_change_post.remove(on_frame_changed) bpy.app.handlers.frame_change_post.remove(on_frame_changed)
del bpy.types.Scene.font3d del bpy.types.Scene.abc3d
del bpy.types.Scene.font3d_data del bpy.types.Scene.abc3d_data
print(f"UNREGISTER {bl_info['name']}") print(f"UNREGISTER {bl_info['name']}")
if __name__ == '__main__': if __name__ == '__main__':

View file

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

View file

@ -151,19 +151,19 @@ def get_glyph(font_name, face_name, glyph_id, alternate=0):
""" """
# print(fonts) # print(fonts)
if not fonts.keys().__contains__(font_name): if not fonts.keys().__contains__(font_name):
print(f"FONT3D::get_glyph: font name({font_name}) not found") print(f"ABC3D::get_glyph: font name({font_name}) not found")
print(fonts.keys()) print(fonts.keys())
return None return None
face = fonts[font_name].faces.get(face_name) face = fonts[font_name].faces.get(face_name)
if face == None: if face == None:
print(f"FONT3D::get_glyph: font({font_name}) face({face_name}) not found") print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) not found")
print(fonts[font_name].faces.keys()) print(fonts[font_name].faces.keys())
return None return None
glyphs_for_id = face.glyphs.get(glyph_id) glyphs_for_id = face.glyphs.get(glyph_id)
if glyphs_for_id == None or len(glyphs_for_id) <= alternate: if glyphs_for_id == None or len(glyphs_for_id) <= alternate:
print(f"FONT3D::get_glyph: font({font_name}) face({face_name}) glyph({glyph_id})[{alternate}] not found") print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) glyph({glyph_id})[{alternate}] not found")
return None return None
return fonts[font_name].faces[face_name].glyphs.get(glyph_id)[alternate] return fonts[font_name].faces[face_name].glyphs.get(glyph_id)[alternate]