Skip to content

fontlabapp.metrics.panel.model

model

Shared plan, write and panel parts of the Metrics scripts (advance edits).

What: the Metrics scripts (Round Advances, Scale Advances, Tabular Width, Centre In Advance, Italic Sidebearings, Zero-Width Marks) share one model. A planner turns one layer into a LayerPlan (outline shift dx and new advance width) or a skip text. survey plans every target layer, commit writes all pending plans as ONE Undo step and reads them back, and the non-modal MetricsPanel (from panel_type()) shows a live preview.

How: commit uses fontlabapp.core.history.glyphs.commit with the "geometry" policy. Auto layers are listed and never edited. A glyph that owns an auto layer is listed and skipped as a whole. Layers with a metrics link or expression are listed and skipped. A base of auto composites is refused until the user ticks ALLOW_AUTO_LABEL for exactly the glyphs that change now. shift_and_set moves the outline in place (applyTransform), never through a clone, because flShape.clone() drops raw node flags and notes (FontLab issues 8516 and 8538).

Why: each script then holds only its constants, its planner and a small build(). This module imports only the standard library at load time. PythonQt and FontLab load inside the functions; panel_type() loads the Qt panel class. Offline tests do not prove native Undo/Redo/reopen.

How to use (a script)::

from fly.ap.metrics.panel.model import LayerPlan, make_plan, panel_type

class RoundAdvances(panel_type()):
    TITLE, KEY, HEADERS, ACCENT = "Round Advances", "metrics_round", ("Width",), (1,)

    def build(self): ...
    def subtitle_hint(self): return "Rounds advances."
    def planner(self, package, glyphs): return lambda layer, master: make_plan(...)

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
ALLOW_AUTO_LABEL attribute
AUTO_GLYPH_NOTE attribute
AUTO_LAYER_NOTE attribute
LINK_FIELDS attribute
LINK_NOTE attribute
MAX_NAMES attribute (shared captured text)
MAX_ROWS attribute
MISSING_NOTE attribute
NOTE_LIMIT attribute
Planner attribute
READ_BACK_TOLERANCE attribute
auto_dependants function (facts: Any, names: Iterable[str]) -> list[str] Return the sorted auto glyphs that FontLab rebuilds when <code>names</code> change.
auto_skipped function (entries: list[Entry]) -> int Count the layers skipped because of auto layers.
commit function (title: str, entries: list[Entry], *, facts: Any, allow_bases: bool=False, native: Any=None, stamp: Any=None,… Apply all pending plans as ONE Undo step.
has_metrics_link function (layer: Any) -> bool Return True when a sidebearing or the width holds a link or an expression.
ink_edges function (layer: Any) -> tuple[float, float] | None Return the left and right edge of the layer outline, or None for an empty layer.
make_plan function (layer: Any, dx: int, width: int, cells: tuple[str, ...]) -> LayerPlan Build a plan.
make_table function (headers: list[str]) -> Any Return a read-only preview <code>QTableWidget</code> with a stretched layout.
master_layers function (glyph: Any, masters: list[str]) -> dict[str, Any] Map master name to layer for the masters that this glyph has.
muted function (widget: Any) -> str Return a dimmed text colour (<code>#AARRGGBB</code>) from the widget palette.
panel_type function () -> type Return the <code>MetricsPanel</code><code> base class (a PythonQt </code><code>QDialog</code>).
pending function (entries: list[Entry]) -> list[Entry] Return the entries that change the font.
read_back function (entry: Entry, before: tuple[float, float] | None) -> list[str] Compare the written layer with its plan.
rebuild_note function (found: list[str]) -> str Warn that FontLab rebuilds auto composites when it is told about their bases.
shift_and_set function (layer: Any, dx: int, width: int, *, qtgui: Any=None) -> None Move the outline by <code>dx</code> units in place, anchors included, then set the advance.
survey function (glyphs: list[Any], masters: list[str], planner: Planner, *, facts: AutoFacts | None=None) -> list[Entry] Plan every glyph/master layer.
unit function (value: float) -> int Round half up to a whole unit.