Skip to content

fontlabapp.components.creation · declarations 001

Back to fontlabapp.components.creation

COMPONENT_KEYS module-attribute

COMPONENT_KEYS

NO_PROTOTYPE module-attribute

NO_PROTOTYPE

STYLE_DEFAULTS module-attribute

STYLE_DEFAULTS

add_component

add_component(layer: Any, shape: Any) -> Any

Add one shape from build_components to layer; call it INSIDE mutate.

Return the shape that the layer holds now (flLayer.addShape returns it; a None answer returns shape). Raise RuntimeError unless the layer holds exactly one more component of the same base afterwards.

build_components

build_components(package: Any, target: str, wanted: Sequence[NewComponent], facts: AutoFacts, *, cache: dict[str, Any] | None = None) -> tuple[Any, ...]

Return one detached plain component per item of wanted; call it BEFORE history.commit.

target: the existing glyph that will receive them (for the texts). facts: a fresh history.scan_auto_facts(package). Every refusal raises ValueError("<target>: kept; ...") before any change. A native failure while cloning raises RuntimeError that says nothing was added to the font (the clones are detached). Nothing wanted returns () with no native call. Pass one empty cache dict per Apply to reuse the prototype across targets in the same package. Discard the cache after Apply; a later edit can change the prototype. A missing prototype is cached too.

prototype

prototype(package: Any, facts: AutoFacts) -> Any | None

Return the first component that qualifies as a prototype (module text), or None.

Only the component users in facts.users are read, in name order, and only their non-auto layers. The VFJ elements must match the layer shapes one to one (count, and the base of each component), else the layer is skipped. Fetch each glyph VFJ at most once per call, across all layers.