Skip to content

fontlabapp.glyphs.creation · declarations 001

Back to fontlabapp.glyphs.creation

CREATE_UNDO_TEXT module-attribute

CREATE_UNDO_TEXT

LayerKey module-attribute

LayerKey

REBUILD_LABEL module-attribute

REBUILD_LABEL

SHOWN_CANDIDATES module-attribute

SHOWN_CANDIDATES

UNDO_TEXT module-attribute

UNDO_TEXT

auto_candidates

auto_candidates(package: Any, facts: AutoFacts, names: Iterable[str]) -> dict[str, tuple[str, ...]]

Map each new name to the automatic glyphs that FontLab may rebuild when it appears.

A candidate owns a layer with autoLayer and no own recipe (a default-recipe automatic layer), and its name shares a whole dotted suffix segment with the new name (e.sc and eacute.sc; not x.scale). A new name without a dot gets no candidates. Names without candidates are left out. Only the owners in facts.autos are read.

Scope: this is a pre-write HEURISTIC for the consent tick, not a prediction. Adding ANY glyph re-resolves every automatic layer of the font: Add Glyph passes every glyph id to _process_update_auto_layers (flhistorycontroller.cpp:1910-1921) and UpdatePackageData::updateAutoLayers walks every auto layer (update_components.cpp:716-790). So any new name, dotted or not (acute and Aacute), can change any default-recipe automatic glyph. The guard is the after-write auto_changes check. This is a reading of the source, not a measurement.

auto_changes

auto_changes(package: Any, before: Mapping[LayerKey, tuple[Any, ...]]) -> list[str]

Return one text per automatic layer whose signature changed or that is gone.

auto_signatures

auto_signatures(package: Any, facts: AutoFacts) -> dict[LayerKey, tuple[Any, ...]]

Return the signature of every automatic layer of the font, before the write.

FontLab resolves automatic composites by name; a new glyph name can change how one resolves. auto_changes compares these signatures.

create_glyphs

create_glyphs(package: Any, specs: Sequence[NewGlyph], title: str, facts: AutoFacts, *, fill: Callable[[dict[str, Any]], None] | None = None, read_back: Callable[[], Iterable[str]] | None = None, allow_rebuild: bool = False) -> Created

Create every glyph of specs, then optionally fill them in ONE Undo step.

facts: a fresh history.scan_auto_facts(package). fill(glyphs) gets {name: new package glyph} and edits the new master layers (find them with glyph.findLayer(master)); it runs inside one history.commit(title, layers, glyphs, ..., operation="geometry") that declares every new layer and glyph. read_back() returns one text per mismatch with the plan. allow_rebuild: the user ticked REBUILD_LABEL; it also goes to the commit as allow_bases.

Raise ValueError before any change for a refusal (module text, step 1). When FontLab refuses the FIRST glyph before its command runs, raise RuntimeError ("... did not start ... No glyph was added.") without the Undo hint. Every other failure raises history.PartialWriteError (with history.UNDO_HINT); after the first glyph exists its text names the new glyphs. Nothing to create returns Created((), ()) with no native call.

glyph_data

glyph_data(spec: NewGlyph) -> dict[str, Any]

Return the fontpr glyph_data JSON for spec: name, layers, code points.

Each layer is {"name": master, "advanceWidth": width}. A layer with components also has "elements": one {"component": {"glyphName": base}, "transform": {"xOffset": x, "yOffset": y}} per Part, in order (the VFJ tags glyphName, xOffset, yOffset of bin_types.cpp:543,570-571; the form Glyport measured). unicodes is present only when the glyph gets code points.

layer_signature

layer_signature(layer: Any) -> tuple[Any, ...]

Return the component bases and transforms, anchors and width of layer.

rebuild_note

rebuild_note(candidates: Sequence[str]) -> str

Return the preview note: "may rebuild auto eacute.sc, aacute.sc…".

segments

segments(name: str) -> frozenset[str]

Return the dotted suffix segments of a glyph name: h.sc.ss01 -> {sc, ss01}.

undo_text

undo_text(filled: bool) -> str

Return UNDO_TEXT when the script fills outlines, else CREATE_UNDO_TEXT.