Fontlab 5: How to 'Update [kern] feature' in all open fonts?

Hi there,

Does anyone know a Python command to 'Update [kern] feature' in all open fonts?

Thanks in advance.

Comments

  • 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)
    This should work.
  • 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):
    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.
    for ifont in range(len(fl)-1,-1,-1):

  • Thanks!
Sign In or Register to comment.