load specific font in memory

This commit is contained in:
jrkb 2024-08-28 17:25:06 +02:00
parent 40e97aaf9e
commit cd1af39985
2 changed files with 26 additions and 3 deletions

View file

@ -347,6 +347,10 @@ class ABC3D_PT_FontList(bpy.types.Panel):
scale_y = 0.5
row = subbox.row(); row.scale_y = scale_y
row.label(text=text)
row = layout.row()
oper = row.operator(f"{__name__}.load_font", text='Load all glyphs in memory')
oper.font_name = font_name
oper.face_name = face_name
class ABC3D_PT_TextPlacement(bpy.types.Panel):
@ -710,6 +714,21 @@ class ABC3D_OT_LoadInstalledFonts(bpy.types.Operator):
return {'FINISHED'}
class ABC3D_OT_LoadFont(bpy.types.Operator):
"""Load all glyphs from a specific font in memory.\nThis can take a while and slow down Blender."""
bl_idname = f"{__name__}.load_font"
bl_label = "Loading Font."
bl_options = {'REGISTER', 'UNDO'}
font_name: bpy.props.StringProperty()
face_name: bpy.props.StringProperty()
def execute(self, context):
filepaths = Font.fonts[self.font_name].faces[self.face_name].filepaths
for f in filepaths:
butils.load_font_from_filepath(f)
return {'FINISHED'}
class ABC3D_OT_AddDefaultMetrics(bpy.types.Operator):
"""Add default metrics to selected objects"""
bl_idname = f"{__name__}.add_default_metrics"
@ -1353,6 +1372,7 @@ classes = (
ABC3D_PT_FontCreation,
ABC3D_PT_TextPropertiesPanel,
ABC3D_OT_LoadInstalledFonts,
ABC3D_OT_LoadFont,
ABC3D_OT_AddDefaultMetrics,
ABC3D_OT_RemoveMetrics,
ABC3D_OT_AlignMetricsToActiveObject,