fontlab_glyport.drawing.context
context
The current Cocoa graphics state over a QPainter (R032).
Cocoa draws through an implicit current context with a transform (CTM), a
fill and stroke colour, and a save/restore stack. Here that state lives in
Python: affine transforms are 6-tuples (m11, m12, m21, m22, tx, ty)
composed with plain arithmetic, and a QTransform is built only when a
shape is painted (no arithmetic on PythonQt wrappers; unary minus on them
crashes FontLab). The base transform maps the drawing space (glyph units, or
a view's y-up coordinates) to widget pixels.
A context exists only inside a scope (paint_scope for editor painters,
view_scope for NSView.drawRect_). State operations outside one raise
RuntimeError; path painting with no destination is a no-op, as in Cocoa.
A retained painter cannot paint after its callback.
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 |
|---|---|---|---|
current |
function | () -> GraphicsContext |
The active context; outside a scope there is none (RuntimeError). |
optional_current |
function | () -> GraphicsContext | None |
A nil Cocoa context: geometry works, painting has no destination. |
paint_scope |
function | (qt: Any) |
Factory for <code>PluginEnv.paint_scope</code>: glyph units -> widget pixels. |
reporter_view_scope |
function | (scale: float) |
View hooks use the widget bounds in Cocoa points, independent of glyph origin. |
scope |
function | (qt: Any, painter: Any, base: Affine, *, flipped: bool=False) -> Iterator[GraphicsContext] |
Make a context current around <code>painter</code> (saved and restored). |
view_scope |
function | (qt: Any, painter: Any, height: float, *, flipped: bool) |
<code>NSView.drawRect_</code>: y-up bounds unless the view is flipped. |