MCPcopy Create free account
hub / github.com/coldtype/st2 / cycle_font

Function cycle_font

ST2/operations.py:86–103  ·  view source on GitHub ↗
(context, inc)

Source from the content-addressed store, hash-verified

84
85
86def cycle_font(context, inc):
87 data, obj = search.find_st2(context)
88 font_path = Path(data.font_path)
89 fonts = []
90 for file in sorted(font_path.parent.iterdir(), key=lambda x: x.name):
91 if file.suffix in [".otf", ".ttf", ".ufo"]:
92 fonts.append(file)
93
94 fidx = fonts.index(font_path)
95 try:
96 adj_font = fonts[fidx+inc]
97 except IndexError:
98 if inc > 0:
99 adj_font = fonts[0]
100 else:
101 adj_font = fonts[len(fonts)-1]
102
103 data.font_path = str(adj_font)
104
105
106class ST2_OT_LoadNextFont(bpy.types.Operator):

Callers 2

executeMethod · 0.85
executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected