fontlab.flNode
flNode
What Is a Node?
If you've ever edited a glyph in FontLab's glyph editor, you've clicked on nodes. A node is a single point on a Bézier curve contour — it's the fundamental building block of every letter shape you draw. When you look at a capital "S" in the glyph editor, you're looking at a collection of nodes connected by curve segments, and it's those nodes that define where the path goes and how it bends.
There are two fundamental kinds of nodes: on-curve nodes and off-curve nodes (also called handles or control points). On-curve nodes lie directly on the path — they're the filled squares or circles you see in the editor. Off-curve nodes (the hollow circles connected by dotted lines) sit off to the side of the curve and act like magnets, pulling the curve toward them without the path actually passing through them. In PostScript (Type 1 / OpenType CFF) fonts, every curve segment between two on-curve nodes has exactly two off-curve control points — this is the classic cubic Bézier. In TrueType fonts, each curve segment can be described with a single off-curve point between two on-curve anchors.
On-curve nodes can also be smooth or corner nodes. A smooth node keeps its two neighboring handles in a straight line through it, producing a fluid, tangent-continuous transition between the incoming and outgoing curves. A corner node lets the handles point in any direction, creating a sharp angle or cusp. In FontLab, smooth nodes are shown as circles and corner nodes as squares. When you're scripting, the smooth property tells you which kind you have, and setting it to True or False instantly changes the node's behavior.
Nested Types
NodeType
| Key | Native value | Description |
|---|---|---|
On |
flNode::NodeType::On |
Native enum value. |
Off |
flNode::NodeType::Off |
Native enum value. |
Curve |
flNode::NodeType::Curve |
Native enum value. |
AnyNodeMask |
flNode::NodeType::AnyNodeMask |
Native enum value. |
Defines what role a node plays in the contour:
- On — an on-curve point; the path passes through this node
- Off — an off-curve Bézier control handle; the path does not pass through this node
- Curve — an on-curve point that is part of a curve segment (has associated handles)
- AnyNodeMask — a wildcard that matches any node type (used in filter arguments)
NodeKind
| Key | Native value | Description |
|---|---|---|
None |
flNode::NodeKind::None |
Native enum value. |
Smooth |
flNode::NodeKind::Smooth |
Native enum value. |
First |
flNode::NodeKind::First |
Native enum value. |
Selected |
flNode::NodeKind::Selected |
Native enum value. |
Preview |
flNode::NodeKind::Preview |
Native enum value. |
ReadyToEdit |
flNode::NodeKind::ReadyToEdit |
Native enum value. |
InterpolatedX |
flNode::NodeKind::InterpolatedX |
Native enum value. |
InterpolatedY |
flNode::NodeKind::InterpolatedY |
Native enum value. |
HotSpot |
flNode::NodeKind::HotSpot |
Native enum value. |
G2 |
flNode::NodeKind::G2 |
Native enum value. |
Hobby |
flNode::NodeKind::Hobby |
Native enum value. |
SmartAngle |
flNode::NodeKind::SmartAngle |
Native enum value. |
SCV |
flNode::NodeKind::SCV |
Native enum value. |
KindMask |
flNode::NodeKind::KindMask |
Native enum value. |
SmartMask |
flNode::NodeKind::SmartMask |
Native enum value. |
SmoothMask |
flNode::NodeKind::SmoothMask |
Native enum value. |
ExtraLast |
flNode::NodeKind::ExtraLast |
Native enum value. |
A set of flags that can be combined to describe additional node attributes:
- None — no special flags
- Smooth — node enforces tangent continuity between its handles
- First — this is the start node of its contour
- Selected — node is currently selected
- Preview — node is flagged for preview display
- ReadyToEdit — node is in an editable state
- InterpolatedX / InterpolatedY — coordinate interpolation flags for variable fonts
- HotSpot — node is highlighted as a "hot" target for snapping
- G2 — node has G2 curvature continuity enabled
- Hobby — node uses Hobby-spline tension
- SmartAngle — Smart Angle feature is active
- SCV — Smooth Curve Vector is active
- KindMask / SmartMask / SmoothMask — bitmask combinations for filtering
- ExtraLast — internal flag for open contour endpoint handling
Tutorial
This tutorial walks through the most common node operations you'll use in scripts: accessing nodes from a glyph, reading their properties, navigating between them, creating new nodes by hand, and performing transforms. Each section builds on the previous one.
import fontlab as fl
from fontlab import flNode
# ── Step 1: Get a contour to work with ──────────────────────────────────────
# We'll use the first shape on the first layer of the glyph "A".
# In practice you'd pick the glyph and layer relevant to your task.
font = fl.CurrentFont()
glyph = font['A']
layer = glyph.layers[0]
shape = layer.shapes[0]
contour = shape.contours[0]
# ── Step 2: Inspect every node in the contour ────────────────────────────────
# node.type tells you 'on' or 'off'; node.smooth tells you if it's smooth.
# This is the first script most designers write when exploring an outline.
for node in contour.nodes():
print(f" ({node.x:.1f}, {node.y:.1f}) type={node.type} smooth={node.smooth}")
# ── Step 3: Create nodes manually and build a triangle ──────────────────────
# nodeType='on' means the path passes through the point.
# nodeType='off' means it's a Bézier handle — the path is pulled toward it.
n1 = flNode(0, 0, nodeType='on') # bottom-left corner
n2 = flNode(200, 0, nodeType='on') # bottom-right corner
n3 = flNode(100, 300, nodeType='on') # apex
# Adding them to a new closed contour:
tri = fl.flContour()
tri.closed = True
for n in [n1, n2, n3]:
tri.add(n)
shape.addContour(tri)
# ── Step 4: Navigate between nodes ──────────────────────────────────────────
# nextNode() with no argument returns the very next node (on OR off curve).
# nextNode('on') skips handles and jumps to the next on-curve anchor.
node = contour.nodes()[0]
nxt = node.nextNode() # next node of any type
prv = node.prevNode() # previous node of any type
# Find the nearest off-curve handle that follows this node:
next_off = node.nextNode(nodeType='off')
if next_off and not next_off.isNull:
print(f" outgoing handle: ({next_off.x}, {next_off.y})")
# ── Step 5: Change node properties ───────────────────────────────────────────
# Toggle a node between corner and smooth — the handles will snap to collinear.
node = contour.nodes()[0]
node.smooth = True # make this a smooth (tangent-continuous) point
node.smooth = False # revert to a corner
# Move a node:
node.x += 10 # nudge right by 10 units
node.moveBy(0, -5) # nudge down by 5 units (no rounding)
node.moveBy(5, 0, round=True) # move right 5 units, snap to integer
# Select it so you can see the change in the editor:
node.selected = True
# ── Step 6: Convert curve segments to/from lines ────────────────────────────
# convertToLine() removes handles from the incoming segment, making it straight.
# convertToCurve() adds handles to prepare a node for curve editing.
for node in contour.nodes():
if node.isOn(): # only work on on-curve nodes
if node.isCurve():
node.convertToLine() # straighten this segment
fl.Update() # refresh the display
# ── Step 7: Check and use node geometry queries ──────────────────────────────
# isExtreme() identifies nodes at horizontal or vertical extrema.
# These are the nodes that should exist for proper PostScript hinting.
for node in contour.nodes():
if node.isOn() and node.isExtreme(x=False): # vertical extreme
print(f" Vertical extreme at ({node.x:.1f}, {node.y:.1f})")
fl.Update()
Common Scripting Patterns
These ready-to-use patterns cover the tasks designers most often automate with node-level scripting.
Move all smooth nodes up by 10 units
Useful for nudging the smooth transition points in a design across all glyphs, for example when adjusting x-height in a batch operation.
import fontlab as fl
font = fl.CurrentFont()
for glyph in font.glyphs:
for layer in glyph.layers:
for shape in layer.shapes:
for contour in shape.contours:
for node in contour.nodes():
if node.isOn() and node.smooth:
node.moveBy(0, 10)
fl.Update()
Select all extremum nodes (vertical and horizontal)
Select the topmost, bottommost, leftmost, and rightmost nodes on every contour. FontLab highlights these after running extremes(), but this script lets you query and select them manually.
import fontlab as fl
font = fl.CurrentFont()
glyph = font['O']
layer = glyph.layers[0]
for shape in layer.shapes:
for contour in shape.contours:
for node in contour.nodes():
if node.isOn():
if node.isExtreme(x=True) or node.isExtreme(x=False):
node.selected = True
fl.Update()
Convert all curve nodes to line nodes in a glyph
Strips all Bézier handles from a glyph, reducing every curve to a straight line. Handy for creating a simplified or geometric version of a design.
import fontlab as fl
font = fl.CurrentFont()
glyph = font['S']
layer = glyph.layers[0]
for shape in layer.shapes:
for contour in shape.contours:
for node in contour.nodes():
if node.isOn() and node.isCurve():
node.convertToLine()
fl.Update()
Round all node coordinates to integers
Ensures every node in the current glyph has integer coordinates — a required step before manual hinting in many workflows.
import fontlab as fl
font = fl.CurrentFont()
glyph = font['g']
layer = glyph.layers[0]
for shape in layer.shapes:
for contour in shape.contours:
for node in contour.nodes():
node.round() # snaps x and y to nearest integer
fl.Update()
Find nodes that are nearly smooth but flagged as corners
Sometimes imported outlines have handles that are almost collinear but the smooth flag isn't set. This script finds and fixes them.
import fontlab as fl
font = fl.CurrentFont()
glyph = font['n']
layer = glyph.layers[0]
fixed = 0
for shape in layer.shapes:
for contour in shape.contours:
for node in contour.nodes():
if node.isOn() and not node.smooth:
if node.canBeSmooth():
node.smooth = True
fixed += 1
print(f"Fixed {fixed} near-smooth nodes")
fl.Update()
Keyword arguments
transformBy, scaleBy, rotateBy, skewBy, copyFrom, isEqualTo accept positional or keyword arguments. Other registered node methods take positional arguments. See the signatures above for parameter names and defaults.
Inherited binding members: flObject.
Constructors: flNode() flNode(Node) - make clone flNode(QPointF position[, string nodeType="on"[, int nodeKind=None]]) flNode(double x, double y[, string nodeType="on"[, int nodeKind=None]])
Native bases: object
Captured native MRO: flNode, object
Native new allocation evidence (not an init overload): (args, *kwargs) Create and return a new object. See help(type) for accurate signature.
Supplemental documentation:
A contour node. The captured declaration exposes x, y, type and smooth. The type member distinguishes on-curve points from off-curve control points. Read or assign x and y on the original native object.
Source: FontLab Proteus API documentation
Source: generated/fontlab.py: flNode captured declaration
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
NodeKind |
attribute | dict |
(shared captured text) |
NodeType |
attribute | dict |
(shared captured text) |
__init__ |
function | (self, /, *args: Any, **kwargs: Any) -> None |
Initialize self. (shared captured text) |
angle |
attribute | Any |
The angle of the node in degrees, representing the direction of the outgoing tangent. |
angleTo |
function | (self, p: QPointF) -> float |
Returns the angle in degrees between this node and a given point, measured from the positive X axis. |
applyTransform |
function | (self, arg0: QTransform) -> Any |
A lower-level transform application that works directly on the node's stored coordinates. |
canBeHobby |
function | (self) -> bool |
Returns True if this node and its neighbors are in a configuration that supports Hobby-spline optimization. |
canBeSmooth |
function | (self) -> bool |
Returns True if the handles around this node are already collinear (pointing in opposite directions through the node), meaning it could be set to smooth without changing the curve's shape. |
canCollapse |
function | (self) -> bool |
Returns True if this node's handles are short enough (effectively zero-length) that they can be safely collapsed without changing the visual appearance of the outline. |
canImprove |
function | (self) -> bool |
Returns True if FontLab's curve-quality heuristics think this node's position or handle angles could be improved for better curve tension. |
changed |
function | (self) -> Any |
(shared captured text) |
checkInitHistoryState |
function | (self, history_ix: int) -> Any |
(shared captured text) |
checkVectors |
function | (self) -> bool |
Examines the handles around this node to see if they are well-formed — for example, that they don't have zero length or degenerate positions. |
clearAboveHistory |
function | (self, history_ix: int) -> Any |
(shared captured text) |
clearFlag |
function | (self, f: int) -> Any |
(shared captured text) |
clearFlags |
function | (self) -> Any |
(shared captured text) |
clearStored |
function | (self) -> Any |
(shared captured text) |
clone |
function | (self, *args: Any, **kwargs: Any) -> Any |
Clone the object (shared captured text) |
cloneMapped |
function | (self, arg0: QTransform) -> flNode |
Creates a copy of this node with its coordinates transformed by the given matrix. |
cloneObject |
function | (*args: Any, **kwargs: Any) -> Any |
(shared captured text) |
collapseHandles |
function | (self) -> bool |
If the off-curve handles of this node are sitting on top of their on-curve anchor (zero length), this method removes them and converts the segment to a line. |
contour |
attribute | Any |
The parent Contour or None if not present |
convertToCurve |
function | (self, smooth: Any=...) -> bool |
Similar to convertToCurves but targets just the single outgoing segment. |
convertToCurves |
function | (self) -> bool |
Converts this on-curve node and its neighboring segments to use cubic Bézier control points, turning what may have been straight lines into curve segments ready for handle manipulation. |
convertToLine |
function | (self) -> bool |
Removes the off-curve handles from the segment leading into this node, making it a straight line segment. |
copyFrom |
function | (self, withSelected: Any=...) -> Any |
Copies the position, type, smooth flag, and other properties from another node into this one. |
createObject |
function | (*args: Any, **kwargs: Any) -> Any |
FlObject/Nothing createObject(int); (shared captured text) |
currentHistoryState |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
distanceTo |
function | (self, *args: Any, **kwargs: Any) -> Any |
Calculates the straight-line distance between this node and another node or a given point in em units. |
flObjectFlags |
attribute | dict |
(shared captured text) |
flag |
function | (self, f: int) -> Any |
(shared captured text) |
g2 |
attribute | Any |
True if G2 curvature continuity is active on this node. |
getLines |
function | (self, *args: Any, **kwargs: Any) -> Any |
(QLineF, QLineF)/None getLines() |
getOn |
function | (self) -> Any |
Node/None getOn() |
getProperties |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get object's properties list (shared captured text) |
getProperty |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get object property by 'key' or number (shared captured text) |
getPropertyFloat |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get float object property by 'key' (shared captured text) |
getPropertyInt |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get int object property by 'key' (shared captured text) |
hasChanges |
attribute | Any |
(shared captured text) |
hasHistoryState |
function | (self, history_ix: int) -> Any |
(shared captured text) |
hasHistoryStates |
attribute | Any |
(shared captured text) |
haveObject |
function | (*args: Any, **kwargs: Any) -> Any |
(shared captured text) |
historyStates |
function | (self, accepted_state: bool) -> Any |
(shared captured text) |
hobby |
attribute | Any |
True if this node is using Hobby-spline tension optimization. |
id |
attribute | Any |
Object id (shared captured text) |
improve |
function | (self) -> bool |
Attempts to automatically improve the curve quality around this node by adjusting handle lengths and directions. |
independedAll |
function | (self) -> Any |
(shared captured text) |
index |
attribute | Any |
The index of the node in parent's contour (if present, otherwise -1) |
initialHistoryState |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
instanceType |
function | (*args: Any, **kwargs: Any) -> Any |
(shared captured text) |
interpolated |
attribute | Any |
A tuple combining (interpolatedX, interpolatedY) for convenient reading and writing of both interpolation flags at once. |
interpolatedX |
attribute | Any |
When True, the node's X coordinate is treated as interpolated between masters rather than being independently controlled. |
interpolatedY |
attribute | Any |
Same as interpolatedX but for the Y axis. |
isChanged |
attribute | Any |
(shared captured text) |
isCorner |
function | (self, a: Any=...) -> bool |
Returns True if this node is a corner — meaning the angle between its incoming and outgoing tangents exceeds angle degrees. |
isCurve |
function | (self) -> bool |
Returns True if this node is an on-curve node that is part of a curve segment (as opposed to a line segment). |
isEqual |
function | (self, arg0: flObject) -> Any |
(shared captured text) |
isEqualTo |
function | (self, tolerance: Any=...) -> bool |
Returns True if this node has the same coordinates as another node (within tolerance). |
isExtreme |
function | (self, open: Any=...) -> bool |
Returns True if this node sits at a local extremum of the outline. |
isFirst |
function | (self) -> bool |
Returns True if this node is the designated start node of its contour. |
isG2 |
function | (self, tolerance: float) -> bool |
Returns True if this node currently satisfies G2 continuity within the given angular tolerance. |
isInternal |
function | (self, clockwise: bool) -> bool |
Returns True if this node appears to be on the inside (counter) of an outline, given the specified winding direction. |
isInterpolated |
function | (self, x: bool) -> bool |
Returns True if the specified coordinate of this node is marked as interpolated between masters. |
isLast |
function | (self) -> bool |
Returns True if this is the last node in the contour's node list. |
isNull |
attribute | Any |
True if this node object is a null/invalid reference — for example, if you called nextNode() and there was no next node. |
isOff |
function | (self) -> bool |
Returns True if this is an off-curve handle (Bézier control point). |
isOn |
function | (self) -> bool |
Returns True if this is an on-curve node — one that the path actually passes through. |
isPresent |
attribute | Any |
(shared captured text) |
isReleased |
attribute | Any |
(shared captured text) |
isSelectedAlone |
attribute | Any |
True if this node is selected and it is the only selected node in the contour. |
isSmartAngle |
function | (self) -> bool |
Returns True if this node has the Smart Angle feature enabled, meaning it can transition smoothly between a corner and a smooth point across the design space. |
isTerminal |
attribute | Any |
True if this node is at an endpoint of an open contour (either the very first or very last node with no connecting segment). |
isValid |
attribute | Any |
(shared captured text) |
makeStart |
function | (self) -> bool |
Designates this node as the first node (start point) of its contour. |
moveBy |
function | (self, *args: Any, **kwargs: Any) -> Any |
MoveBy(float dx, float dy[, bool round=false] |
name |
attribute | Any |
Object name (shared captured text) |
nextNode |
function | (self, nodeType: Any=...) -> Any |
Node/None nextNode([string nodeType= [, int searchDepth=1]]) |
nodeState |
attribute | Any |
A combined state value encoding both the node's type and kind flags. |
pointG2 |
function | (self) -> Any |
QPointF/None pointG2() |
position |
attribute | Any |
Coordinates of the node as QPointF |
prevNode |
function | (self, nodeType: Any=...) -> Any |
Node/None prevNode([string nodeType= [, int searchDepth=1]]) |
preview |
attribute | Any |
Flags this node for preview highlighting in the glyph editor. |
propertyNames |
function | (self, *args: Any, **kwargs: Any) -> Any |
PropertyNames(): sorted snapshot of dynamic property keys (shared captured text) |
refCnt |
attribute | Any |
Object references count (shared captured text) |
release |
function | (self) -> Any |
(shared captured text) |
remove |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
removeChild |
function | (self, arg0: flObject) -> Any |
(shared captured text) |
restoreCoordinates |
function | (self) -> Any |
(shared captured text) |
restoreHistoryState |
function | (self, history_ix: int) -> Any |
(shared captured text) |
rotateBy |
function | (self, origin: Any=...) -> Any |
Rotates the node around an optional center point. |
round |
function | (self) -> Any |
Round the node's coordinate |
scaleBy |
function | (self, origin: Any=...) -> Any |
Scales the node's position relative to an optional origin point. |
scv |
attribute | Any |
"Smooth Curve Vector" flag. |
selected |
attribute | Any |
The selected flag |
setExtraLast |
function | (self, bool: Any) -> Any |
Marks or unmarks this node as an "extra last" node, which is an internal flag used in some open-contour operations. |
setFlag |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
setNextSmooth |
function | (self, base: QPointF) -> Any |
Sets the position of the outgoing handle such that it maintains smooth continuity with the incoming handle direction. |
setPrevSmooth |
function | (self, base: QPointF) -> Any |
Sets the position of the incoming handle such that it maintains smooth continuity with the outgoing handle direction. |
setProperty |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set object property by 'key' or number (shared captured text) |
setPropertyFloat |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set float object property by 'key' (shared captured text) |
setPropertyInt |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set int object property by 'key' (shared captured text) |
setSmartAngleEnbl |
function | (self, bool: Any) -> bool |
Enables or disables the Smart Angle feature on this node. |
setSmartSharp |
function | (self, tension: Any=...) -> bool |
Sets up this node as a "smart sharp" point — a node type that blends between a corner and smooth depending on tension. |
skewBy |
function | (self, origin: Any=...) -> Any |
Skews (shears) the node's position. |
smartAngleR |
attribute | Any |
The radius parameter for the Smart Angle feature. |
smartMove |
function | (self, offset: Any) -> Any |
Moves this node while preserving smooth continuity with neighboring nodes — the adjacent handles are automatically adjusted to maintain their angles. |
smartSetXY |
function | (self, arg0: QPointF) -> Any |
Moves this node to the given position while intelligently updating neighboring handles to preserve curve quality, similar to dragging a node in the editor. |
smooth |
attribute | Any |
The smooth flag |
state |
attribute | Any |
A raw integer encoding all of the node's flags. |
storeCoordinates |
function | (self) -> Any |
(shared captured text) |
storeTestParameters |
function | (self) -> Any |
(shared captured text) |
tag |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
transformBy |
function | (self, origin: Any=...) -> Any |
Applies a full affine transformation matrix (QTransform) to the node's position. |
type |
attribute | Any |
The node type |
update |
function | (self) -> Any |
(shared captured text) |
updateG2 |
function | (self) -> bool |
Recalculates and updates the G2-continuity state for this node. |
updateSmooth |
function | (self, extended_neibh: Any=...) -> Any |
Recomputes the smooth constraint for this node, enforcing that its handles remain collinear. |
x |
attribute | Any |
The x coordinate of the node |
y |
attribute | Any |
The y coordinate of the node |