TypeRig

A Python framework for font design and engineering. Started as a personal toolkit for working inside FontLab, grew over the years into a standalone geometry and interpolation core with a bunch of GUI tools on top.

Objects for manipulating font outlines — points, nodes, contours, shapes, layers and glyphs — plus math helpers for interpolation, adaptive scaling and curve processing. Proxy layers wrap FontLab and Glyphs internals so the same code works both standalone and inside the host app. Experimental, evolving, and perpetually work-in-progress.

Python FontLab 8 Glyphs 3 AGPL-3.0

TypeRig is used every day in real font production, and it changes about as often. That has a cost: there are bugs, some tools fail on input they were not written for, and behaviour can change between commits. Work on copies of your fonts and save often.

Tested

The core has standalone tests (objects, actions, outline cleanup, CJK, element operations), run by CI on Python 3.11 under Linux, macOS and Windows.

Tested by hand only

The FontLab and Glyphs tools. Recent panels — Cleanup, Stem Snap, Magic Scale, the new Element panel — have seen little use inside FontLab so far.

Undo

Not every tool records its changes correctly for the host's Undo. A known case: Element → Flip leaves the element flipped after Undo.

Hosts

FontLab 8 is the main target. TypeRig also runs in FontLab 9, but has not been tested there systematically. The Glyphs side targets Glyphs 3 and 4.

Bug reports are welcome on GitHub Issues.

The biggest part of TypeRig in practice — a collection of GUI tools that cover most of what I need in a daily font production workflow. Built with PythonQt, hooked into FontLab's undo, multi-master aware.

TypeRig Paneltyperig-panel.py

A dockable panel that loads sub-panels as tabs. Layer selectors and glyph-scope controls in the masthead. Panel visibility persisted via JSON.

