Set fixed width in all glyphs

# define width value
value = 400

# get current font
font = CurrentFont()

# iterate over all glyphs in font
for glyph in font:
    # set glyph width to value
    glyph.width = value

Set infos in all open fonts

This example shows how to set font infos from a dictionary into all open fonts.

# a dictionary with font infos
infoDict = {
    # attribute name (key) : data (value)
    'openTypeNameDesigner' : 'Claude Garamond',
    'year' : 1532,
    'copyright' : 'Copyright (c) 1532 Claude Garamond.',
    'note' : 'bonjour le monde',

# for each open font
for font in AllFonts():
    # iterate over all font info attributes in dict
    for key in infoDict.keys():
        # set data in font info attribute
        setattr(, key, infoDict[key])
# done!

Copy font infos from one font to another

This example shows how to copy font info data from one open font to another.

# get the source font by name
f1 = AllFonts().getFontsByStyleName('Regular')[0]

# get the destination font by name
f2 = AllFonts().getFontsByStyleName('Bold')[0]

# a list of attributes to copy
attributes = [

# copy data from f1 to f2
for attr in attributes:
    # get value from source font
    value = getattr(, attr)
    # set value in destination font
    setattr(, attr, value)

Generate fonts for all UFOs in folder

This script will first open a dialog for selecting a folder; it will then open each UFO file in the folder, without the UI, and generate an OpenType-CFF font for it.

import os
from vanilla.dialogs import getFolder

# select folder
folder = getFolder('Select a folder with UFOs')[0]

# make a subfolder for otfs
otfsFolder = os.path.join(folder, 'otfs')

# iterate over all files in folder
for f in os.listdir(folder):

    # if file has .ufo extension
    if os.path.splitext(f)[-1] == '.ufo':

        # get full ufo path
        ufoPath = os.path.join(folder, f)

        # open ufo (without UI)
        font = OpenFont(ufoPath, showUI=False) # RF 1.8
        # font = OpenFont(ufoPath, showInterface=False) # RF 3.0

        # make otf path
        otfPath = os.path.join(folder, f.replace('.ufo', '.otf'))

        # generate otf font
        font.generate(path=otfPath, format='otf', decompose=True, checkOutlines=True)

        # close the ufo

Import a font into layer of current font

This script shows how to import all glyphs of a font into a layer of the current font. Notice how the source font is never opened in the UI: it is just loaded in memory. Note also how the glyphs are copied from one font to the other with a point pen.

# open a font without UI
srcFont = OpenFont(showInterface=False)

# get the current font
f = CurrentFont()

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

# loop over all glyphs in the source font
for g in srcFont:
    # if the glyph doesn't exist in the current font, create a new glyph
    if not in f:
    # get the layered glyph
    layerGlyph = f[].getLayer(layerName)

    # get the point pen of the layer glyph
    pen = layerGlyph.getPointPen()
    # draw the points of the imported glyph into the layered glyph

# we are done :)
Last edited on 15/02/2018