Skip to content

fontlab.flNodeInfo

flNodeInfo

Represents one node on the canvas. This is the "live" version of an flNode — it knows where the node is on screen and can move it in glyph-space coordinates. This is what you receive when the user selects nodes in a scripted tool.

When do you use it?

In any tool that moves selected nodes. canvas.selectedNodes() returns a list of flNodeInfo objects, and you move those nodes by calling setGlyphPoint() on each one.

Tutorial

flNodeInfo is the primary API for moving nodes in a custom canvas tool. Here is the standard pattern: get the selected node infos, move them, then refresh.

from PythonQt.QtCore import QPointF
import fontlab as fl

# ============================================================
# Move all selected nodes up by 10 units.
# This is the pattern used by any tool that nudges nodes.
# ============================================================

ws     = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
if canvas is None:
    print("Open a glyph window first.")
    raise SystemExit

gi = canvas.activeGlyphInfo()
if gi is None:
    print("No active glyph.")
    raise SystemExit

selected = gi.selectedNodes()   # returns list of flNodeInfo
if not selected:
    print("Select at least one node first.")
    raise SystemExit

print(f"Moving {len(selected)} selected node(s) up by 10 units:")
for ni in selected:
    pt = ni.getGlyphPoint(False)          # current position (unrounded)
    new_pt = QPointF(pt.x(), pt.y() + 10)
    ni.setGlyphPoint(new_pt)              # move the node
    print(f"  ({pt.x():.0f}, {pt.y():.0f}) → ({new_pt.x():.0f}, {new_pt.y():.0f})")

fl.Update()   # refresh the canvas after all moves

# ============================================================
# Align all selected nodes to the same x-coordinate
# (the average x of the selection).
# ============================================================

if selected:
    xs    = [ni.getGlyphPoint(False).x() for ni in selected]
    avg_x = sum(xs) / len(xs)
    for ni in selected:
        pt = ni.getGlyphPoint(False)
        ni.setGlyphPoint(QPointF(avg_x, pt.y()))
    fl.Update()
    print(f"Aligned {len(selected)} nodes to x={avg_x:.0f}")

Common Scripting Patterns

Validate node infos after a delete operation

import fontlab as fl

ws     = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
gi     = canvas.activeGlyphInfo() if canvas else None
if gi:
    nodes = gi.selectedNodes()
    valid_nodes = [ni for ni in nodes if ni.isValid()]
    print(f"{len(valid_nodes)} of {len(nodes)} node infos are still valid.")

Get the canvas repaint rect for a node move

import fontlab as fl

ws     = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
gi     = canvas.activeGlyphInfo() if canvas else None
if gi:
    selected = gi.selectedNodes()
    if selected:
        ni          = selected[0]
        repaint_rect = ni.getMappedNeighborsRect()
        print(f"Repaint rect for node move: {repaint_rect}")
        # In a real tool, pass this to canvas.update(repaint_rect)

Inherited binding members: flSearchInfo.

Constructors: flNodeInfo() flNodeInfo(flObject) flNodeInfo(flNodeInfo) flNodeInfo(flNode, QTransform) flNodeInfo(flNode, flObject contour_info) flNodeInfo(flNode, flObject glyph_info, QTransform) flNodeInfo(flNode, flNodeInfo)

Native bases: object

Captured native MRO: flNodeInfo, 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: Node information. The captured declaration exposes node, contour, contourInfo, shape, shapeInfo, glyphInfo, getGlyphPoint, setGlyphPoint, setGlyphPointX, setGlyphPointY, getMappedPoint, toNodesInfo, breakContourExpanded, combine, dist and transform. 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: flNodeInfo 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
__init__ function (self, /, *args: Any, **kwargs: Any) -> None Initialize self. (shared captured text)
breakContourExpanded function (self, extrapolate_d: Any=...) -> bool Breaks the contour at this node, with the break slightly expanded by extrapolate_d units so the two endpoints don't coincide.
changed function (self) -> Any (shared captured text)
checkInitHistoryState function (self, history_ix: int) -> Any (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)
clone function (self, *args: Any, **kwargs: Any) -> Any Clone the object (shared captured text)
cloneObject function (*args: Any, **kwargs: Any) -> Any (shared captured text)
combine function (self, transform: QTransform) -> Any (shared captured text)
contour function (self) -> flContour Returns the flContour that contains this node.
contourInfo attribute Any The parent flContourInfo.
createInstance function () -> flNodeInfo Factory.
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)
dist attribute Any Double dist (shared captured text)
flObjectFlags attribute dict (shared captured text)
flag function (self, f: int) -> Any (shared captured text)
getGlyphPoint function (self, round: bool) -> QPointF Returns this node's position in glyph units.
getMappedNeighborsRect function (self) -> QRectF Returns the canvas bounding rect that covers this node plus its two immediate neighbours (the nodes before and after it in the contour) and their control points.
getMappedPoint function (self, *args: Any, **kwargs: Any) -> Any Returns this node's current position in canvas coordinates.
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)
getUpdateCanvasRect function (self) -> QRectF Returns the canvas rect to repaint when this specific node moves.
glyphInfo attribute Any Glyph info (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)
id attribute Any Object id (shared captured text)
independedAll function (self) -> Any (shared captured text)
initialHistoryState function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
instanceType function (*args: Any, **kwargs: Any) -> Any (shared captured text)
isChanged attribute Any (shared captured text)
isEqual function (self, arg0: flObject) -> Any (shared captured text)
isNull attribute Any (shared captured text)
isPresent attribute Any (shared captured text)
isReleased attribute Any (shared captured text)
isValid function (self) -> bool Returns True if this node info points to an existing node.
name attribute Any Object name (shared captured text)
node attribute Any The underlying flNode model object.
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)
restoreHistoryState function (self, history_ix: int) -> Any (shared captured text)
setFlag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
setGlyphPoint function (self, arg0: QPointF) -> Any Moves this node to the given position in glyph units.
setGlyphPointX function (self, x: float) -> Any Sets only the x-coordinate of this node in glyph units, leaving y unchanged.
setGlyphPointY function (self, y: float) -> Any Sets only the y-coordinate of this node in glyph units.
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)
shape function (self) -> flShape Returns the parent flShape.
shapeInfo function (self) -> flShapeInfo Returns the parent flShapeInfo.
tag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
toNodesInfo function (self, *args: Any, **kwargs: Any) -> Any
transform attribute Any Transform matrix (shared captured text)
type attribute Any Object type (shared captured text)
update function (self) -> Any (shared captured text)