▶ Node
Insertion, removal, conversion, smart movement, alignment to metrics, slope and Hobby tension tools, coordinate banking, primitive drawing.
Smart node movement with multiple methods: plain shift, proportional (LERP), italic-angle slant, slope-following, and a smart mode that preserves handle relationships. Alignment to other nodes, font metrics (ascender, caps height, x-height, baseline, descender, measurement line), and user-defined targets with intercept and dimension-preserving modes. Hobby spline tension copy/paste. Coordinate banking for complex multi-step operations. Circle from 2 or 3 nodes, square from diagonal or midpoints.
▶ Contour
Close, open, reverse, boolean operations, alignment, group alignment, distribution, reordering.
Boolean operations: union, subtract, intersect, exclude. Alignment to other contours, to font metrics, and bounding-box-relative positioning. Group alignment (A-to-B). Horizontal and vertical distribution of multiple contours. Reordering by position.
▶ Corner
Smart corner filters with multi-master presets. Mitre, round, loop, and ink-trap operations.
Apply, remove, and find-and-remove smart corners by preset value. Live slider control for captured smart angles. Dialog-based parameter entry for mitre, round, loop, and ink-trap corners. Corner rebuild for re-processing existing corners.
▶ Layer
Full layer management, cross-layer operations, element-level swap/pull/push, zero-setup interpolation.
Add, duplicate, delete, duplicate-as-mask. Copy and paste whole layer groups. Visibility toggle and type assignment (mask, wireframe, service). Element-level operations: swap, pull, push, clean, lock/unlock. Contour-level cross-layer operations: pull/push nodes, copy/paste outlines, paste by layer name. Side-by-side comparison view. Zero setup interpolation between selected layers.
▶ Delta
Adaptive scaling (delta machine) with stem values per master, target layer generation, Tim Ahrens methodology.
Virtual axis setup with stem values per master layer. Target layer generation with configurable horizontal/vertical stems, width, and height. Supports extrapolation, intensity control, italic-angle compensation, and multiple transform origins. Axis configurations saved/loaded from Font Lib or external JSON files.
▶ Element
Element management, rewritten in autumn 2026: merge, separate, group, arrange, align, transform, style.
Merge selected contours into a new, the top or the bottom element; separate by ejecting contours, by islands or one element per contour; group, ungroup, group from selection. Stacking order: forward, backward, reverse, to front, to back, and auto arrange by position, reading order or size, optionally to match the other masters. Align and distribute to the touched elements, a key element, the layer or font metrics; flip; transform with a chosen origin. Copy, paste and match fill, stroke, opacity and style; brush weight. Rename, duplicate, link/unlink, apply/reset/round element transforms, clean empty elements. The older naming and composition tools moved to ElementComposer.
▶ Cleanup
Outline cleanup: remove redundant nodes and debris, refit curves within a tolerance.
Analyze reports node counts and deviation without touching the outlines. Fix Degeneracies drops the debris; Clean & Simplify also refits curves within a tolerance; Show Locks selects the nodes that would be kept. Layers can be cleaned in sync or one by one; output stays cubic, converts to quadratic, or keeps what it had. Groups, components and shared elements are skipped. Ported from the Glyphs side; lightly tested in FontLab.
▶ StemSnap
Snap stems or strokes that are close to a standard stem onto it; leave the rest alone.
Node-level H/V stems, with corrections cascading over the stem's contour family, or whole-contour strokes measured on the medial axis at any angle. Targets from each master's PostScript stems or a typed list; tolerance in units or percent. Show on canvas marks the stems that would be snapped before anything changes. Single glyph at a time for now. Ported from the Glyphs side; lightly tested in FontLab.
▶ MagicScale
Stem-preserving 1D warp per axis: stems keep their thickness, the whitespace absorbs the change.
The change is redistributed by counter (中宫) and gravity (重心). Live editing writes into the glyph's own nodes, like the Delta panel, with Reset and Apply.
▶ Clipboard
Multi-master contour clipboard with core-object storage. Configurable paste transform and delta machine fit.
Copy full contours or partial selections. Paste with configurable transform (translate, scale, rotate, skew), delta machine size fit and transform origin. Reversed and partial paste modes, drawing and connecting multiple segments. Save/load clipboard to XML for cross-session and cross-font workflows.
▶ Metrics
Sidebearing and advance width tools with metric expressions and cross-glyph copying.
Copy metrics from other glyphs by name with percentage and unit adjustments. Metric expressions: get, set, auto-link from element references, unlink. Copy bounding-box dimensions between glyphs with proportional adjustments.
▶ Anchor
Anchor management with flexible coordinate input, font-metric and expression-based placement, italic-angle awareness.
Tree-view display per layer. Add, move, and clear with absolute positions, font-metric-relative placement, bounding-box-relative, and expression-based coordinates. Per-layer coordinate lists for multi-master workflows.
▶ Guide
Guideline creation at percentage-based positions. Named/tagged guidelines with color assignment.
Vertical and horizontal placement relative to advance width, bounding box, or font metrics. Source glyph reference for cross-glyph alignment. Glyph tagging and node naming tools.
▶ Glyph · Outline · Pairs · Stats
Glyph rename/copy/duplicate, interactive node table, kern string generation, glyph statistics.
Glyph: rename, copy/duplicate with configurable options, batch duplication with auto-numbering and transforms. Outline: interactive sortable node table with direct coordinate editing and live viewport sync. Pairs: filler-based kern pair construction, DTL .krn/.cla/.afm import. Stats: bounding box dimensions, advance widths, sidebearings across layers.
▶ AutoMetrics · CopyKerning · CleanKerning
Automated metric assignment, kern pair copying with class-aware support, kerning table cleanup.
AutoMetrics: automated metric assignment tools. CopyKerning: kern pair copying between glyphs and layers, source pair lookup with expression adjustment, group kerning with automatic class resolution. CleanKerning: kerning table cleanup utilities.
▶ ElementComposer · Symbol Explorer · Delta New
Named-element insertion and composition, plus two experimental panels that are off by default.
ElementComposer: insert, replace and swap named elements across glyphs, with the expression-based composition syntax. Symbol Explorer (experimental): search a symbol set by tag and category with previews. Delta New (experimental): the canvas-driven rewrite of the Delta panel.

Which tabs load is set in Panel/typerig-panel-config.json. The shipped default enables Node, Contour, Clipboard, Layer, Element, Delta, Cleanup, StemSnap and MagicScale.

