Skip to content

fontlab.flAuditInfo

flAuditInfo

Represents one finding from FontLab's built-in font audit system. Each flAuditInfo wraps a FaBasic record that describes a specific problem (an open contour, an almost-flat curve, a wrong-direction path, etc.) and can point you to the exact location in the glyph.

When do you use it?

When you want to programmatically run the audit and process or fix the results. Combine with FaBasic.fix() to auto-fix all fixable issues in a batch.

Tutorial

The code below shows how to build a simple interactive tool function that works with info objects. You can run parts of it in the scripting panel when a glyph window is open.

from PythonQt.QtCore import QPointF
import fontlab as fl

# ============================================================
# First, make sure a glyph window is open.
# Everything that follows requires an active canvas.
# ============================================================

ws     = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
if canvas is None:
    print("Please open a glyph window first (double-click any glyph).")
    raise SystemExit

# ============================================================
# 1. Get the glyph that is currently being edited.
#    This is your main entry point into the canvas info system.
# ============================================================

glyph_info = canvas.activeGlyphInfo()
if not glyph_info:
    print("No active glyph — click inside the glyph editor.")
    raise SystemExit

print(f"Active glyph: '{glyph_info.name}'")
print(f"  Canvas bounds:  {glyph_info.brectOnCanvas}")
print(f"  Is active:      {glyph_info.isActive}")

# ============================================================
# 2. Find all contours within 60 canvas pixels of a point.
#    This simulates what a snap-to-outline tool would do:
#    given the mouse position, find the nearest contour.
# ============================================================

test_point = QPointF(200, 400)   # a canvas-space point
nearby = glyph_info.getNearbyContours(test_point, 60.0, "")
print(f"\nContours within 60px of {test_point}: {len(nearby)}")
for ci in nearby:
    pt = ci.paramExT()   # extended parametric position of closest point
    print(f"  Contour canvas bounds: {ci.brectOnCanvas()}")

# ============================================================
# 3. Work with selected nodes.
#    canvas.selectedNodes() gives you every selected node as
#    an flNodeInfo. You can read its glyph position and move it.
# ============================================================

selected = canvas.selectedNodes()
print(f"\nSelected nodes: {len(selected)}")

for ni in selected:
    # Read current position in glyph units:
    pos = ni.getGlyphPoint(True)   # True = round to nearest integer
    print(f"  Node at glyph ({pos.x():.0f}, {pos.y():.0f})")

    # Check which shape and contour this node belongs to:
    si = ni.shapeInfo()
    print(f"    → in shape with canvas bounds {si.boundingBox()}")

    # Move the node 10 units to the right:
    new_pos = QPointF(pos.x() + 10, pos.y())
    ni.setGlyphPoint(new_pos)

# After moving nodes, tell FontLab to refresh the display:
if selected:
    fl.Update()
    print("Moved all selected nodes 10 units right.")

# ============================================================
# 4. Hit test: find which shape is under a canvas point.
#    Useful in custom tools to implement "click to select shape".
# ============================================================

hit_pt = QPointF(150, 300)   # simulate a mouse click position
hit_shape = glyph_info.getTopHitShape(hit_pt)
if hit_shape:
    print(f"\nShape hit at {hit_pt}: bounds = {hit_shape.boundingBox()}")
else:
    print(f"\nNo shape at {hit_pt}")

# ============================================================
# 5. Align selected nodes to the same Y value (horizontal align).
#    This is a practical designer script: select nodes in the
#    glyph editor, run this, and they all snap to the same height.
# ============================================================

selected = canvas.selectedNodes()
if len(selected) >= 2:
    # Use the average Y of all selected nodes as the target:
    avg_y = sum(ni.getGlyphPoint(False).y() for ni in selected) / len(selected)
    print(f"\nAligning {len(selected)} nodes to Y = {avg_y:.1f}")

    for ni in selected:
        pos = ni.getGlyphPoint(False)
        ni.setGlyphPoint(QPointF(pos.x(), avg_y))

    fl.Update()
    print("Done — nodes aligned.")

Common Scripting Patterns

Pattern 1 — Print the canvas position of every node in the active glyph

from PythonQt.QtCore import QPointF
import fontlab as fl

canvas = fl.flWorkspace.instance().currentCanvas
gi = canvas.activeGlyphInfo() if canvas else None
if gi:
    for ci in gi.getNearbyContours(QPointF(0,0), 99999, ""):
        for ni in ci.getNodesInfo():
            cp = ni.getMappedPoint()
            gp = ni.getGlyphPoint(True)
            print(f"  Glyph ({gp.x():.0f}, {gp.y():.0f}) → Canvas ({cp.x():.0f}, {cp.y():.0f})")

Pattern 2 — Nudge all selected nodes up by one unit

from PythonQt.QtCore import QPointF
import fontlab as fl

canvas = fl.flWorkspace.instance().currentCanvas
if canvas:
    for ni in canvas.selectedNodes():
        p = ni.getGlyphPoint(False)
        ni.setGlyphPoint(QPointF(p.x(), p.y() + 1))
    fl.Update()

Pattern 3 — Print all auto-fixable audit issues for the current glyph

import fontlab as fl

# (Run after fl.flItems.notifyFontChanged() has been called
#  so the audit results are fresh.)
font  = fl.CurrentFont()
glyph = fl.CurrentGlyph()
layer = glyph.layers[0]

# Audit results are returned from the layer:
# for ai in layer.auditResults():   # when available
#     print(f"Issue: {ai.basic.title}")
#     print(f"  Report: {ai.basic.report}")
#     if ai.basic.canBeFixed:
#         ai.basic.fix()
#         print("  Auto-fixed!")

Constructors: flAuditInfo() flAuditInfo(flObject) flAuditInfo(flAuditInfo) flAuditInfo(FaBasic, QTransform)

Native bases: object

Captured native MRO: flAuditInfo, 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: Audit information. The captured declaration exposes glyphLocation, and the attributes basic, item. 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: flAuditInfo 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)
basic attribute Any The underlying audit record.
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)
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)
flObjectFlags attribute dict (shared captured text)
flag function (self, f: int) -> Any (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)
glyphLocation function (self, *args: Any, **kwargs: Any) -> Any Returns the location of this audit issue in glyph coordinates.
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 attribute Any (shared captured text)
item attribute Any The specific font model object (node, contour, shape) that this audit issue is about.
name attribute Any Object name (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)
restoreHistoryState function (self, history_ix: int) -> Any (shared captured text)
setFlag function (self, *args: Any, **kwargs: Any) -> 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)
tag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
type attribute Any Object type (shared captured text)
update function (self) -> Any (shared captured text)