Skip to content

fontlabapp.core.history.glyphs · declarations 001

Back to fontlabapp.core.history.glyphs

CHECK_TEXT module-attribute

CHECK_TEXT

NOT_STORED module-attribute

NOT_STORED

OPERATIONS module-attribute

OPERATIONS

Operation module-attribute

Operation

Record module-attribute

Record

SHOWN_MISMATCHES module-attribute

SHOWN_MISMATCHES

STRUCTURAL module-attribute

STRUCTURAL

UNDO_HINT module-attribute

UNDO_HINT

auto_facts

auto_facts(records: Iterable[Record]) -> AutoFacts

Build AutoFacts from dependency records, one record per layer.

Use the records of fontlabapp.guides.inspect.model.dependency_values(package): (glyph name, layer is auto, component base names). A glyph with any auto record is an auto owner; every component base gets the glyph as user.

commit

commit(title: str, layers: Sequence[Any], glyphs: Sequence[Any], mutate: Callable[[], Iterable[Any] | None], *, operation: Operation, facts: AutoFacts, allow_bases: bool = False, read_back: Callable[[], Iterable[str]] | None = None, settled: bool = False, window: int | None = None, native: Any = None, stamp: Any = None, retain: Sequence[Any] = (), glyph_window_ok: bool = False) -> Committed

Run mutate as ONE native Undo step. See the module text for the order.

title: the Undo name. layers: every existing layer that mutate changes (all layers of a glyph for renames and Unicode). glyphs: their owner glyphs. mutate(): the edit; return new native objects to notify, or None. operation and facts: the refusal policy (facts from a fresh scan_auto_facts). allow_bases: let bases of auto composites through after the user agreed. read_back(): return one text per mismatch between font and plan. settled: refuse queued native updates (explicit opt-in; default False discloses pre-write ids in Committed.pending_updates without clearing them). window: the bound package id; when given, run require_selection_window and require_no_editors first (Unicode writers). native/stamp: the fontlab module and the UTC stamp; the defaults are the native module and QDateTime.currentDateTimeUtc(). retain: native objects to keep in the Undo state, first in the list, with the deep-history flag True (use component_history for each removed component, read before the removal). They get no checkInitHistoryState and are not in Committed.created. Empty: the two-argument notification, as before. glyph_window_ok: skip the Glyph-window check (edit_guards.require_history_scope). Use it only for a caller that a native test proves safe; no caller uses it now.

Raise ValueError before any history call for a refusal. Raise PartialWriteError when anything fails after history started, including a new auto layer from mutate (it stays out of the notification).

component_history

component_history(shape: Any) -> tuple[Any, ...]

Return the native objects to retain when a script removes shape.

What: (shape, shape.shapeData, shapeData.builder) for a component; () for any other shape, so the result can always go to commit(..., retain=...). Same logic as glyport's _retain_component_history. When: call it BEFORE removeShape, outside mutate. Glyport records that a builder read after detachment can already be too late (fl#7641). A component without shapeData raises ValueError: nothing to retain is a fault, not an empty result. The builder is returned as FontLab gives it.

refusal

refusal(facts: AutoFacts, name: str, operation: str, *, allow_bases: bool = False) -> str

Return why operation must not edit glyph name, or "".

Texts: "has auto layers" for an auto owner (every operation); "base of auto X, Y…" for a base of auto composites ("rename", "unicode", "geometry", unless allow_bases). An unknown operation raises ValueError.

refusals

refusals(facts: AutoFacts, names: Iterable[str], operation: str, *, allow_bases: bool = False) -> dict[str, str]

Return {refused name: reason} for names, in their order.

Names that operation may edit are left out. Use it to list refused rows in a preview before Apply.

scan_auto_facts

scan_auto_facts(package: Any) -> AutoFacts

Read every layer of package and return its AutoFacts.

Reuse fontlabapp.guides.inspect.model.dependency_values: font order from FontGate records, package.findName per glyph, never flGlyph.fgGlyph. A missing glyph raises ValueError("Glyph source changed; reopen this tool.").

unstored_error

unstored_error(missed: Sequence[str], advice: str = '') -> RuntimeError

Return the error for values that FontLab did not keep after a commit.

Text: "FontLab did not store N change(s): a, b. <advice> Check those layers before you save.". It starts with NOT_STORED, so a panel can tell a read-back gap from a refusal. advice is an optional sentence before CHECK_TEXT. The text makes no claim about Undo: the commit was one Undo step, but no measurement shows what Undo restores.