<div>from FL import Feature, fl
# loop through open fonts
for ifont in range(len(fl)):
font = fl[ifont]
# generate 'kern' feature value
kern_feature_value = font.MakeKernFeature().value
# create 'kern' FontLab feature
kern_feature = Feature('kern', kern_feature_value)
# check for 'kern' feature index in current font if it already exists
kern_feature_i = None
for i, feature in enumerate(font.features):
if feature.tag == 'kern':
kern_feature_i = i
break
# delete current 'kern' feature if it exists
if kern_feature_i:
del font.features[kern_feature_i]
# add 'kern' feature to font features
font.features.append(kern_feature)
fl.UpdateFont(ifont)<br></div>
If you are updating, saving and closing vfb files you can use this call command but you will need to click OK in the dialog for each font.
for i in range(len(fl)-1,-1,-1):<br> fl.CallCommand(33934)<br> fl.Save(fl.font.file_name)<br> fl.Close(fl.ifont)<br><br>
Else you can do this which is similar to Jameson's above but works backwards through the list of opened fonts as each is saved and closed.
<div>for ifont in range(len(fl)-1,-1,-1):<br> f = fl[ifont]<br> print f.full_name + "\n"<br><br> for i in range(len(f.features)-1,-1,-1):<br> if f.features[i].tag == 'kern':<br> del f.features[i]<br><br> f.features.append(Feature('kern', f.MakeKernFeature().value))<br><br> fl.UpdateFont(ifont)<br> <br> fl.Save(f.file_name)<br> <br> fl.Close(ifont)<br><br></div><br>
Comments