TypeRig Managertyperig-manager.py
▶ FontMetrics
Multi-master font metrics editor with table-based interface. Font zone management with JSON import/export.
Table-based interface for all vertical metrics across all master layers. Add, remove, import/export zones as JSON. Zone creation from metric references.
▶ Kerning · KernGroups · Impex
Font-wide kerning table, kern class editor, batch import/export actions.
Kerning: browse, filter and edit pairs across masters in a table. KernGroups: build, rename and merge classes, set key glyphs, import/export class sets as JSON. Impex: a table of import/export actions run in batch over the font; currently ships AFM kerning.
Toolbars
▶ TypeRig Toolbar
One native, dockable FontLab panel (macOS and Windows, FontLab 8 and 9) for node operations, alignment, curves, contours, booleans, cut, end caps, collinear / monoline and slope tools.
Nodes and corners, align (options, edges, centers, outline, neighbours, font metrics, per-master targets), curves (line/curve conversion, Tunni, Hobby, handle proportions, Hobby copy and paste), contours (close, winding, start node, order), booleans, end caps, collinear and monoline, slope copy and paste. Scope masthead: layers Active / Masters / Selected and glyph active / window / font selection. Drags and docks on every edge and reflows to rows or columns.
Standalone Tools
▶ Delta Preview TR-DeltaPreview.py
Visual preview of delta machine results without writing to the font. Dual-pane with live zoom/padding.
Source masters and computed targets rendered as QPainterPath objects from core geometry. Execute-to-font mode for committing approved results as real layers.
▶ Comparator TR-Comparator.py
Cross-font and cross-layer glyph comparison. Outline differences, missing layers, anchor mismatches.
Detect shifted-but-identical layers, color-coded difference display. Time-stamp-aware comparison for change tracking. Batch processing with progress bar and font mark colorization.
▶ Match Contours TR-MatchContours.py
Visual contour matching across masters. Drag-and-drop reordering, start-point alignment, winding display.
Contour order tab with drag-and-drop reordering and winding direction display (color-coded CW/CCW). Start-point tab for aligning start nodes across masters with corner-based and sequential adjustment. Visual icon rendering per contour per master.
▶ Encoder TR-EncodeGlyphs.py
Unicode encoding management. Load from JSON, FontLab .nam, Google .textproto files.
Apply or clear unicode mappings for entire fonts or selected glyphs. Save/load encoding data to Font Lib.
▶ Sort Anchors TR-SortAnchors.py
Anchor ordering across all masters. Reference-master or alphabetical mode with verbose missing-anchor reports.
Reference-master mode preserves anchor order from a chosen master. Alphabetical mode sorts uniformly. Verbose mode reports missing anchors across masters.
▶ Propagate Anchors TR-PropagateAnchors.py
Table-driven batch anchor copying between glyphs with per-action configuration. Save/load as JSON.
Source glyph, anchor selection, destination glyphs, layer scope, copy options (absolute/relative with LSB/RSB/advance-relative modes, collision handling with overwrite or rename, suffix control). Repeatable JSON workflows.
▶ Export Glyph TR-ExportGlyph.py
Export individual glyphs as .trglyph XML files via the core serialization system and proxy-to-core eject.
Round-trip export using the eject mechanism to produce pure core objects serialized to XML.
▶ Import Glyph · Font IO TR-ImportGlyph.py · TR-ExportFont.py
Read .trglyph files back into glyphs; write and read whole fonts as .trfont.
Import Glyph reads a .trglyph file back into a glyph, layer by layer. Font IO is a whole-font .trfont write/read round-trip from FontLab over the folder-level serialization in core.fileio.trfont.
▶ Copy Layers · Copy Anchors · Rename Anchors
Copy selected layers or anchors between two open fonts; batch anchor renaming across masters.
TR-CopyLayers.py, TR-CopyAnchors.py and TR-RenameAnchors.py.
▶ trconvert trconvert.py
Not a FontLab tool: a command-line converter between .trfont and UFO 3.
ufo2tr, tr2ufo and roundtrip. Needs fontTools. roundtrip runs both directions on a temporary copy and reports PASS/FAIL with a structural diff.

A host-independent core, connected to the font editors by proxy layers.

Coretyperig.core

Pure Python, runs anywhere — CPython, Pyodide in a browser, whatever. Geometry, interpolation and algorithms need no third-party packages; fontTools is used for UFO, designspace and compiled-font I/O.

