This glyph uses an installed font to set text, rather than displaying single glyphs from the UFO directly.

A test version of your font can be installed using the font.testInstall() function. (This line is commented-out because you don’t need to generate and install a font every time you run the script.)

The script generates spacing test strings for lowercase, uppercase, digits and punctuation characters. The list of characters in each group is imported from the string module – you could easily extend it with additional glyphs which are present in your font.

from string import *

f = CurrentFont()
fontName = '%s-%s' % (,

# install the font locally
# f.testInstall()

margin = 20
fontSize_ = 13
lineHeight_ = 1.1 * fontSize_

for group in [lowercase, uppercase, digits, punctuation]:

    txt = ''
    for char in list(group):
        # punctuation
        if group.startswith('!'):
            txt += '%s%s%s\n' % (char, char.join(list(lowercase)), char)
        # digits
        elif group.startswith('0'):
            txt += '%s%s%s\n' % (char, str(char).join(list(group)), char)
            txt += '%s%s%s\n' % (char, str(char*2).join(list(group)), char)
        # uppercase + lowercase
            txt += '%s%s%s\n' % (char, char.join(list(group)), char)

    # create new page

    # set font
    if fontName in installedFonts():
        print('font %s not installed' % fontName)

    # calculate pos/size
    x = y = margin
    w = width() - margin*2
    h = height() - margin*2

    # set text sample
    textBox(txt, (x, y, w, h))
Last edited on 23/01/2018