Skip to content

fontlabapp.core.edit_guards · declarations 001

Back to fontlabapp.core.edit_guards

CANVAS_SCAN_SECONDS module-attribute

CANVAS_SCAN_SECONDS

CANVAS_TEXT module-attribute

CANVAS_TEXT

EDITOR_SCAN_SECONDS module-attribute

EDITOR_SCAN_SECONDS

append_note

append_note(text: str, result: Mapping[str, Any]) -> str

Append the stored pre-write note once, using the standard separator.

canvas_glyphs

canvas_glyphs(native: Any = None, *, deadline: float | None = None) -> frozenset[tuple[int, str]] | None

Return the glyphs that the active Glyph window shows, or None.

None: no Glyph window is the active canvas, so FontLab records package history. Otherwise return one (package id, glyph name) pair for each glyph in the text blocks of the active canvas. Use the name, not the id: CurrentGlyph().id and the canvas slot id of the same glyph differ on 9790 (412 against 531175085312). These are the glyphs that FontLab's canvas history attaches an Undo step to (flhistorycontroller.cpp, the in_glyphs branch; FontLab issue 8573). Empty slots are skipped. deadline is a time.monotonic() instant (default: now plus CANVAS_SCAN_SECONDS); a later checkpoint raises TimeoutError. Native read errors propagate.

A fontlab module without flWorkspace, or a workspace without getActiveCanvas (offline doubles), has no canvas: return None. FontLab's own module always defines both.

disclose

disclose(result: Any, target: dict[str, Any] | None = None) -> None

Copy a commit's disclosure to a caller's result, or print it for CLI use.

Writers with a legacy scalar/list return pass a target for their panel or tests; standalone callers without a target see the same note in Output.

pending_note

pending_note(ids: Sequence[int]) -> str

Explain queued ids and their date caveat, or return empty text.

pending_updates

pending_updates(native: Any = None) -> tuple[int, ...]

Read the native queue once before a write; never clear or deliver it.

Use this with pending_note for ordinary writers. FontLab 9.0.9790 can keep ids queued for the rest of the process after a refresh or opening an editor. Use require_settled only for explicit opt-in protocols.

require_history_scope

require_history_scope(glyphs: Sequence[Any], *, creates: bool = False, native: Any = None) -> None

Refuse a write that FontLab would undo only in part (FontLab issue 8573).

While a Glyph window is the active canvas, FontLab attaches the Undo step of notifyChangesApplied only to the glyphs that this canvas shows. Other notified glyphs keep the change after Undo (measured on 9790). With the Font window active, the Undo step covers every notified glyph.

glyphs: the owner glyphs of the write, matched by font and glyph name. creates: the write makes new glyphs (a new glyph is never in the canvas). Raise ValueError(CANVAS_TEXT) before any write when a Glyph window is the active canvas and the write creates glyphs, or when an owner is not in the canvas. When the canvas cannot be read, use the safe rule: allow no owner, or one owner that is the current glyph, and no new glyph. With no active canvas, return. Call it on the GUI thread only; other threads are refused. native is the fontlab module (default: the native one).

require_no_editors

require_no_editors(*, qt: Any = None, deadline: float | None = None, action: str = 'removing Unicode assignments') -> None

Refuse a write while any Glyph editor is open, also an inactive one.

qt is the PythonQt module (default: the native one). deadline is a time.monotonic() instant (default: now plus EDITOR_SCAN_SECONDS). action completes the refusal text "before ." Raise ValueError for an open or unreadable editor and TimeoutError when the widget scan passes the deadline. The scan reads only the inherits("GlyphWindow") predicate, with cyclic GC off.

require_selection_window

require_selection_window(package_id: int) -> None

Refuse a write unless a Font window of the bound font is active.

package_id is the flPackage.id that the caller scanned. Raise ValueError("Activate the Font window before selecting glyphs.") when the active panel is no regular Font window or the font changed. Use it before Unicode writes and before FL.fl.Select/Unselect.

require_settled

require_settled(native: Any = None) -> None

Refuse a write while FontLab has queued native glyph updates.

native is the fontlab module (default: the native one). Read flGlyph.updatedFgGlyphs() once and never clear it: clearing the queue hides the defect instead of avoiding it (FontLab issue 8537).