Skip to content

fontlab.flAbstractVectorNode

flAbstractVectorNode

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: flAbstractVectorNode(flAbstractVectorNode) flAbstractVectorNode(flObject)

Native bases: object

Captured native MRO: flAbstractVectorNode, 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: Abstract 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 and y. 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: flAbstractVectorNode 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
NodeType attribute dict
__init__ function (self, /, *args: Any, **kwargs: Any) -> None Initialize self. (shared captured text)
angle attribute Any
angleTo function (self, p: QPointF) -> float
applyTransform function (self, arg0: QTransform) -> Any
canBeHobby function (self) -> bool
canBeSmooth function (self) -> bool
canCollapse function (self) -> bool
canImprove function (self) -> bool
changed function (self) -> Any (shared captured text)
checkInitHistoryState function (self, history_ix: int) -> Any (shared captured text)
checkVectors function (self) -> bool
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
clone function (self, *args: Any, **kwargs: Any) -> Any Clone the object (shared captured text)
cloneMapped function (self, arg0: QTransform) -> flNode
cloneObject function (*args: Any, **kwargs: Any) -> Any (shared captured text)
collapseHandles function (self) -> bool
contour attribute Any The parent Contour or None if not present
convertToCurve function (self, smooth: Any=...) -> bool
convertToCurves function (self) -> bool
convertToLine function (self) -> bool
copyFrom function (self, withSelected: Any=...) -> Any
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
flObjectFlags attribute dict (shared captured text)
flag function (self, f: int) -> Any (shared captured text)
g2 attribute Any
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
id attribute Any Object id (shared captured text)
improve function (self) -> bool
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
interpolatedX attribute Any
interpolatedY attribute Any
isChanged attribute Any (shared captured text)
isCorner function (self, a: Any=...) -> bool
isCurve function (self) -> bool (shared captured text)
isEqual function (self, arg0: flObject) -> Any (shared captured text)
isEqualTo function (self, tolerance: Any=...) -> bool
isExtreme function (self, open: Any=...) -> bool
isFirst function (self) -> bool
isG2 function (self, tolerance: float) -> bool
isInternal function (self, clockwise: bool) -> bool
isInterpolated function (self, x: bool) -> bool
isLast function (self) -> bool
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
isSmartAngle function (self) -> bool
isTerminal attribute Any
isValid attribute Any (shared captured text)
makeStart function (self) -> bool
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
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
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
restoreHistoryState function (self, history_ix: int) -> Any (shared captured text)
rotateBy function (self, origin: Any=...) -> Any
round function (self) -> Any Round the node's coordinate
scaleBy function (self, origin: Any=...) -> Any
scv attribute Any
selected attribute Any The selected flag
setExtraLast function (self, bool: Any) -> Any
setFlag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
setNextSmooth function (self, base: QPointF) -> Any
setPosition function (self, arg0: QPointF) -> None Sets the position of this vector node in glyph coordinates.
setPrevSmooth function (self, base: QPointF) -> Any
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
setSmartSharp function (self, tension: Any=...) -> bool
skewBy function (self, origin: Any=...) -> Any
smartAngleR attribute Any
smartMove function (self, offset: Any) -> Any
smartSetXY function (self, arg0: QPointF) -> Any
smooth attribute Any The smooth flag
state attribute Any
storeCoordinates function (self) -> Any
storeTestParameters function (self) -> Any
tag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
transformBy function (self, origin: Any=...) -> Any
type attribute Any The node type
update function (self) -> Any (shared captured text)
updateG2 function (self) -> bool
updateSmooth function (self, extended_neibh: Any=...) -> Any
x attribute Any The x coordinate of the node
y attribute Any The y coordinate of the node