Font examples

Make monospaced font

# convert to monospace font
from robofab.interface.all.dialogs import AskString

value = AskString("Monospace width:")

    value = int(value)
except ValueError:
    value = None

if value:
    font = CurrentFont()
    for glyph in font:
        glyph.width = value

Open font in layer

Import a font into a layer of the CurrentFont

## open a font without UI
f = OpenFont(showUI=False)

## get the current font
cf = CurrentFont()

## create a layer name based on the familyName and styleName of the opend font
layerName = "%s_%s" %(,

## loop over all glyphs in the font
for g in f:
    ## if the glyph doenst exist in the current font, create a new glyph
    if not in cf:
    ## get the layered glyph
    layerGLyph = cf[].getLayer(layerName)
    ## get the point pen of the layered glyph
    pen = layerGLyph.getPointPen()
    ## draw the points of the imported glyph into the layerd glyph

## we are done :)
print "done"

Clean glyph names with quotes in groups

FontLab uses the single quote character ' to indicate key glyphs in spacing groups. In RoboFont/UFO the concept of key glyphs does not exist. The script below cleans names of key glyphs in groups created with FontLab.

for f in AllFonts():
    hasEdits = False
    for name, members in f.groups.items():
        groupHasEdits = False
        new = []
        for m in members:
            if m[-1] == "'":
                groupHasEdits = True
                hasEdits = True
    if hasEdits:
        print "edits made in ",
        print "no edits made",