ChewpackChewpack

Guide · About 5 minutes

Your first script

Run three lines of Python that respace a selection, then undo them.

  1. Step 1: Open the Scripting window

    Choose Scripts › Scripting window.

    CtrlShiftP
  2. Step 2: Select some glyphs

    In the glyph grid, select a few glyphs whose spacing you want to set.

  3. Step 3: Write the script

    Replace the text in the editor with this.

    python
    for glyph in CurrentFont().selectedGlyphs:
        glyph.leftMargin = 40
        glyph.rightMargin = 40
  4. Step 4: Run it

    Press Ctrl+Enter. The selected glyphs now have 40 units on each side.

    CtrlEnter
  5. Step 5: Undo it

    Press Ctrl+Z in the main window: the whole run undoes in one step.

    CtrlZ
Scripting in ChewPackThe complete guide to Python scripting: first script, recipes, full API reference, limits and safety.