The easiest and most efficient way to check (and fix) interpolation compatibility between fonts is using the Prepolator extension.

This page shows how to check interpolation compatiblity with code.

Checking glyph compatibility

The RGlyph object has a isCompatible method which checks for interpolation compatibility with another glyph. It returns a boolean (indicating if the glyphs are or not compatible) and a string (a report about the glyphs).

f1 = AllFonts().getFontsByStyleName('LightCondensed')[0]
f2 = AllFonts().getFontsByStyleName('LightWide')[0]
print(f1['a'].isCompatible(f2['c']))
>> (False, ["Fatal error: glyph a and glyph c don't have the same number of contours."])
print(f1['a'].isCompatible(f2['d']))
>> (False, ["Fatal error: contour 1 in glyph a and glyph d don't have the same number of segments."])
print(f1['a'].isCompatible(f2['a']))
>> (True, [''])

Marking glyphs by compatibility

The following script checks for glyph compatibility between all open fonts and a neutral font, and applies a mark color based on the result (green for compatible, red for not compatible).

from mojo.UI import SelectFont

neutral = SelectFont()

for f in AllFonts():

    if f == neutral:
        continue

    for g in f:
        compatible, report = g.isCompatible(neutral[g.name])

        if compatible:
            f[g.name].markColor = 0, 1, 0, 0.5
        else:
            f[g.name].markColor = 1, 0, 0, 0.5

    f.changed()

Setting starting points automatically

g = CurrentGlyph()

for c in g.contours:
    c.autoStartSegment()
Last edited on 01/09/2021