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

Class ST2FontVariationsPanel

ST2/font.py:76–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75
76class ST2FontVariationsPanel(bpy.types.Panel):
77 bl_label = "Font Variations"
78 bl_idname = "ST2_PT_31_FONTVARSPANEL"
79 bl_space_type = "VIEW_3D"
80 bl_region_type = "UI"
81 bl_category = "ST2"
82 bl_options = {'DEFAULT_CLOSED'}
83
84 @classmethod
85 def poll(cls, context):
86 ko = search.active_key_object(context)
87 if ko:
88 font = ko.st2.font()
89 if ko.st2.visible_variation_axes(font):
90 return True
91 return False
92
93 def draw(self, context):
94 ko = search.active_key_object(context)
95
96 layout = self.layout
97 data = ko.st2
98 font = data.font()
99 fvars = ko.st2.visible_variation_axes(font)
100
101 for idx, (k, v) in enumerate(fvars.items()):
102 prop = f"fvar_axis{idx+1}"
103
104 norm_v = getattr(data, prop)
105 diff = abs(v["maxValue"]-v["minValue"])
106 unnorm_v = v["minValue"] + (diff * norm_v)
107
108 row = layout.row()
109 split = row.split(factor=0.85)
110 col = split.column()
111 col.prop(data, prop, text=k)
112 #col = row.column()
113 #col.alignment = "RIGHT"
114 #col.width = 50
115 col = split.column()
116 col.alignment = "RIGHT"
117 col.label(text="{:d}".format(round(unnorm_v)))
118
119 if k == "wdth":
120 row = layout.row()
121 row.label(text="Fit Width")
122 row.prop(data, "fit", text="")
123 row.prop(data, "fit_enable", text="Enable")
124
125 if ko.st2.has_keyframes(ko) or True:
126 layout.row().label(text="Variation Offsets")
127
128 for idx, (k, v) in enumerate(fvars.items()):
129 layout.row().prop(data, f"fvar_axis{idx+1}_offset", text=f"{k} offset")
130
131 row = layout.row()
132 row.operator("st2.load_var_axes_defaults", icon="EMPTY_AXIS", text="Set to Defaults")
133

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected