Skip to content

fontlab.flVectorNode

flVectorNode

Guideline-anchored nodes.

What are vector nodes?

A vector node (called a "vector point" in the FontLab UI) is a special node that is pinned to a guideline. When the guideline moves, the node moves with it — automatically, across all glyphs that reference that guideline. This is the mechanism behind FontLab's power guidelines: you draw a guideline, attach nodes from multiple glyphs to it, and moving the guideline moves all the attached nodes at once.

This makes vector nodes a powerful tool for variable font design. If you define a guideline at the x-height and attach the top of your lowercase letters to it, raising the x-height guideline automatically raises every attached node in every glyph.

flAbstractVectorNode is the base class (provides the interface); flVectorNode is the concrete implementation you create and use in scripts.

Static Methods (flVectorNode)

Signature Description
flVectorNode createInstance() Creates a detached flVectorNode ready to be attached to a guideline.
bool isVectorNode(flObject) Returns True if the given object is an flVectorNode. Use this for type checking when iterating mixed node lists.

Properties (flVectorNode)

Name Type Access Description
mode uint ro The current positioning mode of this vector node — absolute or relative tracking.
guideline flGuideLine ro The guideline this node is attached to. Read this to find which guideline is driving the node's position.

Tutorial

Vector nodes are most useful in variable fonts where you want multiple glyphs to share a common alignment target. Here is how to check for and inspect existing vector nodes in a glyph.

from PythonQt.QtCore import QPointF
import fontlab as fl
from fontlab import flVectorNode

# ============================================================
# Check whether any nodes in the active glyph are vector nodes
# (i.e. attached to guidelines).
# ============================================================

font  = fl.CurrentFont()
glyph = font['a']
layer = glyph.layers[0]

print(f"Checking '{glyph.name}' for vector nodes:")
found = 0
for shape in layer.shapes:
    for contour in shape.contours:
        for node in contour.nodes():
            if flVectorNode.isVectorNode(node):
                vn = node   # it IS an flVectorNode
                print(f"  Vector node at ({vn.x:.0f}, {vn.y:.0f})"
                      f"  attached to guideline: {vn.guideline}")
                found += 1

if found == 0:
    print("  No vector nodes found in this glyph.")

# ============================================================
# Create a vector node and attach it to a guideline.
# ============================================================

# First, find or create a guideline to attach to:
x_height_guide = next(
    (g for g in font.guidelines if g.expression == "=xHeight"), None
)

if x_height_guide:
    # Create a vector node at the x-height position:
    vn = flVectorNode.createInstance()
    vn.setPosition(QPointF(250, x_height_guide.centerPoint.y()))

    print(f"\nCreated vector node at ({250}, {x_height_guide.centerPoint.y():.0f})")
    print("Attach this node to a contour via contour.addVectorNode(vn).")
else:
    print("\nNo x-height expression guideline found.")
    print("Create one first: guide.expression = '=xHeight'")

Common Scripting Patterns

Count vector nodes across the entire font

import fontlab as fl
from fontlab import flVectorNode

font = fl.CurrentFont()
total = 0
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 flVectorNode.isVectorNode(node):
                        total += 1

print(f"Total vector nodes in font: {total}")

Find all guidelines that have attached vector nodes

import fontlab as fl
from fontlab import flVectorNode

font = fl.CurrentFont()
used_guides = set()

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 flVectorNode.isVectorNode(node):
                        gl = node.guideline
                        if gl:
                            used_guides.add(id(gl))

print(f"{len(used_guides)} guideline(s) have attached vector nodes.")

flVectorNode.Mode

Use the flVectorNode.Mode dictionary with subscription.

Key Native value Description
PosParametric flVectorNode::Mode::PosParametric Native enum value.
PosAbsolute flVectorNode::Mode::PosAbsolute Native enum value.
PosHorzDir flVectorNode::Mode::PosHorzDir Native enum value.
PosVertDir flVectorNode::Mode::PosVertDir Native enum value.
PosMask flVectorNode::Mode::PosMask Native enum value.

Constructors: flVectorNode(flObject) flVectorNode(flVectorNode) flVectorNode(flGuideLine, QPointF)

Native bases: object

Captured native MRO: flVectorNode, 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: Vector node. The captured declaration exposes angleTo, canBeSmooth, canCollapse, collapseHandles, convertToCurve, convertToLine, moveBy, rotateBy, scaleBy, skewBy, makeStart, nextNode, prevNode, isCurve, isOn, isOff, isFirst, isLast, smooth, position, selected, x, y, guideline, mode, setPositionMode and isVectorNode. It is created with no captured constructor overloads. It also carries the shared object members changed, clone, cloneObject, getProperty, setProperty, release, remove and update and the shared attributes id, name, type, isValid and isNull.

Source: FontLab Proteus API documentation

Source: generated/fontlab.py: flVectorNode 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
Mode attribute dict
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 (shared captured text)
angleTo function (self, p: QPointF) -> float (shared captured text)
applyTransform function (self, arg0: QTransform) -> Any (shared captured text)
canBeHobby function (self) -> bool (shared captured text)
canBeSmooth function (self) -> bool (shared captured text)
canCollapse function (self) -> bool (shared captured text)
canImprove function (self) -> bool (shared captured text)
changed function (self) -> Any (shared captured text)
checkInitHistoryState function (self, history_ix: int) -> Any (shared captured text)
checkVectors function (self) -> bool (shared captured text)
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 (shared captured text)
cloneObject function (*args: Any, **kwargs: Any) -> Any (shared captured text)
collapseHandles function (self) -> bool (shared captured text)
contour attribute Any The parent Contour or None if not present (shared captured text)
convertToCurve function (self, smooth: Any=...) -> bool (shared captured text)
convertToCurves function (self) -> bool (shared captured text)
convertToLine function (self) -> bool (shared captured text)
copyFrom function (self, withSelected: Any=...) -> Any (shared captured text)
createInstance function () -> flVectorNode
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 (shared captured text)
flObjectFlags attribute dict (shared captured text)
flag function (self, f: int) -> Any (shared captured text)
g2 attribute Any (shared captured text)
getLines function (self, *args: Any, **kwargs: Any) -> Any (QLineF, QLineF)/None getLines() (shared captured text)
getOn function (self) -> Any Node/None getOn() (shared captured text)
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)
guideline attribute Any
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 (shared captured text)
id attribute Any Object id (shared captured text)
improve function (self) -> bool (shared captured text)
independedAll function (self) -> Any (shared captured text)
index attribute Any The index of the node in parent's contour (if present, otherwise -1) (shared captured text)
initialHistoryState function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
instanceType function (*args: Any, **kwargs: Any) -> Any (shared captured text)
interpolated attribute Any (shared captured text)
interpolatedX attribute Any (shared captured text)
interpolatedY attribute Any (shared captured text)
isChanged attribute Any (shared captured text)
isCorner function (self, a: Any=...) -> bool (shared captured text)
isCurve function (self) -> bool (shared captured text)
isEqual function (self, arg0: flObject) -> Any (shared captured text)
isEqualTo function (self, tolerance: Any=...) -> bool (shared captured text)
isExtreme function (self, open: Any=...) -> bool (shared captured text)
isFirst function (self) -> bool (shared captured text)
isG2 function (self, tolerance: float) -> bool (shared captured text)
isInternal function (self, clockwise: bool) -> bool (shared captured text)
isInterpolated function (self, x: bool) -> bool (shared captured text)
isLast function (self) -> bool (shared captured text)
isNull attribute Any (shared captured text)
isOff function (self) -> bool (shared captured text)
isOn function (self) -> bool (shared captured text)
isPresent attribute Any (shared captured text)
isReleased attribute Any (shared captured text)
isSelectedAlone attribute Any (shared captured text)
isSmartAngle function (self) -> bool (shared captured text)
isTerminal attribute Any (shared captured text)
isValid attribute Any (shared captured text)
isVectorNode function (arg0: flObject) -> bool
makeStart function (self) -> bool (shared captured text)
mode attribute Any
moveBy function (self, *args: Any, **kwargs: Any) -> Any MoveBy(float dx, float dy[, bool round=false] (shared captured text)
name attribute Any Object name (shared captured text)
nextNode function (self, nodeType: Any=...) -> Any Node/None nextNode([string nodeType= [, int searchDepth=1]]) (shared captured text)
nodeState attribute Any (shared captured text)
pointG2 function (self) -> Any QPointF/None pointG2() (shared captured text)
position attribute Any Coordinates of the node as QPointF (shared captured text)
prevNode function (self, nodeType: Any=...) -> Any Node/None prevNode([string nodeType= [, int searchDepth=1]]) (shared captured text)
preview attribute Any (shared captured text)
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 (shared captured text)
round function (self) -> Any Round the node's coordinate (shared captured text)
scaleBy function (self, origin: Any=...) -> Any (shared captured text)
scv attribute Any (shared captured text)
selected attribute Any The selected flag (shared captured text)
setExtraLast function (self, bool: Any) -> Any (shared captured text)
setFlag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
setNextSmooth function (self, base: QPointF) -> Any (shared captured text)
setPosition function (self, arg0: QPointF) -> None Sets the position of this vector node in glyph coordinates. (shared captured text)
setPositionMode function (self, m: Any) -> None Controls whether the node's position is tracked absolutely (always at a fixed glyph coordinate) or relatively (offset from the guideline's current position).
setPrevSmooth function (self, base: QPointF) -> Any (shared captured text)
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 (shared captured text)
setSmartSharp function (self, tension: Any=...) -> bool (shared captured text)
skewBy function (self, origin: Any=...) -> Any (shared captured text)
smartAngleR attribute Any (shared captured text)
smartMove function (self, offset: Any) -> Any (shared captured text)
smartSetXY function (self, arg0: QPointF) -> Any (shared captured text)
smooth attribute Any The smooth flag (shared captured text)
state attribute Any (shared captured text)
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 (shared captured text)
type attribute Any The node type (shared captured text)
update function (self) -> Any (shared captured text)
updateG2 function (self) -> bool (shared captured text)
updateSmooth function (self, extended_neibh: Any=...) -> Any (shared captured text)
x attribute Any The x coordinate of the node (shared captured text)
y attribute Any The y coordinate of the node (shared captured text)