Skip to content

fontlab.flCanvas

flCanvas

A canvas is one editor window in FontLab — a glyph editor, a metrics window, or a text window. When you're drawing nodes in a glyph editor, you're looking at a canvas. flCanvas gives you scripting access to that window: its zoom level, what's selected, what's visible, and the coordinate mapping between the screen and your font data.

You get the active canvas from the workspace:

ws     = flWorkspace.instance()
canvas = ws.getActiveCanvas()

Two coordinate systems — and why they matter

This is the most important conceptual thing to understand about flCanvas. There are two coordinate systems in play whenever a glyph is on screen:

  • Glyph (font unit) coordinates — the "real" coordinates stored in your font. A node at x=250, y=700 is at those coordinates in font units, regardless of how zoomed in you are.
  • Canvas (screen pixel) coordinates — where that node actually appears on screen, in pixels, taking zoom and scroll position into account.

When you're writing code that interacts with the visual display — checking what's under the mouse, doing hit testing, or snapping to canvas positions — you need to be able to move between these two systems. flCanvas provides the conversion methods:

  • glyphToCanvas(point) — takes a point in font units, returns where it appears on screen (in canvas pixels).
  • canvasToGlyph(point) — takes a screen pixel position, returns the corresponding font unit coordinate.

Example: if a node is at glyph position (250, 700), and you're zoomed to 200%, glyphToCanvas might return something like (480, 300) in screen pixels. canvasToGlyph does the reverse — if the mouse is at screen pixel (480, 300), canvasToGlyph tells you the glyph coordinate underneath it.

This matters for: - Hit testing — "did the user click near this node?" - Snap-to-point — "snap this to the nearest canvas grid point" - Custom drawing — drawing overlays or decorations that need to match glyph positions on screen

Common Scripting Patterns

from PythonQt.QtCore import QPointF
from fontlab import flWorkspace

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

# Check zoom level
print("Current zoom:", canvas.scale())   # e.g. 2.0 for 200%

# Convert: glyph coords → screen position
import fontlab as fl
node_pos_in_font = QPointF(250, 700)
screen_pos = canvas.mapToViewport(node_pos_in_font)

# Convert: mouse position → glyph coords
mouse_screen = canvas.mousePosition()
mouse_glyph  = canvas.mapFromViewport(mouse_screen)

# Get selected nodes
nodes = canvas.selectedNodes()
for ni in nodes:
    print(ni)

# Force a full redraw
canvas.refresh()

# Deselect everything
canvas.unselectAll()

# Ensure a specific glyph bounding box is visible
# canvas.ensureVisible(some_rect)

Tutorial

from PythonQt.QtCore import QPointF, QRectF
import fontlab as fl
from fontlab import flWorkspace, flCanvas

# ============================================================
# 1. Get the active canvas
# ============================================================
# Always check that a canvas is open before proceeding.
# Scripts that assume a canvas is open will crash otherwise.

ws     = flWorkspace.instance()
canvas = ws.getActiveCanvas()

if canvas is None:
    print("No glyph window is open. Please open a glyph to edit.")
    raise SystemExit

print("Got canvas:", canvas)
print("Is active:", canvas.isActiveCanvas())
print("Has focus:", canvas.isFocusedCanvas())

# ============================================================
# 2. Zoom level
# ============================================================
# scale() returns a float: 1.0 = 100%, 2.0 = 200%, etc.

current_zoom = canvas.scale()
print(f"\nCurrent zoom: {current_zoom * 100:.0f}%")

# Zoom to 400% centered on the origin
# canvas.zoomTo(QPointF(0, 0), 4.0, fl.ViewPointAlignment.Center)

# ============================================================
# 3. Coordinate mapping — the most important canvas skill
# ============================================================
# These two systems are always in play:
#   - Glyph (font unit) coords: stored in the font, e.g. x=250, y=700
#   - Canvas (screen pixel) coords: where that point appears on screen

