| 84 | |
| 85 | |
| 86 | def 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 | |
| 106 | class ST2_OT_LoadNextFont(bpy.types.Operator): |