Skip to content

fontlabapp.studios.spacing_studio.model

model

Spacing Studio arithmetic: sidebearing plans, offsets, comparisons and base-first order.

What: Qt-free functions over whole font units. Metrics is one layer's measured state; each rule (tuned, equalized, centred, copied, synced, italic) returns the new left and right sidebearings (and width) that make_plan turns into a Plan: the outline shift dx and the new advance. order_plans puts bases before composites per master and removes the plan of any composite whose base moves in the same step, so no outline is moved twice (App TODO:37, Scriptmix TODO:74). Why: The maths of the nine absorbed Scriptmix metrics scripts and the Layer Metric Comparison example, kept testable without FontLab. Used by fontlabapp.studios.spacing_studio.session and .tabs.

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
AUTO_GLYPH_NOTE attribute (shared captured text)
AUTO_LAYER_NOTE attribute (shared captured text)
COMPARE_MODES attribute
COPY_MODES attribute
DEFAULT_STRINGS attribute
EMPTY_NOTE attribute
EQUALIZE_RULES attribute
ITALIC_MODES attribute
LIMIT attribute
LINK_NOTE attribute (shared captured text)
MEASURES attribute
MISSING_NOTE attribute (shared captured text)
NEGATIVE_NOTE attribute
OFFSET_LIMIT attribute
OPERATIONS attribute
Planner attribute
SYNC_RULES attribute
WIDTH_DEFAULT attribute
WIDTH_MODES attribute
centred function (before: Metrics, mode: str, value: float) -> Plan | str Centre In Advance: centre the ink in the kept, set or changed advance.
compared function (value: float | None, reference: float | None, mode: str) -> str Signed difference or percentage of <code>reference</code>; blank when undefined (never substituted).
copied function (before: Metrics, reference: tuple[int, int, float], mode: str, offset: int) -> Plan | str Copy Metrics From Reference: <code>reference</code> is (lsb, rsb, width) of the same master.
equalize function (before: Metrics, rule: str) -> Plan | str
equalized function (lsb: int, rsb: int, rule: str) -> tuple[int, int] Equalize Sidebearings: both sides from one rule.
italic function (before: Metrics, edges: tuple[float, float], mode: str, lsb: float | None, rsb: float | None) -> Plan | str Italic Sidebearings: change the de-slanted (italic) sidebearings <code>edges</code> describe.
make_plan function (before: Metrics, lsb: int, rsb: int, width: float | None=None) -> Plan | str The <code>Plan</code><code> that gives </code><code>before</code><code> the sidebearings </code><code>lsb</code><code>/</code><code>rsb</code>; a note when impossible.
measure function (edges: tuple[float, float] | None, width: float) -> Metrics | None <code>Metrics</code><code> from ink </code><code>edges</code> (left, right) and the advance; None when empty.
measure_value function (metrics: Metrics | None, height: float | None, which: str) -> float | None One Layer Metric Comparison measurement; None when an empty layer has no such value.
offset_rows function (rows: Iterable[tuple[str, Metrics | None]], offset: int) -> list[tuple[str, str, str, str]] Sidebearing Offset Preview: (name, new LSB, new RSB, advance); the advance never changes.
order_plans function (entries: Sequence[tuple[str, str, Plan | None, str]], users: Mapping[str, Iterable[str]]) -> list[tuple[str,… Bases before composites per master; drop the plan of a composite whose base moves.
subject function (names: Sequence[str]) -> str Undo-label subject: the glyph name, or <code>&quot;N glyphs&quot;</code> for several. (shared captured text)
synced function (before: Metrics, reference: Metrics, proportional: bool) -> Plan | str Sync Sidebearings: the reference master's sidebearings, scaled by ink width when proportional.
tune function (before: Metrics, mode: str, lsb: float | None, rsb: float | None) -> Plan | str Apply <code>tuned</code> to each side given; None keeps that side.
tuned function (current: int, mode: str, value: float) -> int Sidebearings Tuner: add <code>value</code><code>, set to it, or scale by </code><code>value</code> percent.
unit function (value: float) -> int Round half up to a whole font unit, as the Metrics panels do.