# A specific point in glyph/font units:
glyph_pt = QPointF(250, 700)

# Where does it appear on screen right now?
# mapToViewport takes a canvas-space point and returns a screen pixel point.
# (For glyph coords, the canvas transform includes zoom + pan.)
screen_pt = canvas.mapToViewportF(glyph_pt)
print(f"\nGlyph point {glyph_pt} appears on screen at {screen_pt}")

# And the reverse: what glyph coords is this screen position?
back = canvas.mapFromViewport(screen_pt)
print(f"Screen point {screen_pt} maps back to glyph {back}")

# scaled() tells you how many screen pixels = 1 font unit at current zoom:
pixels_per_unit = canvas.scaled(1.0)
print(f"At current zoom: 1 font unit = {pixels_per_unit:.2f} screen pixels")

# ============================================================
# 4. Selection — reading what the user has selected
# ============================================================
# selectedNodes() gives you canvas-level proxies (flNodeInfo)
# for each selected node.

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

for ni in selected:
    # Each flNodeInfo knows where the node is on-screen
    print(f"  Node proxy: {ni}")

# Check if there's anything selected at all:
if canvas.haveSelectedNodes():
    print("Nodes are selected.")
else:
    print("No nodes selected.")

# Deselect everything:
canvas.unselectAll()
print("Deselected all.")

# ============================================================
# 5. Mouse position
# ============================================================
# mousePosition() returns canvas (screen pixel) coordinates.
# Use mapFromViewport to get the glyph-unit position under the cursor.

mouse_canvas = canvas.mousePosition()
mouse_glyph  = canvas.mapFromViewport(mouse_canvas)
print(f"\nMouse: screen={mouse_canvas}, glyph coords={mouse_glyph}")

# ============================================================
# 6. Built-in edit operations
# ============================================================
# These are equivalent to menu commands — they operate on
# whatever is currently selected in the canvas.

# Example: select all nodes first (requires glyph to be open)
# canvas.selectAll()

# Then apply an operation:
# canvas.operationReverseContours()   # reverse contour direction
# canvas.operationSimplify()          # remove redundant nodes
# canvas.operationToBeziers()         # convert to cubic beziers
# canvas.operationFlipHorizontal()    # mirror left/right

# ============================================================
# 7. Forcing a redraw
# ============================================================
# After making edits with other API calls, tell the canvas to
# refresh so the user sees the updated state.

canvas.refresh()       # standard full-canvas redraw
# canvas.refreshAll()  # heavier: clears all render caches too

# ============================================================
# 8. Highlight a region
# ============================================================
# Useful for drawing attention to a specific area — e.g.
# after finding a problem spot in the glyph.

problem_area = QRectF(200, 600, 100, 150)  # x, y, w, h in glyph units
canvas.highlight(problem_area)

# Remove the highlight when done:
# canvas.resetHighlight()

print("\nCanvas tutorial complete.")

Python canvas painters

appendPythonPainter(callback[, order]) -> int registers an overlay and returns a cleanup token. callback(painter, canvas) receives a borrowed QPainter whose transform has been reset for viewport coordinates. The default order is flCanvas.UnderOwner (0); flCanvas.OverOwner (1) draws above the owner. removePythonPainter(token) -> bool removes a callback from the same canvas and requests repainting.

import fontlab as fl

canvas = fl.flWorkspace.instance().getActiveCanvas()
if canvas is not None:
    def overlay(painter, callback_canvas):
        painter.drawText(12, 24, "Python overlay")

    painter_token = canvas.appendPythonPainter(overlay, fl.flCanvas.OverOwner)
    # Keep canvas and painter_token while the overlay is needed.
    # Later, during cleanup:
    canvas.removePythonPainter(painter_token)

Register and remove hooks on the GUI thread. Keep the token for cleanup; do not retain the borrowed painter beyond its callback or assume its wrapper remains valid. The native hook saves and restores painter state and guards against recursive painting. Exceptions are reported through Python's error output.

