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. A proxy layer wraps FontLab internals so the same code works both standalone and inside the host app. Experimental, evolving, and perpetually work-in-progress.

Python JavaScript FontLab 8

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
Shape manipulation, element library insertion, alignment, and expression-based composition system.
Naming, unlinking references, deletion, transform reset/rounding, auto-reorder, ungroup-all. Shape insertion and replacement from font-wide element library. Alignment to other shapes, layer bounds, font metrics. Expression-based composition with scripting syntax: coordinate placement by node tags, anchor names, bbox positions, per-layer overrides, element swapping.
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.
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.
Toolbars
Node · Node Align · Node Slope · Contour
Dockable toolbars for node operations, alignment, slope tools, and contour booleans.
Node: insertion, removal, extreme insertion, start-point, corner operations. Node Align: alignment to min/max, user targets, font metrics with intercept and smart-align. Node Slope: copy/paste with italic angle, min/max pivot with horizontal flip. Contour: boolean operations, closing, reversing, winding correction. MacOS Panel (toolbar-mac.py): unified flow-layout panel consolidating all toolbar functionality where QToolBar doesn't work.
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.
Lossless round-trip export using the eject mechanism to produce pure core objects serialized to XML.

Two packages, connected by a proxy layer.

Coretyperig.core

No external dependencies. Pure Python, runs anywhere — CPython, Pyodide in a browser, whatever.

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. utils — type-checking helpers.
core.fileio xmlio — XML round-trip engine with class registry, compact attribute encoding, lib-attribute support. Powers the .trfont experimental format. svg — SVG path filtering and pen-based import. nam — FontLab .nam parser. textproto — Google protobuf .textproto parser.
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: TRNodeActionCollector, TRCurveActionCollector, TRContourActionCollector, TRDrawActionCollector, TRLayerActionCollector.
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 (TRDrawIcon, contour/node rendering).
proxy.fl.application pWorkspace (canvas access, text block queries, active kern pair, frame creation), pItems (undo notification helpers).
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.

The core package also runs in the browser via Pyodide. The TR Glyph Viewer loads modules from GitHub at runtime, stubs the FL-dependent parts, and gives you a live Python editor on a canvas. Still rough around the edges.

TR Glyph Viewer → 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.

# Clone the repository git clone https://github.com/kateliev/TypeRig.git # Core objects — pure Python, no dependencies 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