fontlab.flLayerInfo
flLayerInfo
Canvas proxy for a layer.
What is flLayerInfo?
flLayerInfo is the canvas-aware wrapper around an flLayer. While an flLayer stores the model data (shapes, guidelines, metrics, nodes in font units), an flLayerInfo knows where all of that content is on screen at the current zoom level. Its primary purpose is providing the brectOnCanvas() method — the bounding rectangle in screen pixels that contains everything on the layer.
You typically get an flLayerInfo from the canvas engine rather than creating one yourself. It is used in tool code when you need to know the full on-screen footprint of the active layer — for example, to draw an overlay, zoom to fit, or calculate a repaint region.
Tutorial
flLayerInfo is most useful when you need the full on-screen bounds of a layer's content — for example, to draw a custom overlay frame or to check whether anything is visible in the current viewport.
import fontlab as fl
from fontlab import flLayerInfo
# ============================================================
# Get the canvas bounding rect of the active layer.
# This is the screen rectangle that encloses all shapes.
# ============================================================
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
# Get a layer info — create one and attach the layer:
layer = gi.glyph.layers[0]
li = flLayerInfo.createInstance()
li.layer = layer
bbox_canvas = li.brectOnCanvas()
print(f"Layer canvas bounds:")
print(f" x: {bbox_canvas.left():.1f} .. {bbox_canvas.right():.1f}")
print(f" y: {bbox_canvas.top():.1f} .. {bbox_canvas.bottom():.1f}")
print(f" width: {bbox_canvas.width():.1f}px height: {bbox_canvas.height():.1f}px")
# ============================================================
# Use the bounding rect to check if the glyph is in the
# current viewport (e.g. for selective rendering).
# ============================================================
viewport = canvas.rect() # viewport rectangle in canvas coords
if bbox_canvas.intersects(viewport):
print("Layer is visible in the current viewport.")
else:
print("Layer is scrolled out of view.")
Common Scripting Patterns
Compute the layer bounds in glyph units (not canvas)
import fontlab as fl
font = fl.CurrentFont()
glyph = font['O']
layer = glyph.layers[0]
# The model layer has a bounding box in glyph units:
shapes = layer.shapes
if shapes:
from PythonQt.QtCore import QRectF
total = shapes[0].boundingBox
for s in shapes[1:]:
total = total.united(s.boundingBox)
print(f"'O' layer bounds (glyph units):")
print(f" ({total.left():.0f}, {total.bottom():.0f}) → "
f"({total.right():.0f}, {total.top():.0f})")
Inherited binding members: flSearchInfo.
Constructors: flLayerInfo() flLayerInfo(flObject) flLayerInfo(flLayerInfo) flLayerInfo(flLayer, QTransform) flLayerInfo(flLayer, flObject glyph_info, QTransform)
Native bases: object
Captured native MRO: flLayerInfo, 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:
Layer information. The captured declaration exposes layer, glyphInfo, combine, dist, transform and brectOnCanvas. 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: flLayerInfo 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) |
brectOnCanvas |
function | (self) -> QRectF |
Returns the canvas-space bounding rectangle of everything on this layer — all shapes, their composites, and any bounds they contribute. |
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) |
createInstance |
function | () -> flLayerInfo |
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) |
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 (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 |
attribute | Any |
(shared captured text) |
layer |
attribute | Any |
The underlying flLayer model object. |
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) |