fontlab
fontlab
Overview
Python interface for FontLab data objects
Architecture
The FontLab Python API is a C++/Python binding layer:
The class articles document registered names, member kinds, calling conventions and property access. Some APIs depend on build flags. The separate fontgate module and inherited PythonQt/Qt APIs are outside this inventory.
CurrentFont() returns fgFont, and CurrentGlyph() returns fgGlyph. Use fl.flPackage(fg_font) or fl.flGlyph(fg_glyph) when calling the model APIs described by the fl* guides. Constructing a wrapper from an existing model object does not imply an independent geometry copy; use the appropriate clone() operation when a separate object is needed.
Type Conventions
Throughout the documentation, types use these conventions:
| Type | Meaning |
|---|---|
str |
Python string (C++ QString) |
float |
Python float (C++ double) |
int |
Python integer |
bool |
Python bool |
QPointF |
Qt 2D point; use PythonQt.QtCore.QPointF unless the specific overload documents tuple conversion |
QRectF |
Qt rectangle; use PythonQt.QtCore.QRectF unless the specific overload documents tuple conversion |
QTransform |
3×3 matrix — passed as a QTransform-like object |
QColor |
Qt color; use PythonQt.QtGui.QColor unless the specific overload documents tuple conversion |
list(T) |
Python list of type T |
T/None |
Returns T or Python None |
Calling conventions and inherited members
Registered methods take positional arguments unless their class article explicitly lists keyword support. Optional values shown as name=default in signatures do not by themselves imply keyword support. flNode documents its keyword-capable methods. Value-wrapper constructors document their own field-keyword initialization.
Inherited registrations are documented in the base class article; each class article names its binding base where applicable. C++ inheritance alone does not guarantee that a base member is exposed in Python. Binding annotations record declared signatures and can be incomplete; implementation notes in the class articles qualify known differences.
High-level FontLab editing API. flGlyph contains drawing layers, flLayer contains shapes, and flContour contains nodes. CurrentFont() and CurrentGlyph() access the active editing context.
Source: FontLab Proteus API documentation
Functions
| Function | Signature | Summary |
|---|---|---|
AcceptChanges |
(clearChangedState: Any=...) -> Any |
Accept pending changes. |
AllFonts |
(*args: Any, **kwargs: Any) -> Any |
Get a list of currently opened fonts |
ApplicationPath |
(*args: Any, **kwargs: Any) -> Any |
Return path to FontLab main application |
CountFonts |
(*args: Any, **kwargs: Any) -> Any |
Return number of currently opened fonts |
CreatePanel |
(*args: Any, **kwargs: Any) -> Any |
Create YPanelWidget instance |
CurrentFont |
(*args: Any, **kwargs: Any) -> Any |
Get currently active font |
CurrentGlyph |
(*args: Any, **kwargs: Any) -> Any |
Get currently active glyph |
GetFileName |
(open_save: Any, extension: Any, filename: Any, filters: Any) -> Any |
Opens the file dialog. open_save = 1 for file open dialog |
GetPathName |
(*args: Any, **kwargs: Any) -> Any |
Allows to select folder |
GetProperty |
(*args: Any, **kwargs: Any) -> Any |
Get FL properties (keywords: output, ...) |
MainWindow |
(*args: Any, **kwargs: Any) -> Any |
Get MainWindow object |
PanelManager |
(*args: Any, **kwargs: Any) -> Any |
Get YPanelManager object |
SetCurrentFont |
(*args: Any, **kwargs: Any) -> Any |
Set active font |
SetCurrentGlyph |
(*args: Any, **kwargs: Any) -> Any |
Set active glyph |
SetProperty |
(*args: Any, **kwargs: Any) -> Any |
Set FL properties (keywords: output, ...) |
TestBuilder |
(*args: Any, **kwargs: Any) -> Any |
Test Glyph Builder |
Update |
(*args: Any, **kwargs: Any) -> Any |
Update object and it's visual representations. |
UpdateActiveCanvas |
() -> Any |
Refresh the active canvas. |
UpdateAll |
() -> Any |
Full preview update. |
UpdateGlyphRect |
(x0: Any, y0: Any, x1: Any, y1: Any) -> Any |
Update glyph rect and trigger preview. |
Classes
| Class | Summary |
|---|---|
AccentInfo |
An accent-placement result returned by flPackage.getAccentsInfo(layer, pin). |
CurveEx |
A single Bézier segment. |
ExportControl |
Font export configuration. |
FaBasicPtr |
A single font audit finding. |
FontLayer |
This auxiliary wrapper is registered by the module and accepts FontLayer(package, name), with an flPackage and a string. |
FontMetrics |
Vertical metric values for one master. |
GlyphComponent |
A component reference inside a composite glyph. |
Info |
Font Info data |
Interval |
A parametric range on a contour. |
LocationValue |
A LocationValue is the value stored for a single axis in an flLocation. |
PaintBrush |
Brush settings for drawing tools. |
PaintBrushShape |
The custom brush profile stored in PaintBrush.shape. |
SmartCornerParameters |
A value wrapper for a font's Smart Corners settings. |
TransformFrame |
Interactive Bounding Frame. |
YPanelManager |
Dockable panel system. |
YPanelWidget |
Custom dockable panel. |
fgSymbol |
A single character identity record. |
fgSymbolList |
A string of characters. |
flAbstractEditor |
Inline canvas widget editor. |
flAbstractVectorNode |
Guideline-anchored nodes. |
flAnchor |
flAnchor is a geometric attachment link — it records a connection between a shape and another object (a guideline, another shape, or a specific node). |
flAuditInfo |
Represents one finding from FontLab's built-in font audit system. |
flAxis |
A design axis is one dimension of variation in a variable font. |
flBasicTool |
Base class for editor tools. |
flCanvas |
A canvas is one editor window in FontLab — a glyph editor, a metrics window, or a text window. |
flContour |
A contour is the closed or open path that forms a letter's shape. |
flContourInfo |
Canvas proxy for a contour. |
flEvent |
Mouse and keyboard event. |
flExpression |
Formula string for axis-driven values. |
flGlyph |
A glyph is your font's record for one character — the letter "A", the numeral "3", an ampersand, or any other symbol you draw. |
flGlyphInfo |
Canvas proxy for a rendered glyph. |
flGraphicsInfo |
Canvas-transform-aware info object. |
flGuideLine |
Guidelines are the non-printing reference lines you draw across your canvas to help align things. |
flHintingParameters |
PostScript hinting settings. |
flInstance |
A named instance is a preset — a specific location in design space that you've given a name to, like "Regular", "Bold", "Light Italic", or "SemiBold Condensed". |
flItems |
flItems is FontLab's application-wide event megaphone. |
flLayer |
In FontLab, a layer is the container inside a glyph that holds the actual drawing for one master. |
flLayerAttributes |
A value wrapper used by flPackage.instanceAttributes to describe generated instance layers. |
flLayerInfo |
Canvas proxy for a layer. |
flLocation |
A location is a coordinate in design space. |
flMarkerPoint |
Snap Line Measurement Marker. |
flModel |
Think of flModel as FontLab's type registry — its internal catalogue of every kind of object that can exist in a font. |
flModelProducer |
Clipboard operations. |
flMouseEvent |
Mouse-event data supplied by the editor, or returned by flWorkspace.convertMouseEvent(qevent, previous_global_point). |
flNode |
If you've ever edited a glyph in FontLab's glyph editor, you've clicked on nodes. |
flNodeInfo |
Represents one node on the canvas. |
flObject |
Everything you touch in FontLab — a node, a contour, a shape, a guideline, an anchor, a glyph, a layer, even the font itself — is an flObject under the hood. |
flObjectsList_flGuideLine_ |
These are native mutable object-list wrappers, used by APIs such as flShapeData.includes. |
flObjectsList_flShape_ |
These are native mutable object-list wrappers, used by APIs such as flShapeData.includes. |
flPackage |
flPackage is your font file. |
flPaper |
Metrics view background layer. |
flPinPoint |
Named anchor for mark positioning. |
flPreferences |
flPreferences gives scripts read and write access to almost every setting in FontLab — the same settings you'd normally change in the Preferences dialog. |
flProperty |
Base class for axis-aware attributes. |
flPropertyDouble |
Scalar axis-driven attribute. |
flPropertyPoint |
2-D point axis-driven attribute. |
flSearchInfo |
Base canvas info object. |
flShape |
The Element. |
flShapeBuilder |
Parametric Element Constructor. |
flShapeData |
The Shared Drawing Record. |
flShapeInfo |
Represents one flShape as displayed on the canvas. |
flSnapLine |
Guideline snap geometry engine. |
flSnapObject |
A snap target. |
flSnaps |
Snap object constants |
flStem |
Hinting Stem Definition. |
flSticker |
Canvas Annotation. |
flTTHCommand |
A TrueType hinting instruction. |
flTextBlock |
Text layout and editing engine. |
flTransform |
A transform is a recipe for repositioning, resizing, rotating, or slanting something. |
flVectorNode |
Guideline-anchored nodes. |
flVisualItem |
Base class for all canvas objects. |
flWorkspace |
flWorkspace is the FontLab application itself — represented as a Python object. |
flZone |
A single alignment zone — a band near a metric line used to snap stroke endings consistently. |
Constants and attributes
| Name | Type | Summary |
|---|---|---|
BinaryFormatVersion |
dict |
Binary file format version identifiers, including the current version. |
BuilderFeatures |
dict |
Builder feature flags; the documented key is bfSmartAngle. |
DecoratorOrder |
dict |
Drawing order of a decorator relative to its owner: over or under. |
EditMode |
dict |
Glyph window editing modes: preview text, edit outline, edit metrics, edit text, and edit metrics or outlines. |
GlyphInfoState |
dict |
Glyph state flags: no state, selected, active, active and selected, and all. |
HintingDataType |
dict |
Hinting data kinds: PostScript or TrueType. |
LightNodesMode |
dict |
Node highlighting modes: off, all nodes, active glyph only, or an area only. |
ObjectFlag |
dict |
Object state flags such as released, changed, ignore changes, passive, slow update, anchored and history. |
SelectionMode |
dict |
Node selection tests: any node selected, or all nodes of the contour selected. |
ShapeCloneInfo |
dict |
Flags choosing which shape parts to clone: contours, anchors, composite, guidelines, pin points, transform or all. |
ShapeType |
dict |
Shape kinds: undefined, outline contours, bitmap image, sticker, or any shape. |
SnapAngleMode |
dict |
Angle snapping modes: absolute or vector. |
SnapObjectsStyle |
dict |
Kinds of snap target, such as page, glyph, font and shape guidelines and smart positions. |
TextBlockFormat |
dict |
Text block formats: text, frame or table. |
TransformFrameControls |
dict |
Transform frame handles: edges, corners, centers, body and rotate. |
ViewPointAlignment |
dict |
View point alignment: center or top left. |
flTools |
dict |
Names of the FontLab editing tools, such as the pen, knife, text and transform tools. |