@@ -179,6 +179,7 @@ class DesignAxisModel(SliceBaseTableModel):
179
179
def __init__ (self , * args ):
180
180
SliceBaseTableModel .__init__ (self , * args )
181
181
self .fvar_axes = {}
182
+ self .fvar_name_map = {}
182
183
self .ordered_axis_tags = []
183
184
self ._data = [
184
185
["" , "" ],
@@ -214,8 +215,10 @@ def headerData(self, section, orientation, role):
214
215
if role == Qt .ToolTipRole :
215
216
if orientation == Qt .Vertical :
216
217
axis_name = self .get_axis_name_string (self ._v_header [section ])
217
- # if this is a defined registered axis value, create a tooltip
218
- # with the full axis name
218
+ # if we receive a axis name string value, create a tooltip
219
+ # with the full axis name. The method returns None if the
220
+ # axis name is not available. Skip tooltip gen if that is
221
+ # the case
219
222
if axis_name :
220
223
return axis_name
221
224
@@ -242,7 +245,9 @@ def load_font(self, font_model):
242
245
# clear the axis tag list attribute
243
246
self .ordered_axis_tags = []
244
247
for axis in fvar .axes :
248
+ # maintain order of axes in the font
245
249
self .ordered_axis_tags .append (axis .axisTag )
250
+ # create a map of the min, default, max axis values
246
251
self .fvar_axes [axis .axisTag ] = [
247
252
axis .minValue ,
248
253
axis .defaultValue ,
@@ -251,6 +256,11 @@ def load_font(self, font_model):
251
256
new_data .append (
252
257
[f"({ axis .minValue } , { axis .maxValue } ) [{ axis .defaultValue } ]" , "" ]
253
258
)
259
+ # use the axisID to locate the axis name in the name table
260
+ # if it does not exist, the getName method returns None
261
+ self .fvar_name_map [axis .axisTag ] = (
262
+ ttfont ["name" ].getName (axis .axisNameID , 3 , 1 , 1033 ).toUnicode ()
263
+ )
254
264
255
265
# set header with ordered axis tags
256
266
self ._v_header = self .ordered_axis_tags
@@ -319,7 +329,10 @@ def get_axis_name_string(self, needle):
319
329
elif needle in unregistered_axes :
320
330
return unregistered_axes [needle ]
321
331
else :
322
- return None
332
+ if needle in self .fvar_name_map :
333
+ return self .fvar_name_map [needle ]
334
+ else :
335
+ return None
323
336
324
337
325
338
class FontBitFlagModel (object ):
0 commit comments