The Python API and Libraries

Choose the API layer that matches the task. FontLab's high-level objects, its font engine, and external font-file libraries describe related data but are not interchangeable object systems.

The Python Packages and Bundled Libraries

fontlab exposes application-integrated font and workspace objects. It is the usual starting point for scripts that work with open fonts, glyphs, layers, elements, and the editor.

fontgate exposes lower-level font-engine data. Use it where the task requires those representations, and consult the API reference for object ownership and update requirements before changing data.

FL is the older compatibility API associated with FontLab Studio workflows. Recognize it in legacy scripts, but use the current APIs for new work unless maintaining that compatibility is the task.

PythonQt provides access to Qt-based interfaces and signals. PythonQt is not identical to PySide or PyQt; examples from those libraries may need adaptation.

The bundled fontTools copy is available under the private namespace. A script that deliberately prefers a separately installed version can use:

try:
    from fontTools import ttLib
except ImportError:
    from fontlab_private.fontTools import ttLib

That selects an import; it does not guarantee that both versions have identical APIs. Record which version a production script expects.

Other supporting libraries include AFDKO-related tools, ICU, HarfBuzz, FreeType, and Qt. This inventory does not identify one library as the exclusive current GSUB/GPOS compiler; the compilation workflow is described in Authoring OpenType Layout. Their role beneath the application does not mean every library is exposed through the same Python interface.

TypeRig and Installing Packages

TypeRig, developed by Vassil Kateliev, wraps the fontlab and fontgate APIs in a more Python-oriented interface, with reusable tools. For many scripting tasks it is a practical high-level starting point before working directly with lower-level objects. It is a third-party project, not an official FontLab product.

Its tools include the TypeRig panel for multi-master work, Delta Machine for suitable anisotropic derivation, and focused Filter, Kern, Manager, and Metrics utilities. Delta Machine needs an appropriate source model, such as a weight axis with at least two usable masters; it cannot derive a well-designed family from missing source relationships.

Use Script > Update / Install Scripts to reach extension resources, then follow the installed extension's instructions. Verify its FontLab/Python compatibility and refresh or restart as required. Tool names and menus can depend on the extension version.

Additional packages must be compatible with FontLab's bundled Python and architecture. The Python package search path under FontLab’s default data location includes the embedded version, for example python/3.11/site-packages for the bundled 3.11 build. Check the installed interpreter’s sys.path: relocating the customization folder need not relocate this default package search path. Do not substitute a conflicting Windows Python310/Python311 example. The folder hierarchy is covered in The User Data Folder and Customizable Data Files. Installing a package into an unrelated system Python does not ensure FontLab can import it.

When using a separate Python and pip to prepare packages, match the version and platform. Use pip’s --target option with the full user-data package path matching FontLab’s embedded Python version to choose that destination explicitly. After installation, test the package’s documented import in FontLab’s py> console; a successful import in the external interpreter alone does not verify the application’s environment. Compiled extensions have stronger compatibility requirements than plain Python files. Keep package requirements with the script rather than copying an undocumented collection of files between computers.

What Scripting Can Reach

The API can inspect and modify font/master libs, glyph geometry, metrics, anchors, kerning, and other source data. Use the appropriate object layer and preserve the editor's required update and undo behavior.

The documented surfaces include the font object’s autoKern method (for example f.fl.autoKern(...) through a TypeRig proxy), flPreferences for settings, flPackage.runActions() for Actions and Action Sets, and ExportControl for the export workflow in The Export Process. Consult their current signatures before writing a runnable call; an entry-point name alone does not supply its arguments or scope.

fontTools can inspect exported binaries independently of the live editor. This is useful for reports and production checks, but modifying a binary with fontTools does not automatically update the FontLab source that generated it.

For a reusable script, separate inspection, proposed changes, mutation, and reporting. That organization makes the code easier to review and helps a collaborator understand whether it operates on the active layer, selected glyphs, all masters, or saved files.