# settings interpolationSteps = 5 extrapolateSteps = 2 # get the currentFont f = CurrentFont() if f is None: # no font open print("Oeps! There is not font open.") else: # get the selection selection = f.selectedGlyphNames # check if the selection contains only two glyphs if len(selection) != 2: print("Incompatible selection: two compatible glyphs are required.") else: # get the master glyphs source1 = f[selection[0]] source2 = f[selection[1]] # check if they are compatible if not source1.isCompatible(source2)[0]: # the glyphs are not compatible print("Incompatible masters: Glyph %s and %s are not compatible." % (source1.name, source2.name)) else: # loop over the amount of required interpolations nameSteps = 0 for i in range(-extrapolateSteps, interpolationSteps + extrapolateSteps + 1, 1): # create a new name name = "interpolation.%03i" % nameSteps nameSteps += 1 # create the glyph if does not exist dest = f.newGlyph(name) # get the interpolation factor (a value between 0.0 and 1.0) factor = i / float(interpolationSteps) # interpolate between the two masters with the factor dest.interpolate(factor, source1, source2) # done! f.changed()