Skip to content

fontlabapp.contours.transform.model · declarations 001

Back to fontlabapp.contours.transform.model

Affine module-attribute

Affine

FIT_MARGIN module-attribute

FIT_MARGIN

ORIGIN_NEAR module-attribute

ORIGIN_NEAR

XY module-attribute

XY

bakes

bakes(shape: Any) -> bool

True when FontLab's own layer transform writes the new nodes into the shape.

FontLab's rule (fllayer.cpp:6957-6978): an own contour shape whose transform only moves, whose outline data no other shape shares and that includes no other shapes gets new node positions. Every other shape (components, shared data, scaled shapes) keeps its nodes and gets the composed shape transform. This function follows that rule and also composes a shape with no contours, which FontLab would bake. That is harmless: such a shape has no nodes to write.

fit

fit(box: Any, width: float, height: float) -> Affine

Map font units in box (y up) into a width × height widget (y down).

layer_outline

layer_outline(layer: Any) -> list[list[Point]]

Every contour of the layer as (x, y, on) lists, placed by its shape transform.

mapped

mapped(contours: list[list[Point]], matrix: Affine) -> list[list[Point]]

The same contours after matrix.

outline_path

outline_path(contours: list[list[Point]]) -> Any

QPainterPath of closed contours: cubic for two controls, quadratic for one.

panel_type

panel_type() -> type

Return the TransformPanel base class (a PythonQt QDialog).

It is OutlinePanel (fontlabapp.contours.panel.model.panel_type()) with an OutlinePreview below the form. The class loads PythonQt, so call this inside FontLab only. Subclass it like OutlinePanel and add the hook preview_matrix(layer) that returns (matrix, guide y or None). See fontlabapp.contours.transform.ui.TransformPanel.

transform_changes

transform_changes(layer: Any, matrix: Affine, anchors: bool, note: str) -> list[Change]

Rows for one layer: the shapes, then the anchors when asked.

Shape edit: ("shapes", [(shape, new shape transform, bakes, probe)]); probe is (first node, its expected glyph position) for a baked shape. Anchor edit: ("anchors", [(anchor, x, y)]). An anchor that would move onto 0, 0 blocks Apply: FontLab cannot redo that move (fl#8527). The rule is anchor_writer.on_origin: the new point counts with the ORIGIN_NEAR rounding tolerance, the old point only when it is exactly 0, 0. So an anchor at (0.3, 0) that moves to (0, 0) is refused; only an anchor that is exactly on the origin already does not count.