core.objects Point, Line, CubicBezier, QuadraticBezier — basic geometry with operator overloading and complex-number math. Node with navigation, corner ops, Hobby splines, per-node stem weights. Contour with winding, segment iteration, analytical offset, SDF-clamped offset, compensated scaling. Shape, Layer (interpolation, adaptive scaling, virtual axes), Glyph, Anchor. Transform, SDF, HobbySpline, PointArray, DeltaArray, DeltaScale.
core.func math — lerp, SLERP, rational fractions, directional interpolation, Hobby velocity, matrix solvers. transform — delta machine, adaptive scaling (extending Tim Ahrens), directional adaptive scaling, stem compensation, italic-angle correction, per-contour angle adjustment. geometry — CCW, collinearity, intersection, squircle corners. utils — type-checking helpers.
core.fileio xmlio and trfont — the experimental .trfont format. ufo and designspace — .trfont ↔ UFO 3 and .designspace. afm, krn, cla, flc, otkern, kerndoc — kerning and class interchange, including kerning read from compiled fonts. svgio, nam, textproto — SVG import and encoding files.
core.algo Pure algorithms on core objects, testable outside any editor: outline cleanup, stem and stroke snapping, medial axis and stroke separation, magic scale, matchmaker (point-compatible matching), design transfer between masters, TR Kern analysis and cleanup, CJK measurement, element operations, curve intersection.
core.actions Host-independent tool logic shared by panels, command line and tests: node, contour, curve, layer, cut, clipboard and delta actions, and the TR Kern engine with its tr-kern command line for UFO, designspace and .trfont files.
Proxy — FontLabtyperig.proxy.fl

Needs FontLab (fontlab, fontgate, PythonQt). Proxy objects, GUI bits, and action collectors.

proxy.fl.objects pFont/pFontMetrics, pGlyph/eGlyph, pShape/eShape, pContour, pNode/eNode/eNodesContainer, eCurveEx — full layer, shape, contour, node, anchor, guideline, component, metric access. eGlyph extends with tool-preparation and multi-master-aware operations.
proxy.fl.actions Action collectors separating tool logic from GUI: node, curve, contour, draw, layer, element and cut (stroke separation across masters).
proxy.fl.gui Widgets (buttons, flow layout, tab widgets, table views, sliders, transform controls, delta layer tree, icon font loader), dialogs (layer chooser with search/filter, quick input), stylesheets with auto dark/light detection, canvas drawing utilities, and a reusable base for tools that draw on and take mouse input from the glyph canvas.
proxy.fl.application pWorkspace (canvas access, text block queries, active kern pair, frame creation), pItems (undo notification helpers).
proxy.fl.devtools For testing TypeRig inside a running FontLab, by hand or by a coding agent: press panel controls, click and drag on the canvas, take screenshots, snapshot and diff glyph data, read the History panel, reload TypeRig code without a restart. Not imported by anything else.
Proxy — Core Bridgetyperig.proxy.tr

Each proxy — trNode, trContour, trShape, trLayer, trGlyph, trFont, trAnchor — inherits from its core counterpart and keeps a .host reference to the FL object. Attribute access goes through a __meta__ mapping so the same core algorithms work on live FL data without extra glue.

Eject / Mount

.eject() detaches a pure core copy. .mount() writes values back into the host. Keeps FL undo intact.

Host Sync

Structural changes trigger proxy rebuild of the FL contour with _sync_host() up the parent chain.

Attribute Routing

Reads/writes to mapped names go straight to the host. Everything else follows the normal core path.

Proxy — Glyphs 3typerig.proxy.gs3

A second host proxy, for Glyphs 3 and 4: objects wrapping Glyphs' own classes so the core algorithms run unchanged, and a small panel toolkit over vanilla with the same glyph/layer scope controls as the FontLab panel. Cleanup, Stem Snap and TR Kern were written once in the core and shelled for both hosts. Install with install.glyphs.py.

The core package also runs in the browser via Pyodide. The browser work moved to FontRig in March 2026; this repository keeps only the core it imports. Still rough around the edges.

FontRig: Editor → Glyph viewer with a Python editor in the browser. Experimental.

How it works

Pyodide loads CPython as WebAssembly, fetches core modules from GitHub, stubs the FL parts. It works, mostly.

# Install the library from PyPI (Python 3.10+) python -m pip install typerig # Or clone the repository; the FontLab and Glyphs tools come with their installers git clone https://github.com/kateliev/TypeRig.git # Core objects — pure Python from typerig.core.objects import Node, Contour, Shape, Layer, Glyph # Transform functions from typerig.core.func.transform import adaptive_scale, lerp # FontLab proxy (inside FontLab only) from typerig.proxy.fl.objects.glyph import eGlyph