Skip to content

fontlab.flPaper

flPaper

Metrics view background layer.

What is flPaper?

The "paper" is the background layer of the metrics view canvas. It is the model object that manages the ordered list of all flGlyphInfo objects currently being rendered — the glyphs that are shown in the text string of the metrics/spacing view. It also tracks which glyph is the "active" one (the one whose outline nodes are currently visible and editable).

In typical scripting you access the paper through the canvas rather than creating one directly. The paper is your gateway to understanding what is being displayed: which glyphs are on screen, which is selected for editing, and what the combined bounding rectangle of all displayed content is.

Tutorial

flPaper is the object you use to ask "what is on screen right now, and which glyph is active?" in the metrics view.

import fontlab as fl

# ============================================================
# Access the paper of the current metrics/glyph window canvas
# and inspect what is displayed.
# ============================================================

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

paper = canvas.paper
if paper is None or not paper.hasContent():
    print("Paper has no content — type something in the metrics view.")
    raise SystemExit

print(f"Paper has content: {paper.hasContent()}")
print(f"Active glyph open: {paper.hasActive()}")

# Get the bounding box of all displayed glyphs in canvas units:
bounds = paper.glyphsBoundRect()
print(f"All-glyphs canvas bounds: "
      f"({bounds.left():.0f}, {bounds.top():.0f}) → "
      f"({bounds.right():.0f}, {bounds.bottom():.0f})")

# Get the active glyph info:
if paper.hasActive():
    gi = paper.activeGlyphInfo()
    print(f"Active glyph: '{gi.name}'")

# ============================================================
# Iterate all glyphs currently displayed on the paper.
# ============================================================

# The paper's glyphInfoAt(i) API requires knowing the count.
# Use the canvas's glyphInfos() shortcut if available,
# otherwise iterate with a try-except:
print("\nGlyphs on paper:")
i = 0
while True:
    try:
        gi = paper.glyphInfoAt(i)
        if gi is None:
            break
        print(f"  [{i}] '{gi.name}'")
        i += 1
    except Exception:
        break

# ============================================================
# Programmatically open a glyph for editing in the metrics view.
# ============================================================

font  = paper.package()
glyph = font['O']
new_gi = paper.setActiveGlyph(glyph)
if new_gi:
    print(f"\nOpened '{new_gi.name}' for editing.")
    fl.Update()

Common Scripting Patterns

Check if a specific glyph is currently in the text string

import fontlab as fl

ws     = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
if canvas:
    paper = canvas.paper
    font  = fl.CurrentFont()
    if paper and font:
        gi = paper.getGlyphInfo(font['a'])
        if gi:
            print("'a' is on the paper.")
        else:
            print("'a' is not currently displayed.")

Zoom the canvas to show all glyphs

import fontlab as fl

ws     = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
if canvas:
    paper = canvas.paper
    if paper and paper.hasContent():
        rect = paper.glyphsBoundRect()
        canvas.centerOnRect(rect)   # or use canvas.zoomToRect(rect)
        fl.Update()

Constructors: flPaper() flPaper(flPaper) flPaper(flObject) flPaper(QBrush)

Native bases: object

Captured native MRO: flPaper, 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: A paper object holding glyph information. The captured declaration exposes the methods activeGlyphInfo, getGlyphInfo, glyphInfoAt, glyphsBoundRect, hasActive, hasContent, glyph, setActiveGlyph and setPaperGlyph. It is created as flPaper(), flPaper(flPaper), flPaper(flObject) or flPaper(QBrush). It also carries the shared object members name, id, type, isValid, release and remove.

Source: FontLab Proteus API documentation

Source: generated/fontlab.py: flPaper 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)
activeGlyphInfo function (self) -> flObject Returns the flGlyphInfo of the glyph that is currently active — the one shown with its outline nodes.
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)
createInstance function () -> flPaper Creates a detached flPaper instance.
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)
getGlyphInfo function (self, arg0: flObject) -> flObject Given an flGlyph, returns its flGlyphInfo on this paper if it is currently displayed.
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)
glyph function (self) -> flObject Returns the main flGlyph currently displayed (the active glyph, if set).
glyphInfoAt function (self, index: int) -> flObject Returns the flGlyphInfo at position index in the paper's ordered list.
glyphsBoundRect function (self) -> QRectF Returns the bounding rectangle in canvas units that encloses all displayed glyphs.
hasActive function (self) -> bool Returns True if one of the displayed glyphs is currently active (its outline nodes are visible and editable).
hasChanges attribute Any (shared captured text)
hasContent function (self) -> bool Returns True if the paper has at least one glyph to display.
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)
package function (self) -> flObject Returns the flPackage (font file) whose glyphs are displayed on this paper.
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)
setActiveGlyph function (self, glyph: flObject) -> flObject Sets which glyph is open for outline editing (shows its nodes).
setFlag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
setPaperGlyph function (self, glyph: flObject) -> flObject Sets which glyph is the main (central) glyph displayed on the paper.
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)