Skip to content

fontlabapp.qt.painting.editor

editor

Paint over FontLab's glyph editor: one overlay per visible glyph window.

What it does: EditorPainters lets a script register painter callbacks. FontLab calls each callback once per laid-out glyph, after the native glyph layer is painted. Each call gets a PaintContext with the glyph-to-canvas map, the canvas-to-view map and a ready QPainter.

How to use: painters = EditorPainters(qt, fontlab, error_sink=sink) where qt is the PythonQt module and fontlab is the FontLab module. token = painters.register("after_native_layer", callback) starts the work. painters.remove(token) stops one painter. painters.close() stops all of them. After the last painter is gone, the poll timer stops and every overlay is detached. layer_filter is "active" (default), "inactive" or "all". document_id limits a painter to one font (package.id). Inside the callback, draw with context.painter and map glyph units to pixels with context.glyph_to_canvas then context.canvas_to_view.

Native facts (FontLab 9.0.9780, measured by Glyport; evidence glyport-ui/probe-editor-paint.json): - The native canvas paints the viewport from an event filter and fills it opaquely. A Python pre-paint leaves no visible pixel. Only painting after the native layer works, so before_native_layer raises ValueError here. - A transparent child widget of the viewport paints after the native canvas. This module uses one such child per viewport. - A glyph unit maps to a pixel as the native glyph paint does: glyph transform, then text-block transform, to canvas units, then flCanvas.mapToViewportF to pixels. Kerning is already in the glyph transform.

Why this design: - New glyph windows appear at any time. A 250 ms poll finds them. Hidden (closed) tabs stay alive, so only visible windows get an overlay. - Callback errors go to error_sink. Nothing raises out of paintEvent: an exception there, with a QPainter active, crashes FontLab (AGENTS.md landmines). - The painter is saved and restored around every callback. One plugin cannot leak pen, brush or transform state into the next. - Teardown disconnects each signal before deleteLater. A widget deleted with live Python slot targets crashes FontLab (double delete in PythonQtSignalReceiver). - Maths come from fontlabapp.contours.affine. Native widget lists come through fontlabapp.qt.safe.qt_list (GC off during conversion).

Compare fontlabapp.qt.painting.drawing.Drawing: that class paints one given widget. This module is a registry over all glyph windows. Glyport's fontlab_glyport.drawing.editor subclasses it. The subclass adds the Glyphs UnsupportedCapability refusal for the before-native phase and the layer_resolver wiring.

Classes

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
AFTER_NATIVE_LAYER attribute
BEFORE_NATIVE_LAYER attribute
ErrorSink attribute (shared captured text)
GLYPH_WINDOW_CLASS attribute
LAYER_FILTERS attribute
POLL_MS attribute (shared captured text)