twardoch-fontlab-scripts

Python scripts for FontLab 7 by Adam Twardoch

View the Project on GitHub twardoch/twardoch-fontlab-scripts

twardoch-fontlab-scripts

Useful Python scripts for FontLab 7 by Adam Twardoch.

These scripts are designed to streamline your font design workflow, automate common tasks, and extend the capabilities of FontLab 7. They are provided under a permissive license, allowing for wide use and modification.

License: Licensed at your choice under:

Part 1: General Information

This section is for all users, including those who may not be deeply technical. It covers what the scripts do, who they’re for, why they’re useful, and how to install and use them.

What are these scripts?

This repository contains a collection of Python scripts that add new functionalities to FontLab 7. Each script addresses a specific task in the font production process, such as batch exporting fonts, managing Unicode assignments, selecting glyphs based on criteria, or manipulating text in the Glyph window.

Who are these scripts for?

These scripts are primarily for:

Why are they useful?

Installation

Follow these steps to install the scripts and their dependencies:

  1. Download the Scripts:
    • Download ZIP
    • Unzip the downloaded file. You will find a Scripts subfolder inside the unzipped folder – this contains the scripts you’ll install.
  2. Install TypeRig (Dependency):
    • Some scripts (like “Select Glyphs by Anchor”) require the TypeRig extension library.
    • In FontLab 7, choose Scripts > Update / Install Scripts. This will open a dialog.
    • Find TypeRig in the list, select it, and click Install.
    • Restart FontLab 7 after the installation completes.
  3. Locate Your FontLab 7 User Data Folder:
    • In FontLab 7, go to the FontLab 7 menu (on macOS) or Edit menu (on Windows).
    • Choose Preferences > General.
    • Click the Open user data folder button. This will open a Finder (macOS) or File Explorer (Windows) window showing your FontLab 7 user data folder. (More on user data folder locations).
  4. Copy Scripts:
    • If a Scripts folder does not already exist inside your FontLab 7 user data folder, create one.
    • Copy the contents of the Scripts subfolder (from the unzipped download in Step 1) into the Scripts folder in your user data folder. This means you’ll copy the TW Anchors, TW Export Fonts, etc., folders into your user data Scripts folder.
  5. Refresh Scripts in FontLab:
    • If FontLab 7 is running, choose Scripts > Refresh Scripts. If it’s not running, start FontLab 7.
    • The scripts should now appear in the Scripts menu, organized into submenus like “TW Text”, “TW Export Fonts”, etc.

Note: These scripts are not an official Fontlab Ltd. product. No technical support or warranty is provided, but pull requests are welcome!

How to Use the Scripts

General Usage (FontLab UI)

Once installed, most scripts are run from the FontLab 7 Scripts menu. Typically, you’ll:

  1. Open a font file in FontLab 7.
  2. Navigate to the Scripts menu.
  3. Find the desired script within its submenu (e.g., Scripts > TW Text > Reverse Text).
  4. Click the script name to run it. Some scripts will present a dialog window for further options or inputs.

Specific instructions for each script are provided below.

Programmatic Usage

These are Python scripts designed to be run within the FontLab 7 environment, which provides the necessary Python interpreter and FontLab-specific APIs.

Script Descriptions and Usage

TW Text > Reverse Text

TW Export Fonts > Export Fonts in Folder

TW Glyph Names and Unicode > Generate Unicodes by NAM

TW Anchors > Select Glyphs by Anchor

Other Tips

Change the FontLab UI font

To change the UI font of FontLab to a lighter variant on macOS:

from PythonQt import QtGui
qapp = QtGui.QApplication.instance()
appfont = qapp.font()
appfont.setFamily("SF Pro")
appfont.setWeight(QtGui.QFont.Light)
qapp.setFont(appfont)

Part 2: Technical Details

This section is for users interested in the underlying code, how the scripts work, or contributing to their development.

Code Overview

Script-Specific Technical Notes

Coding Conventions

While not strictly enforced, the scripts generally follow common Python conventions:

Contributing

Pull requests are welcome! If you’d like to contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes.
    • Try to follow the existing coding style and conventions.
    • If adding a new script, place it in an appropriately named subfolder within the main Scripts directory (e.g., Scripts/TW New Feature/My_New_Script.py).
    • Ensure your script has the standard license and author header.
    • If your script has external dependencies beyond standard Python and FontLab (like TypeRig), document them.
  4. Test your changes thoroughly by running the script within FontLab 7.
    • Consider different scenarios and edge cases.
    • If your script creates UI, check its usability.
  5. Update README.md if you’re adding a new script or significantly changing an existing one. This includes:
    • Adding a description to “Part 1: General Information > Script Descriptions and Usage”.
    • Adding relevant technical notes to “Part 2: Technical Details > Script-Specific Technical Notes” if applicable.
    • Including a screenshot or GIF if it helps illustrate the script’s functionality.
  6. Commit your changes with clear and descriptive commit messages.
  7. Push your branch and submit a pull request.

Dependencies Summary