flCanvas constants

These constants are class attributes.

Key Native value Description
UnderOwner 0 Native enum value.
OverOwner 1 Native enum value.
SetMetricsZero flCanvas::SetMetricsZero Native enum value.
SetMetricsDefault flCanvas::SetMetricsDefault Native enum value.
SetMetricsAuto flCanvas::SetMetricsAuto Native enum value.

Constructors: flCanvas() flCanvas(flCanvas) flCanvas(flObject) flCanvas(id)

Native bases: object

Captured native MRO: flCanvas, 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: Canvas. The captured declaration exposes activateEditor, deactivateEditor, addTextBlock, clearTextBlocks, clearItems, appendDecorator, clearDecorators, hoveredItem, haveSelectedNodes, invertSelectedNodes, isActiveCanvas, isFocusedCanvas, ensureVisible, hide, currentHistoryState and hasHistoryState. 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: flCanvas 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
Listeners attribute dict
OverOwner attribute int
SetMetricsAuto attribute int
SetMetricsDefault attribute int
SetMetricsZero attribute int
UnderOwner attribute int
__init__ function (self, /, *args: Any, **kwargs: Any) -> None Initialize self. (shared captured text)
_finalize_smart_angles function (self) -> bool Finalises any pending smart angle changes.
acceptEvents function (self) -> int
activateEditor function (self, canvas_pos: QPointF) -> None
activatePreviewNodes function (self) -> Any Activates the preview node rendering layer — shows nodes as they would appear in a preview/proofing context.
addTextBlock function (self, arg0: flTextBlock) -> Any Adds a text block to the canvas.
addedToCanvas function (self, arg0: flCanvas) -> None
addedToWorkspace function (self, arg0: flWorkspace) -> Any Called when this canvas is added to the workspace.
adjustCanvasPosition function (self, arg0: QPointF) -> QPointF
adjustPosition function (self, double: Any) -> Any QPointF | double adjustPosition(QPointF | double)
appendDecorator function (self, arg0: flVisualItem, DecoratorOrder: Any) -> None
appendPythonPainter function (self, callback: Any, order: Any=...) -> Any AppendPythonPainter(callback, order=UnderOwner) -> token. callback(painter, canvas) draws in viewport coordinates; painter is valid only during the callback.
availableRect function (self) -> QRectF Returns the canvas rectangle that's available for drawing.
boundingRectOnCanvas function (self, *args: Any, **kwargs: Any) -> Any QRectF boundingRectOnCanvas(
canvas function (self) -> flCanvas
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)
clearDecorators function (self) -> Any
clearFlag function (self, f: int) -> Any (shared captured text)
clearFlags function (self) -> Any (shared captured text)
clearItems function (self) -> Any
clearSurfaces function (self) -> Any Clears all render surfaces (the internal caches FontLab uses for fast drawing).
clearTextBlocks function (self) -> Any Removes all text blocks from this canvas.
clone function (self, *args: Any, **kwargs: Any) -> Any Clone the object (shared captured text)
cloneObject function (*args: Any, **kwargs: Any) -> Any (shared captured text)
collectChangedRects function (self) -> Any Gathers the dirty regions that need redrawing — used internally by the rendering pipeline.
contain function (self, canvas_pos: QPointF) -> bool
containsItem function (self, arg0: flVisualItem) -> bool
createFrame function (self, list: fgSymbolList, position: QPointF) -> fgSymbolList Creates a text frame at the given canvas position.
createInstance function () -> flCanvas Creates a new canvas 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)
deactivateEditor function (self) -> Any
deactivatePreviewNodes function (self) -> Any Deactivates the preview node layer, returning to normal node rendering.
distanceTo function (self, arg0: QPointF) -> float
ensureVisible function (self, total_cover: Any=...) -> Any Scrolls and/or zooms the canvas to make the given point or rectangle visible.
flObjectFlags attribute dict (shared captured text)
flag function (self, f: int) -> Any (shared captured text)
getHighlight function (self) -> Any QRectF/Nothing getHighlight()
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)
getScaleTo function (self, arg0: flShapeInfo) -> float Calculates what zoom scale would be needed to fit a given shape in the current viewport.
hasChanges attribute Any (shared captured text)
hasHistoryState function (self, history_ix: int) -> Any (shared captured text)
hasHistoryStates attribute Any (shared captured text)
haveCanvas function (self) -> bool
haveEditor function (self, canvas_pos: QPointF) -> bool
haveHoveredItem function (self) -> bool Returns True if the mouse cursor is hovering over an interactive item.
haveObject function (*args: Any, **kwargs: Any) -> Any (shared captured text)
haveSelectedNodes function (self) -> bool Returns True if any nodes are currently selected.
hide function (self) -> Any
highlight function (self, arg0: QRectF) -> Any Highlights a rectangular region of the canvas with a visual indicator — useful for drawing attention to a specific area.
historyStates function (self, accepted_state: bool) -> Any (shared captured text)
hovered attribute Any
hoveredItem function (self) -> flVisualItem Returns the visual item the cursor is currently hovering over.
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)
instanceAcceptEvents function () -> int
instanceType function () -> int Returns the canvas type code.
invertSelectedNodes function (self, *args: Any, **kwargs: Any) -> Any Inverts the selection state for the given nodes (selected becomes unselected, and vice versa).
invselect function (self) -> Any
isActiveCanvas function (self) -> bool Returns True if this is the currently active canvas.
isChanged attribute Any (shared captured text)
isEqual function (self, arg0: flObject) -> Any (shared captured text)
isFocusedCanvas function (self) -> bool Returns True if this canvas has keyboard focus.
isNull attribute Any (shared captured text)
isPresent attribute Any (shared captured text)
isReleased attribute Any (shared captured text)
isSelectable function (self) -> bool
isStableSelect function (self) -> bool
isValid attribute Any (shared captured text)
itemScale function (self) -> float
locked attribute Any
mapCanvasDistanceToItem function (self, arg0: QPointF) -> QPointF
mapCanvasToItem function (self, QRectF: Any) -> Any QPointF | QRectF mapCanvasToItem(QPointF | QRectF)
mapDeltaFromGlobalToCanvas function (self, arg0: QPoint) -> QPointF Converts a pixel delta (a movement amount) from global screen space to canvas-space units.
mapFromGlobal function (self, QPoint: Any) -> Any QRectF | QPointF mapFromGlobal(QRect | QPoint)
mapFromViewport function (self, QPoint: Any) -> Any QRectF | QLineF | QPointF mapFromViewport(QRectF | QRect | QLineF | QPointF | QPoint)
mapItemToCanvas function (self, QRectF: Any) -> Any QPointF | QRectF mapItemToCanvas(QPointF | QRectF)
mapToGlobal function (self, arg0: QPointF) -> QPointF Converts from canvas coordinates to global screen coordinates.
mapToViewport function (self, QPoint: Any) -> Any QPolygonF | QRect | QPoint mapToViewport(QPolygonF | QRect | QPoint)
mapToViewportF function (self, QLineF: Any) -> Any QPointF | QLineF mapToViewportF(QPointF | QLineF)
metricStep function (self) -> float
modelProducer attribute Any The producer object that controls what this canvas shows — the connection between the canvas and the font data.
mousePosition function (self) -> QPointF Returns the current mouse cursor position in canvas (screen pixel) coordinates.
mousePressed function (self) -> bool Returns True if a mouse button is currently pressed.
move function (self, arg0: QPointF) -> None
name attribute Any Object name (shared captured text)
opacity attribute Any
operationAdjustMetrics function (self, delta: float, percent: bool) -> Any Nudges the sidebearings by delta — absolute units if percent=False, percentage if percent=True.
operationAlign function (self, *args: Any, **kwargs: Any) -> Any Aligns selected items (left, right, top, bottom, center).
operationBeauty function (self, bool: Any) -> Any Applies G2 harmonisation (beauty) to the selection.
operationBreak function (self, notify: bool, alone_selected: bool) -> bool Breaks open the selected contour(s) at the selected nodes — useful for creating open paths.
operationCopyToMask function (self, *args: Any, **kwargs: Any) -> Any Copies the current selection to the mask layer.
operationDecompose function (self) -> bool Decomposes composite glyphs (components) into plain contours.
operationFlipHorizontal function (self) -> Any Flips the current selection horizontally (mirror left/right).
operationFlipVertical function (self) -> Any Flips the current selection vertically (mirror up/down).
operationGenius function (self, bool: Any) -> Any Toggles Genius mode on/off for the selection.
operationHarmonize function (self) -> Any Smooths G2 continuity on selected nodes — makes curve transitions more mathematically smooth.
operationImprove function (self) -> Any Runs the "improve" (beautify) operation on selected nodes.
operationJoin function (self) -> Any Joins open contour endpoints together.
operationNoServant function (self) -> Any Removes servant (symmetry) constraints from selected nodes.
operationPrepare function (self, *args: Any, **kwargs: Any) -> Any (flModelProducer, QList<flNodeInfo> selection, flShapeInfo, flGlyphInfo)/Nothing operationPrepare(bool allow_all_contours, bool allow_all_nodes = false)
operationReverseContours function (self) -> Any Reverses the direction of selected contours (clockwise becomes counter-clockwise).
operationRotate180 function (self) -> Any Rotates the selection 180 degrees.
operationRotate90 function (self) -> Any Rotates the selection 90 degrees clockwise.
operationServantX function (self, bool: Any) -> Any Toggles the X-axis servant (symmetry) constraint.
operationServantY function (self, bool: Any) -> Any Toggles the Y-axis servant (symmetry) constraint.
operationSetMetrics function (self, mode: int) -> Any Applies a metrics preset to the current glyph.
operationSimplify function (self) -> Any Simplifies the selected contours by removing redundant nodes.
operationSmartAngle function (self, bool: Any) -> Any Toggles smart angle mode for the selection.
operationSmooth function (self, bool: Any) -> Any Toggles smooth node mode.
operationToBeziers function (self) -> Any Converts the current selection to cubic Bézier curves (PostScript-style).
operationToCurve function (self) -> Any Converts selected nodes to smooth curve nodes.
operationToLine function (self) -> Any Converts selected nodes to sharp corner nodes with straight segments.
operationToSplines function (self) -> Any Converts the selection to quadratic splines (TrueType-style).
owner attribute Any
paint function (self, *args: Any, **kwargs: Any) -> Any
paper attribute Any The canvas background ("paper") settings — background colour, guides display, etc.
placeAICB function (self, position: QPointF, mime_data: Any) -> bool Places artwork from an Adobe Illustrator clipboard file or MIME data at the given canvas position.
placeArtwork function (self, position: QPointF, urls_list: list[QUrl]) -> bool Places artwork from a list of file URLs at the given canvas position.
popupHost function (self) -> Any The popup host widget for this canvas (used for context menus and floating panels).
preview function (self) -> Any
producer function (self) -> flObject Returns the model producer controlling what this canvas displays.
propertyNames function (self, *args: Any, **kwargs: Any) -> Any PropertyNames(): sorted snapshot of dynamic property keys (shared captured text)
rectToUpdate function (self) -> QRect The rectangle scheduled for the next update.
refCnt attribute Any Object references count (shared captured text)
referencePoint function (self) -> QPointF
refresh function (self) -> Any Redraws the current view.
refreshAll function (self) -> Any Full redraw of the entire canvas — clears all cached rendering and redraws from scratch.
refreshCanvasRect function (self, arg0: QRectF) -> Any Invalidates a specific rectangle in canvas (screen pixel) coordinates.
refreshGlyphRect function (self, arg0: QRectF) -> Any Invalidates a specific rectangle in glyph coordinates.
regionToUpdate function (self) -> QRegion The region scheduled for the next update.
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)
removeDeadSmartAngles function (self) -> Any Removes invalidated smart angle markers from the canvas.
removeDecorator function (self, arg0: flVisualItem) -> None
removeItem function (self, arg0: flVisualItem) -> Any Removes a visual item from the canvas.
removePythonPainter function (self, token: Any) -> bool
removeTextBlock function (self, arg0: flTextBlock) -> Any Removes a text block from the canvas.
removedFromCanvas function (self) -> Any
removedFromWorkspace function (self, arg0: flWorkspace) -> Any Called when this canvas is removed from the workspace.
resetHighlight function (self) -> Any Removes the current highlight.
restoreHistoryState function (self, history_ix: int) -> Any (shared captured text)
scale function (self) -> float Returns the current zoom scale factor as a number.
scaled function (self, d: float) -> float Scales a canvas-space value by the current zoom factor.
select function (self) -> Any
selectNode function (self, arg0: flNodeInfo) -> Any Adds a single node to the current selection.
selectNodes function (self, *args: Any, **kwargs: Any) -> Any Selects a set of nodes, adding them to the current selection.
selected attribute Any
selectedNodes function (self) -> list[flNodeInfo] Returns info for all selected nodes as flNodeInfo objects.
selection function (self) -> list[flVisualItem] Returns all currently selected visual items (shapes, nodes, etc.).
setCursor function (self, arg0: QCursor) -> Any Sets the canvas cursor to a Qt cursor object.
setCursorId function (self, CursorId: Any) -> Any Sets the canvas cursor using a FontLab CursorId constant.
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)
setSelectedNodes function (self, *args: Any, **kwargs: Any) -> Any Replaces the current node selection entirely.
show function (self) -> Any
slantTransform function (self, glyph_info: flGlyphInfo) -> QTransform Returns the italic slant transform for the given glyph at the current view settings.
tag function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
textBlocks function (self) -> list[flTextBlock] Returns all text block items currently on this canvas.
transform attribute Any
type attribute Any Object type (shared captured text)
unselect function (self) -> Any
unselectAll function (self) -> bool Deselects everything — nodes, shapes, guidelines.
unselectAllNodes function (self) -> bool Deselects only nodes, leaving shape selection intact.
update function (self) -> Any (shared captured text)
updateCanvasRectA function (self, arg0: QRectF) -> Any Alternative canvas rect update path.
updateMousePos function (self, arg0: QPoint) -> Any Updates the internally tracked mouse position.
updateScreenRect function (self, arg0: QRectF) -> Any Marks a canvas-coordinate rectangle as dirty (needs repaint).
updateScreenRegion function (self, arg0: QRegion) -> Any Marks a screen region (by Qt region) as needing repaint.
updateViewRect function (self) -> Any Recalculates the visible view rectangle after zoom or scroll changes.
updateViewport function (self) -> Any Triggers a viewport refresh.
viewPoint attribute Any The current scroll/pan position — the canvas origin in viewport coordinates.
viewPort attribute Any The Qt viewport widget this canvas renders into.
viewPortHasFocus function (self) -> bool Returns True if the viewport widget currently has keyboard focus.
viewPortRect function (self) -> QRect Returns the viewport widget's rectangle in screen pixel coordinates.
viewRect function (self) -> QRectF Returns the currently visible rectangle in canvas (screen pixel) coordinates.
viewTransform attribute Any The full view transform, including zoom scale and italic slant.
visible attribute Any
workspace attribute Any The workspace that owns this canvas.
zoomTo function (self, canvas_rect: QRectF) -> Any Zooms to a specific point at a specific scale, or zooms to fit a given rectangle.
zoomToReaded function (self) -> Any Restores the previously saved zoom level.