-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathreload_operator.py
48 lines (32 loc) · 1.14 KB
/
reload_operator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import bpy
from . import load_fonts as lf
from .addon_prefs import get_addon_preferences
class FONTSELECTOR_OT_reload_fonts(bpy.types.Operator):
"""Tooltip"""
bl_idname = "fontselector.reload_fonts"
bl_label = "Reload Fonts"
bl_options = {'INTERNAL'}
@classmethod
def poll(cls, context):
return True
def execute(self, context):
debug = get_addon_preferences().debug
# Prevent callback
font_props = context.window_manager.fontselector_properties
font_props.no_callback = True
# Reload families
datas, change = lf.refresh_font_families_json(debug, True)
lf.reload_font_families_collections(datas, debug)
# Relink
lf.relink_font_objects(debug)
# Reload favorites
lf.reload_favorites(debug)
# Restore callback
font_props.no_callback = False
self.report({'INFO'}, "Fonts reloaded")
return {'FINISHED'}
### REGISTER ---
def register():
bpy.utils.register_class(FONTSELECTOR_OT_reload_fonts)
def unregister():
bpy.utils.unregister_class(FONTSELECTOR_OT_reload_fonts)