fontlabapp.glyphs.names.model
model
Whole-font snapshot, refusals and one-Undo commit for the Names editors.
What: the Names editors (Batch Rename, Suffix Tool, Unicode From Names, Glyph Notes, Batch Glyph Notes, Glyph Tags, Mark Color Palette) share one model:
scan()reads every glyph of the current font intoFacts: oneEntryper glyph (FontGate record plus FontLab glyph) and the auto-layer facts of the whole font (history.AutoFacts).refusal/editablesay which glyphs an operation may edit.fresh_factsscans again just before a write, refuses a switched font and leaves pre-write disclosure tocommit.commitruns the edit as ONE Undo step throughhistory.commit.
How: scan maps each font-owned record through package.findFgId and
checks name and id both ways. It never reads flGlyph.fgGlyph: on build
9784 that getter can clear a fresh note mirror. Facts is never patched; a
stale snapshot is scanned again.
Why the refusals (history.refusal): FontLab rebuilds every auto layer when
an auto layer or a base of an auto composite is notified, and Undo does not
restore the result (after e was renamed, ecircumflex became a lone
ee). Use operation="rename" or "unicode" for names and code
points, "metadata" for notes, tags and mark colours (these refuse only
glyphs that own an auto layer).
How to use::
import fly.ap.glyphs.names.model as names_edit
facts = names_edit.fresh_facts(package_id)
ok, refused = names_edit.editable(facts, names, "rename")
names_edit.commit("Batch Rename", [facts.entries[n] for n in ok],
lambda: rename(ok), operation="rename", facts=facts)
The module imports only the standard library at load time. Offline tests do not prove native Undo/Redo/reopen behaviour.
Classes
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 |
|---|---|---|---|
commit |
function | (title: str, entries: list[Entry], mutate: Callable[[], Iterable[Any] | None], *, operation: Operation, facts… |
Run <code>mutate</code><code> as ONE Undo step over </code><code>entries</code><code> (</code><code>history.commit</code>). |
editable |
function | (facts: Facts, names: Iterable[str], operation: str) -> tuple[list[str], dict[str, str]] |
Split <code>names</code> into (names that may be edited, {refused name: reason}). |
fresh_facts |
function | (package_id: int, *, native: Any=None) -> Facts |
Scan again just before a write. |
refusal |
function | (facts: Facts, name: str, operation: str) -> str |
Return why <code>operation</code><code> must not edit glyph </code><code>name</code><code>, or </code><code>""</code>. |
scan |
function | (native: Any=None) -> Facts |
Read every glyph and every layer dependency of the current font. |