Fontlab 5: How to 'Update [kern] feature' in all open fonts?
Ramiro Espinoza
Posts: 839
Hi there,
Does anyone know a Python command to 'Update [kern] feature' in all open fonts?
Thanks in advance.
0
Comments
-
<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>
This should work.2 -
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>
1 -
Thanks!
0
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 799 Font Technology
- 1K Technique and Theory
- 617 Type Business
- 444 Type Design Critiques
- 541 Type Design Software
- 30 Punchcutting
- 136 Lettering and Calligraphy
- 83 Technique and Theory
- 53 Lettering Critiques
- 483 Typography
- 301 History of Typography
- 114 Education
- 68 Resources
- 498 Announcements
- 79 Events
- 105 Job Postings
- 148 Type Releases
- 165 Miscellaneous News
- 269 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports