font3d -> ABC3D
This commit is contained in:
parent
a7632a9c03
commit
8ce5e6c816
4 changed files with 187 additions and 185 deletions
|
@ -8,7 +8,7 @@ pip install bpy
|
|||
# install addon:
|
||||
```bash
|
||||
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:
|
||||
|
|
306
__init__.py
306
__init__.py
|
@ -5,12 +5,12 @@ A 3D font helper
|
|||
"""
|
||||
|
||||
bl_info = {
|
||||
"name": "Font3D",
|
||||
"name": "ABC3D",
|
||||
"author": "Jakob Schlötter, Studio Pointer*",
|
||||
"version": (0, 0, 1),
|
||||
"blender": (4, 1, 0),
|
||||
"location": "VIEW3D",
|
||||
"description": "Does Font3D stuff",
|
||||
"description": "Does ABC3D stuff",
|
||||
"category": "Typography",
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ def getPreferences(context):
|
|||
preferences = context.preferences
|
||||
return preferences.addons[__name__].preferences
|
||||
|
||||
class FONT3D_addonPreferences(bpy.types.AddonPreferences):
|
||||
"""Font3D Addon Preferences
|
||||
class ABC3D_addonPreferences(bpy.types.AddonPreferences):
|
||||
"""ABC3D Addon Preferences
|
||||
|
||||
These are the preferences at Edit/Preferences/Add-ons"""
|
||||
|
||||
|
@ -91,7 +91,7 @@ class FONT3D_addonPreferences(bpy.types.AddonPreferences):
|
|||
layout.prop(self, "assets_dir")
|
||||
|
||||
|
||||
class FONT3D_settings(bpy.types.PropertyGroup):
|
||||
class ABC3D_settings(bpy.types.PropertyGroup):
|
||||
font_path: bpy.props.StringProperty(
|
||||
name="Font path",
|
||||
description="Load a *.glb or *.gltf fontfile from disk",
|
||||
|
@ -136,11 +136,11 @@ class FONT3D_settings(bpy.types.PropertyGroup):
|
|||
subtype='EULER',
|
||||
)
|
||||
|
||||
class FONT3D_available_font(bpy.types.PropertyGroup):
|
||||
class ABC3D_available_font(bpy.types.PropertyGroup):
|
||||
font_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_object: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
letter_spacing: bpy.props.FloatProperty(
|
||||
|
@ -148,7 +148,7 @@ class FONT3D_glyph_properties(bpy.types.PropertyGroup):
|
|||
description="Letter Spacing",
|
||||
)
|
||||
|
||||
class FONT3D_text_properties(bpy.types.PropertyGroup):
|
||||
class ABC3D_text_properties(bpy.types.PropertyGroup):
|
||||
def font_name_items(self, context):
|
||||
out = []
|
||||
for f in Font.fonts.keys():
|
||||
|
@ -215,13 +215,13 @@ class FONT3D_text_properties(bpy.types.PropertyGroup):
|
|||
default=False,
|
||||
)
|
||||
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
|
||||
class FONT3D_data(bpy.types.PropertyGroup):
|
||||
available_fonts: bpy.props.CollectionProperty(type=FONT3D_available_font, name="name of the collection property")
|
||||
class ABC3D_data(bpy.types.PropertyGroup):
|
||||
available_fonts: bpy.props.CollectionProperty(type=ABC3D_available_font, name="name of the collection property")
|
||||
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):
|
||||
if self.active_text_index != -1:
|
||||
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)
|
||||
|
||||
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):
|
||||
layout.label(text=f"{index}: {item.font_name} {item.face_name}") # avoids renaming the item by accident
|
||||
|
||||
def invoke(self, context, event):
|
||||
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):
|
||||
split = layout.split(factor=0.3)
|
||||
split.label(text="Id: %d" % (item.text_id))
|
||||
|
@ -253,9 +253,9 @@ class FONT3D_UL_texts(bpy.types.UIList):
|
|||
def invoke(self, context, event):
|
||||
pass
|
||||
|
||||
class FONT3D_PT_Panel(bpy.types.Panel):
|
||||
class ABC3D_PT_Panel(bpy.types.Panel):
|
||||
bl_label = f"{__name__} panel"
|
||||
bl_category = "Font3D"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
|
||||
|
@ -265,10 +265,10 @@ class FONT3D_PT_Panel(bpy.types.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_parent_id = "FONT3D_PT_Panel"
|
||||
bl_category = "Font3D"
|
||||
bl_parent_id = "ABC3D_PT_Panel"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
|
@ -278,18 +278,18 @@ class FONT3D_PT_LoadFontPanel(bpy.types.Panel):
|
|||
wm = context.window_manager
|
||||
scene = context.scene
|
||||
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
layout.label(text="Load FontFile:")
|
||||
layout.row().prop(font3d, "font_path")
|
||||
layout.row().operator('font3d.loadfont', text='Load Font')
|
||||
layout.row().prop(abc3d, "font_path")
|
||||
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_parent_id = "FONT3D_PT_Panel"
|
||||
bl_category = "Font3D"
|
||||
bl_parent_id = "ABC3D_PT_Panel"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
|
||||
|
@ -298,16 +298,16 @@ class FONT3D_PT_FontList(bpy.types.Panel):
|
|||
wm = context.window_manager
|
||||
scene = context.scene
|
||||
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
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_parent_id = "FONT3D_PT_Panel"
|
||||
bl_category = "Font3D"
|
||||
bl_parent_id = "ABC3D_PT_Panel"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
|
||||
|
@ -326,15 +326,15 @@ class FONT3D_PT_TextPlacement(bpy.types.Panel):
|
|||
wm = context.window_manager
|
||||
scene = context.scene
|
||||
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
layout.label(text="Set Properties Objects")
|
||||
layout.row().prop(font3d, "text")
|
||||
layout.row().prop(font3d, "letter_spacing")
|
||||
layout.row().prop(font3d, "font_size")
|
||||
layout.column().prop(font3d, "translation")
|
||||
layout.column().prop(font3d, "orientation")
|
||||
layout.row().prop(abc3d, "text")
|
||||
layout.row().prop(abc3d, "letter_spacing")
|
||||
layout.row().prop(abc3d, "font_size")
|
||||
layout.column().prop(abc3d, "translation")
|
||||
layout.column().prop(abc3d, "orientation")
|
||||
placerow = layout.row()
|
||||
placerow.enabled = self.can_place
|
||||
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="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_parent_id = "FONT3D_PT_Panel"
|
||||
bl_category = "Font3D"
|
||||
bl_parent_id = "ABC3D_PT_Panel"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
|
||||
|
@ -353,15 +353,15 @@ class FONT3D_PT_TextManagement(bpy.types.Panel):
|
|||
@classmethod
|
||||
def poll(self, context):
|
||||
scene = context.scene
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
# TODO: update available_texts
|
||||
def update():
|
||||
if bpy.context.screen.is_animation_playing:
|
||||
return
|
||||
active_text_index = -1
|
||||
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):
|
||||
remove_list.append(i)
|
||||
continue
|
||||
|
@ -389,17 +389,17 @@ class FONT3D_PT_TextManagement(bpy.types.Panel):
|
|||
remove_list.append(i)
|
||||
|
||||
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:
|
||||
active_text_index = i
|
||||
if (hasattr(context.active_object, "parent") and
|
||||
context.active_object.parent == t.text_object):
|
||||
active_text_index = i
|
||||
|
||||
if active_text_index != font3d_data.active_text_index:
|
||||
font3d_data.active_text_index = active_text_index
|
||||
if active_text_index != abc3d_data.active_text_index:
|
||||
abc3d_data.active_text_index = active_text_index
|
||||
|
||||
butils.run_in_main_thread(update)
|
||||
|
||||
|
@ -410,16 +410,16 @@ class FONT3D_PT_TextManagement(bpy.types.Panel):
|
|||
wm = context.window_manager
|
||||
scene = context.scene
|
||||
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
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_parent_id = "FONT3D_PT_Panel"
|
||||
bl_category = "Font3D"
|
||||
bl_parent_id = "ABC3D_PT_Panel"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
|
@ -429,12 +429,12 @@ class FONT3D_PT_FontCreation(bpy.types.Panel):
|
|||
wm = context.window_manager
|
||||
scene = context.scene
|
||||
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
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__}.toggle_font3d_collection", text='Toggle Collection')
|
||||
layout.row().operator(f"{__name__}.toggle_abc3d_collection", text='Toggle Collection')
|
||||
box = layout.box()
|
||||
box.label(text="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')
|
||||
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_parent_id = "FONT3D_PT_TextManagement"
|
||||
bl_category = "Font3D"
|
||||
bl_parent_id = "ABC3D_PT_TextManagement"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
|
||||
def get_active_text_properties(self):
|
||||
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:
|
||||
return t
|
||||
if bpy.context.active_object.parent == t.text_object:
|
||||
|
@ -467,8 +467,8 @@ class FONT3D_PT_TextPropertiesPanel(bpy.types.Panel):
|
|||
layout = self.layout
|
||||
wm = context.window_manager
|
||||
scene = context.scene
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
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, "orientation")
|
||||
|
||||
class FONT3D_OT_LoadFont(bpy.types.Operator):
|
||||
class ABC3D_OT_LoadFont(bpy.types.Operator):
|
||||
"""Load Fontfile from path above.
|
||||
(Format must be *.glb or *.gltf)"""
|
||||
bl_idname = f"{__name__}.loadfont"
|
||||
|
@ -504,7 +504,7 @@ class FONT3D_OT_LoadFont(bpy.types.Operator):
|
|||
)
|
||||
return {'CANCELLED'}
|
||||
|
||||
if not os.path.exists(scene.font3d.font_path):
|
||||
if not os.path.exists(scene.abc3d.font_path):
|
||||
butils.ShowMessageBox(
|
||||
title=f"{__name__} Warning",
|
||||
icon="ERROR",
|
||||
|
@ -512,11 +512,11 @@ class FONT3D_OT_LoadFont(bpy.types.Operator):
|
|||
)
|
||||
return {'CANCELLED'}
|
||||
|
||||
butils.load_font_from_filepath(scene.font3d.font_path)
|
||||
butils.load_font_from_filepath(scene.abc3d.font_path)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_OT_AddDefaultMetrics(bpy.types.Operator):
|
||||
class ABC3D_OT_AddDefaultMetrics(bpy.types.Operator):
|
||||
"""Add default metrics to selected objects"""
|
||||
bl_idname = f"{__name__}.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)
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_OT_RemoveMetrics(bpy.types.Operator):
|
||||
class ABC3D_OT_RemoveMetrics(bpy.types.Operator):
|
||||
"""Remove metrics from selected objects"""
|
||||
bl_idname = f"{__name__}.remove_metrics"
|
||||
bl_label = "Remove metrics"
|
||||
|
@ -538,7 +538,7 @@ class FONT3D_OT_RemoveMetrics(bpy.types.Operator):
|
|||
butils.remove_metrics_from_objects(objects)
|
||||
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"""
|
||||
bl_idname = f"{__name__}.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)
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_OT_AlignMetrics(bpy.types.Operator):
|
||||
class ABC3D_OT_AlignMetrics(bpy.types.Operator):
|
||||
"""Align metrics of selected objects to each other"""
|
||||
bl_idname = f"{__name__}.align_metrics"
|
||||
bl_label = "Align metrics"
|
||||
|
@ -560,7 +560,7 @@ class FONT3D_OT_AlignMetrics(bpy.types.Operator):
|
|||
butils.align_metrics_of_objects(objects)
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_OT_TemporaryHelper(bpy.types.Operator):
|
||||
class ABC3D_OT_TemporaryHelper(bpy.types.Operator):
|
||||
"""Temp Font 3D"""
|
||||
bl_idname = f"{__name__}.temporaryhelper"
|
||||
bl_label = "Temp Font"
|
||||
|
@ -569,9 +569,9 @@ class FONT3D_OT_TemporaryHelper(bpy.types.Operator):
|
|||
def execute(self, context):
|
||||
global shared
|
||||
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()
|
||||
|
||||
# objects = bpy.context.selected_objects
|
||||
|
@ -587,7 +587,7 @@ class FONT3D_OT_TemporaryHelper(bpy.types.Operator):
|
|||
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_OT_PlaceText(bpy.types.Operator):
|
||||
class ABC3D_OT_PlaceText(bpy.types.Operator):
|
||||
"""Place Text 3D on active object"""
|
||||
bl_idname = f"{__name__}.placetext"
|
||||
bl_label = "Place Text"
|
||||
|
@ -599,34 +599,34 @@ class FONT3D_OT_PlaceText(bpy.types.Operator):
|
|||
|
||||
selected = bpy.context.view_layer.objects.active
|
||||
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
if font3d.target_object:
|
||||
selected = font3d.target_object
|
||||
if abc3d.target_object:
|
||||
selected = abc3d.target_object
|
||||
|
||||
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
|
||||
face_name = font.face_name
|
||||
|
||||
distribution_type = 'DEFAULT'
|
||||
|
||||
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:
|
||||
text_id = text_id + 1
|
||||
t = font3d_data.available_texts.add()
|
||||
t = abc3d_data.available_texts.add()
|
||||
t.text_id = text_id
|
||||
|
||||
t.font_name = font_name
|
||||
t.face_name = face_name
|
||||
t.text_object = selected
|
||||
t.text = scene.font3d.text
|
||||
t.letter_spacing = scene.font3d.letter_spacing
|
||||
t.font_size = scene.font3d.font_size
|
||||
t.translation = scene.font3d.translation
|
||||
t.orientation = scene.font3d.orientation
|
||||
t.text = scene.abc3d.text
|
||||
t.letter_spacing = scene.abc3d.letter_spacing
|
||||
t.font_size = scene.abc3d.font_size
|
||||
t.translation = scene.abc3d.translation
|
||||
t.orientation = scene.abc3d.orientation
|
||||
t.distribution_type = distribution_type
|
||||
else:
|
||||
butils.ShowMessageBox(
|
||||
|
@ -639,15 +639,15 @@ class FONT3D_OT_PlaceText(bpy.types.Operator):
|
|||
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_OT_ToggleFont3DCollection(bpy.types.Operator):
|
||||
"""Toggle Font3D Collection"""
|
||||
bl_idname = f"{__name__}.toggle_font3d_collection"
|
||||
class ABC3D_OT_ToggleABC3DCollection(bpy.types.Operator):
|
||||
"""Toggle ABC3D Collection"""
|
||||
bl_idname = f"{__name__}.toggle_abc3d_collection"
|
||||
bl_label = "Toggle Collection visibility"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
scene = context.scene
|
||||
fontcollection = bpy.data.collections.get("Font3D")
|
||||
fontcollection = bpy.data.collections.get("ABC3D")
|
||||
|
||||
if fontcollection is None:
|
||||
self.report({'INFO'}, f"{bl_info['name']}: There is no collection")
|
||||
|
@ -661,7 +661,7 @@ class FONT3D_OT_ToggleFont3DCollection(bpy.types.Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
|
||||
class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
|
||||
class ABC3D_OT_SaveFontToFile(bpy.types.Operator):
|
||||
"""Save font to file"""
|
||||
bl_idname = f"{__name__}.save_font_to_file"
|
||||
bl_label = "Save Font"
|
||||
|
@ -688,21 +688,21 @@ class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
|
|||
def execute(self, context):
|
||||
global shared
|
||||
scene = bpy.context.scene
|
||||
font3d_data = scene.font3d_data
|
||||
font3d = scene.font3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
abc3d = scene.abc3d
|
||||
|
||||
fontcollection = bpy.data.collections.get("Font3D")
|
||||
fontcollection = bpy.data.collections.get("ABC3D")
|
||||
|
||||
# check if all is good to proceed
|
||||
if fontcollection is None:
|
||||
self.report({'INFO'}, f"{bl_info['name']}: There is no collection")
|
||||
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")
|
||||
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")
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
@ -716,7 +716,7 @@ class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
|
|||
bpy.ops.object.select_all(action="DESELECT")
|
||||
|
||||
# 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)
|
||||
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")
|
||||
|
||||
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:
|
||||
# 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"""
|
||||
bl_idname = f"{__name__}.create_font_from_objects"
|
||||
bl_label = "Create Font"
|
||||
|
@ -853,15 +853,15 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
print(f"executing {self.bl_idname}")
|
||||
global shared
|
||||
scene = bpy.context.scene
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
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")
|
||||
|
||||
ifxsplit = font3d.import_infix.split('_')
|
||||
ifxsplit = abc3d.import_infix.split('_')
|
||||
# if len(ifxsplit) != 4:
|
||||
|
||||
# font_name = f"{ifxsplit[1]}_{ifxsplit[2]}"
|
||||
|
@ -870,7 +870,7 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
face_name = self.face_name
|
||||
|
||||
# TODO: do not clear
|
||||
# font3d_data.available_fonts.clear()
|
||||
# abc3d_data.available_fonts.clear()
|
||||
# Font.fonts = {}
|
||||
currentObjects = []
|
||||
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):
|
||||
uc = o.users_collection
|
||||
# regex = f"{font3d.import_infix}(.)*"
|
||||
# regex = f"{abc3d.import_infix}(.)*"
|
||||
if self.fix_common_misspellings:
|
||||
o.name = Font.fix_glyph_name_misspellings(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?
|
||||
found = False
|
||||
for f in font3d_data.available_fonts.values():
|
||||
for f in abc3d_data.available_fonts.values():
|
||||
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
|
||||
|
||||
|
@ -927,10 +927,10 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
|
||||
return {'FINISHED'}
|
||||
|
||||
class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
|
||||
class ABC3D_PT_RightPropertiesPanel(bpy.types.Panel):
|
||||
"""Creates a Panel in the Object properties window"""
|
||||
bl_label = f"{bl_info['name']}"
|
||||
bl_idname = "FONT3D_PT_RightPropertiesPanel"
|
||||
bl_idname = "ABC3D_PT_RightPropertiesPanel"
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
bl_context = "object"
|
||||
|
@ -938,28 +938,28 @@ class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
|
|||
@classmethod
|
||||
def poll(self,context):
|
||||
# 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_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_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.abc3d_data.available_texts if t.text_object == context.active_object.parent), None)) != type(None)
|
||||
return is_text or is_glyph
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = context.scene
|
||||
font3d = scene.font3d
|
||||
font3d_data = scene.font3d_data
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
obj = context.active_object
|
||||
|
||||
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():
|
||||
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_glyph = is_it_glyph()
|
||||
|
||||
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.label(text="Hello world!", icon='WORLD_DATA')
|
||||
|
@ -968,7 +968,7 @@ class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
|
|||
# row = layout.row()
|
||||
# row.label(text="text object is: " + textobject.name)
|
||||
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().prop(available_text, "text")
|
||||
|
@ -982,7 +982,7 @@ class FONT3D_PT_RightPropertiesPanel(bpy.types.Panel):
|
|||
if is_glyph:
|
||||
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_label = "Report"
|
||||
|
||||
|
@ -1004,33 +1004,33 @@ class FONT3D_OT_Reporter(bpy.types.Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
classes = (
|
||||
FONT3D_addonPreferences,
|
||||
FONT3D_available_font,
|
||||
FONT3D_glyph_properties,
|
||||
FONT3D_text_properties,
|
||||
FONT3D_data,
|
||||
FONT3D_settings,
|
||||
FONT3D_UL_fonts,
|
||||
FONT3D_UL_texts,
|
||||
FONT3D_PT_Panel,
|
||||
FONT3D_PT_LoadFontPanel,
|
||||
FONT3D_PT_FontList,
|
||||
FONT3D_PT_TextPlacement,
|
||||
FONT3D_PT_TextManagement,
|
||||
FONT3D_PT_FontCreation,
|
||||
FONT3D_PT_TextPropertiesPanel,
|
||||
FONT3D_OT_AddDefaultMetrics,
|
||||
FONT3D_OT_RemoveMetrics,
|
||||
FONT3D_OT_AlignMetricsToActiveObject,
|
||||
FONT3D_OT_AlignMetrics,
|
||||
FONT3D_OT_TemporaryHelper,
|
||||
FONT3D_OT_PlaceText,
|
||||
FONT3D_OT_LoadFont,
|
||||
FONT3D_OT_ToggleFont3DCollection,
|
||||
FONT3D_OT_SaveFontToFile,
|
||||
FONT3D_OT_CreateFontFromObjects,
|
||||
FONT3D_PT_RightPropertiesPanel,
|
||||
FONT3D_OT_Reporter,
|
||||
ABC3D_addonPreferences,
|
||||
ABC3D_available_font,
|
||||
ABC3D_glyph_properties,
|
||||
ABC3D_text_properties,
|
||||
ABC3D_data,
|
||||
ABC3D_settings,
|
||||
ABC3D_UL_fonts,
|
||||
ABC3D_UL_texts,
|
||||
ABC3D_PT_Panel,
|
||||
ABC3D_PT_LoadFontPanel,
|
||||
ABC3D_PT_FontList,
|
||||
ABC3D_PT_TextPlacement,
|
||||
ABC3D_PT_TextManagement,
|
||||
ABC3D_PT_FontCreation,
|
||||
ABC3D_PT_TextPropertiesPanel,
|
||||
ABC3D_OT_AddDefaultMetrics,
|
||||
ABC3D_OT_RemoveMetrics,
|
||||
ABC3D_OT_AlignMetricsToActiveObject,
|
||||
ABC3D_OT_AlignMetrics,
|
||||
ABC3D_OT_TemporaryHelper,
|
||||
ABC3D_OT_PlaceText,
|
||||
ABC3D_OT_LoadFont,
|
||||
ABC3D_OT_ToggleABC3DCollection,
|
||||
ABC3D_OT_SaveFontToFile,
|
||||
ABC3D_OT_CreateFontFromObjects,
|
||||
ABC3D_PT_RightPropertiesPanel,
|
||||
ABC3D_OT_Reporter,
|
||||
)
|
||||
|
||||
@persistent
|
||||
|
@ -1045,10 +1045,10 @@ def load_handler_unload():
|
|||
|
||||
@persistent
|
||||
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
|
||||
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
|
||||
# # butils.set_text_on_curve(t)
|
||||
# pass
|
||||
|
@ -1056,8 +1056,8 @@ def on_frame_changed(self, dummy):
|
|||
def register():
|
||||
for cls in classes:
|
||||
bpy.utils.register_class(cls)
|
||||
bpy.types.Scene.font3d = bpy.props.PointerProperty(type=FONT3D_settings)
|
||||
bpy.types.Scene.font3d_data = bpy.props.PointerProperty(type=FONT3D_data)
|
||||
bpy.types.Scene.abc3d = bpy.props.PointerProperty(type=ABC3D_settings)
|
||||
bpy.types.Scene.abc3d_data = bpy.props.PointerProperty(type=ABC3D_data)
|
||||
# bpy.types.Object.__del__ = lambda self: print(f"Bye {self.name}")
|
||||
print(f"REGISTER {bl_info['name']}")
|
||||
|
||||
|
@ -1089,8 +1089,8 @@ def unregister():
|
|||
if on_frame_changed in bpy.app.handlers.frame_change_post:
|
||||
bpy.app.handlers.frame_change_post.remove(on_frame_changed)
|
||||
|
||||
del bpy.types.Scene.font3d
|
||||
del bpy.types.Scene.font3d_data
|
||||
del bpy.types.Scene.abc3d
|
||||
del bpy.types.Scene.abc3d_data
|
||||
print(f"UNREGISTER {bl_info['name']}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
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':
|
||||
|
|
|
@ -151,19 +151,19 @@ def get_glyph(font_name, face_name, glyph_id, alternate=0):
|
|||
"""
|
||||
# print(fonts)
|
||||
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())
|
||||
return None
|
||||
|
||||
face = fonts[font_name].faces.get(face_name)
|
||||
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())
|
||||
return None
|
||||
|
||||
glyphs_for_id = face.glyphs.get(glyph_id)
|
||||
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 fonts[font_name].faces[face_name].glyphs.get(glyph_id)[alternate]
|
||||
|
|
Loading…
Reference in a new issue