Skip to content

fontlabapp.vfjo._edit

_edit

Navigate and edit Objects in place, and paste them into a font.

What: layers, elements, contours and anchors yield boxes; edit_nodes, move, scale, rename, set_width and add_suffix change the data in place and return it; paste sends it to json_data.paste_glyphs or json_data.paste_shapes.

How: move and scale apply one map x' = sx*x + tx, y' = sy*y + ty and keep the data consistent. An element with a transform or a component gets a new transform (offsets and scales are composed; existing keys stay, new xOffset/yOffset/xScale/ yScale keys are added only at non-default values) and its nodes stay. Other elements get new node coordinates, and their nested elements follow the same rule. Anchors, guideline positions (vertical maps x, horizontal maps y, center maps both), hint points and hint thickness (vertical by sx, horizontal by sy) follow. Numbers are rounded to 3 decimals; whole numbers stay int.

Limits: guideline vector directions are not changed by a non-uniform scale. edit_nodes refuses callbacks that change a contour's point count, because hints address nodes by point index. Nothing here touches a font until paste.

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
add_suffix function (obj: Objects, suffix: str, *, drop_unicodes: bool=True) -> Objects Append <code>suffix</code><code> to every glyph name and return </code><code>obj</code>.
anchors function (obj: Any) -> Iterator[_Data] Yield the anchor boxes of all layers.
contours function (obj: Any) -> Iterator[_Data] Yield the contour boxes (coordinates before element transforms).
edit_nodes function (obj: Any, fn: Callable[[Node], Node | None]) -> Any Replace each node by <code>fn(node)</code><code> (</code><code>None</code><code> keeps it); return </code><code>obj</code>.
elements function (obj: Any) -> Iterator[_Data] Yield the element boxes, nested <code>elementData.elements</code> included.
layers function (obj: Any) -> Iterator[_Data] Yield the layer boxes of all glyph items and layer items.
move function (obj: Any, dx: Number, dy: Number, *, anchors: bool=True) -> Any Move outlines, components, anchors, guidelines and hints by <code>(dx, dy)</code><code>; return </code><code>obj</code>.
paste function (objs: Objects, font: Any=None, *, on_conflict: str='rename', **kw: Any) -> json_data.Pasted Paste <code>objs</code><code> into </code><code>font</code> (default: the current font), with Undo.
rename function (obj: Objects, rename: Mapping[str, str] | Callable[[str], str]) -> Objects Rename glyph items from a mapping (missing names stay) or a function; return <code>obj</code>.
scale function (obj: Any, sx: Number, sy: Number | None=None, *, origin: tuple[Number, Number]=(0, 0), anchors: bool=True, w… Scale by <code>sx</code><code> (and </code><code>sy</code><code>, default </code><code>sx</code><code>) around </code><code>origin</code><code>; </code><code>widths</code><code> scales </code><code>advanceWidth</code>.
set_width function (obj: Any, width: Number | Callable[[Number], Number]) -> Any Set every layer's <code>advanceWidth</code><code> to a number or </code><code>width(old&#95;width)</code><code>; return </code><code>obj</code>.