Skip to content

fontlabapp.metrics.panel.model · declarations 001

Back to fontlabapp.metrics.panel.model

ALLOW_AUTO_LABEL module-attribute

ALLOW_AUTO_LABEL

AUTO_GLYPH_NOTE module-attribute

AUTO_GLYPH_NOTE

AUTO_LAYER_NOTE module-attribute

AUTO_LAYER_NOTE
LINK_FIELDS
LINK_NOTE

MAX_ROWS module-attribute

MAX_ROWS

MISSING_NOTE module-attribute

MISSING_NOTE

NOTE_LIMIT module-attribute

NOTE_LIMIT

Planner module-attribute

Planner

READ_BACK_TOLERANCE module-attribute

READ_BACK_TOLERANCE

auto_dependants

auto_dependants(facts: Any, names: Iterable[str]) -> list[str]

Return the sorted auto glyphs that FontLab rebuilds when names change.

facts is a history.AutoFacts. Chains through manual composites count. Glyphs in names are never listed.

auto_skipped

auto_skipped(entries: list[Entry]) -> int

Count the layers skipped because of auto layers.

commit

commit(title: str, entries: list[Entry], *, facts: Any, allow_bases: bool = False, native: Any = None, stamp: Any = None, qtgui: Any = None) -> dict[str, Any]

Apply all pending plans as ONE Undo step. Report what the font now holds.

facts: fresh history.AutoFacts of the font. allow_bases: the user ticked ALLOW_AUTO_LABEL for these glyphs. The write goes through fontlabapp.core.history.glyphs.commit with operation="geometry": refusals first, then init history, shift_and_set per layer, stamp, one notify of the layers and their glyphs, stamp, read-back.

Return {"layers", "glyphs", "auto_skipped", "mismatches"}. Nothing to change returns zeros and makes no history call. A refusal raises ValueError; a failure after history started raises history.PartialWriteError.

has_metrics_link(layer: Any) -> bool

Return True when a sidebearing or the width holds a link or an expression.

ink_edges

ink_edges(layer: Any) -> tuple[float, float] | None

Return the left and right edge of the layer outline, or None for an empty layer.

make_plan

make_plan(layer: Any, dx: int, width: int, cells: tuple[str, ...]) -> LayerPlan

Build a plan. It is a no-op when the outline and the advance stay as they are.

make_table

make_table(headers: list[str]) -> Any

Return a read-only preview QTableWidget with a stretched layout.

The first column fits its contents; the other columns stretch. No edit, no selection, alternating rows, no grid, no horizontal scroll bar.

master_layers

master_layers(glyph: Any, masters: list[str]) -> dict[str, Any]

Map master name to layer for the masters that this glyph has.

muted

muted(widget: Any) -> str

Return a dimmed text colour (#AARRGGBB) from the widget palette.

panel_type

panel_type() -> type

Return the MetricsPanel base class (a PythonQt QDialog).

The class loads PythonQt, so call this inside FontLab only. Subclass it and set TITLE, KEY, HEADERS and ACCENT. Fill in the hooks build, subtitle_hint and planner; optionally override target_glyphs, empty_message and sync_controls. See fontlabapp.metrics.panel.ui.MetricsPanel for the full contract.

pending

pending(entries: list[Entry]) -> list[Entry]

Return the entries that change the font.

read_back

read_back(entry: Entry, before: tuple[float, float] | None) -> list[str]

Compare the written layer with its plan. Return one text per mismatch.

before holds the ink edges from before the write (ink_edges). The left edge may differ by READ_BACK_TOLERANCE units.

rebuild_note

rebuild_note(found: list[str]) -> str

Warn that FontLab rebuilds auto composites when it is told about their bases.

Name at most NOTE_LIMIT glyphs. An empty list gives "".

shift_and_set

shift_and_set(layer: Any, dx: int, width: int, *, qtgui: Any = None) -> None

Move the outline by dx units in place, anchors included, then set the advance.

Use layer.applyTransform, then changed() and update(); never a shape clone. update() returning False raises RuntimeError. qtgui is PythonQt's QtGui (default: the native one).

survey

survey(glyphs: list[Any], masters: list[str], planner: Planner, *, facts: AutoFacts | None = None) -> list[Entry]

Plan every glyph/master layer. Skipped layers are listed with a note.

Skip, in this order: a missing layer (MISSING_NOTE); an auto layer (AUTO_LAYER_NOTE); any other layer of a glyph that owns an auto layer (AUTO_GLYPH_NOTE; the geometry policy refuses such glyphs); a layer with a metrics link (LINK_NOTE); a layer the planner skips (its text). A manual composite is also skipped when its base moves in this plan. Pass the existing whole-font component facts to follow unselected intermediate glyphs. Without facts, only selected layers supply edges.

unit

unit(value: float) -> int

Round half up to a whole unit. Python round() rounds half to even.