fontlab.flSearchInfo
flSearchInfo
Base canvas info object.
What is flSearchInfo?
flSearchInfo is the root of the canvas info class hierarchy. Every object that describes where something is on the FontLab canvas — a shape, a contour, a node — ultimately inherits from flSearchInfo. This base class provides two things: a link back to the rendered glyph context (glyphInfo) and a dist value used when searching for the nearest feature to a mouse position.
You will rarely create flSearchInfo objects directly. Instead you receive them (or their subclasses) as results from canvas queries like flGlyphInfo.getNearbyContours() or canvas.selectedNodes(). Understanding this base class helps you write tool code that works generically across different info types.
Tutorial
flSearchInfo is primarily useful through its dist property, which tells you how far a query result was from the search point. This is the basis of nearest-feature tools.
from PythonQt.QtCore import QPointF
import fontlab as fl
# ============================================================
# Use getNearbyContours to find all contours within a radius,
# then sort them by the dist property to find the closest one.
# This is the pattern used by snap and knife tools.
# ============================================================
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
# Simulate a mouse position on the canvas:
mouse_pos = QPointF(200, 400)
# Get all contours within 100 canvas pixels of the mouse:
nearby = gi.getNearbyContours(mouse_pos, 100.0, "")
if not nearby:
print("No contours nearby.")
else:
# Sort by dist (closest first):
nearby_sorted = sorted(nearby, key=lambda ci: ci.dist)
closest = nearby_sorted[0]
print(f"Closest contour dist={closest.dist:.1f} px")
print(f" Canvas bounds: {closest.brectOnCanvas()}")
# All results share the same glyphInfo:
print(f" Glyph: {closest.glyphInfo.name}")
Common Scripting Patterns
Check that all nearby results belong to the same glyph
from PythonQt.QtCore import QPointF
import fontlab as fl
ws = fl.flWorkspace.instance()
gi = ws.getActiveCanvas().activeGlyphInfo() if ws.getActiveCanvas() else None
if gi:
nearby = gi.getNearbyContours(QPointF(0, 0), 9999, "")
for ci in nearby:
# Every result's glyphInfo should point back to the same glyph:
assert ci.glyphInfo.name == gi.glyph.name
print(f"All {len(nearby)} contour results belong to '{gi.glyph.name}'")
Constructors: flSearchInfo() flSearchInfo(flObject) flSearchInfo(flSearchInfo) flSearchInfo(QTransform) flSearchInfo(QTransform, flObject glyph_info)
Native bases: object
Captured native MRO: flSearchInfo, 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:
Search information. The captured declaration exposes combine, and the attributes dist, glyphInfo, 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: flSearchInfo 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) |
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 |
Multiplies the object's internal transform by transform. |
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 |
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) |
glyphInfo |
attribute | Any |
Glyph info |
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) |
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) |
transform |
attribute | Any |
Transform matrix (shared captured text) |
type |
attribute | Any |
Object type (shared captured text) |
update |
function | (self) -> Any |
(shared captured text) |