fontlabapp.studios.kerning_studio.model
model
Kerning Studio data rules: pure functions over one master's pairs and groups.
What: one master is MasterData(pairs, groups) in UFO key space (classes are
public.kern1.<name> on the left side and public.kern2.<name> on the
right). These functions find class sides, effective values and the record an
edit targets, plan deletes, compute Kern To Max and the Steal gap value, parse
preview text into pairs, and list a glyph's pairs and group peers.
Why: the tabs stay thin and every rule is testable without Qt or FontLab.
Used by session (native reads) and the four tab modules.
Behaviour credits: Delete Kerning Pair From All Masters, Kern To Max and Steal Kerning From Next Pair are independent rewrites after Alex Slobzheninov, Glyphs-Scripts (Apache-2.0, https://github.com/slobzheninov/Glyphs-Scripts); no code copied. Same Kerning Groups follows Reza Bohloul's workflow; its source has no licence and its body is not redistributed.
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 |
|---|---|---|---|
CURVE_STEPS |
attribute | ||
LEFT |
attribute | ||
NATIVE_SIDES |
attribute | ||
PREFIXES |
attribute | ||
Pair |
attribute | (shared captured text) | |
RIGHT |
attribute | ||
candidates |
function | (data: MasterData, left: str, right: str) -> list[Pair] |
Possible records for a pair, most specific first (glyph/glyph ... class/class). |
check_range |
function | (value: float, upm: Any, master: str, pair: Pair) -> None |
Refuse a value outside FontLab's save/reopen range of twice units per em. |
class_key |
function | (data: MasterData, left: str, right: str) -> Pair |
The pair's class-level record: each glyph side replaced by its group, if any. |
display |
function | (name: str) -> str |
<code>public.kern1.A</code><code> -> </code><code>@A</code>; glyph names unchanged. |
effective |
function | (data: MasterData, left: str, right: str) -> tuple[float, Pair | None] |
The value the pair gets and the record it comes from (<code>(0, None)</code> if none). |
extents |
function | (recording: Sequence[tuple[str, tuple]], height: float, name: str, layer: str) -> tuple[tuple[float, float], … |
Min/max x where closed contours cross <code>height</code>; also the open-contour count. |
from_native |
function | (pairs: Mapping[Pair, float], classes: Mapping[str, tuple[Any, str]]) -> MasterData |
Convert <code>core.scripting</code><code> reads (</code><code>@class</code> keys, side roles) to UFO keys. |
glyph_pairs |
function | (masters: Mapping[str, MasterData], glyph: str) -> list[Pair] |
Every record, on any master, whose left or right side is <code>glyph</code> or its group. |
group_peers |
function | (groups: Mapping[str, Sequence[str]], glyph: str, order: Sequence[str]) -> dict[str, list[str]] |
Other members of the glyph's visual-side groups, in font order. |
is_group |
function | (name: str) -> bool |
|
kern_to_max |
function | (left_width: float, right_width: float) -> int |
Minus half the narrower advance, truncated toward zero. |
overrides |
function | (data: MasterData, key: Pair, left: str, right: str) -> list[tuple[Pair, float]] |
Existing records more specific than <code>key</code> that keep overriding it. |
parse_side |
function | (text: str, side: int) -> str |
User text (<code>A</code><code> or </code><code>@A</code><code>) -> a UFO key for </code><code>side</code>; blank refused. |
parse_text |
function | (text: str, cmap: Mapping[int, str]) -> list[list[str]] |
Split preview text into words of glyph names; <code>/name</code><code> tokens end at space or </code><code>/</code>. |
side_groups |
function | (groups: Mapping[str, Sequence[str]], glyph: str) -> tuple[str | None, str | None] |
The <code>(kern1, kern2)</code><code> groups containing </code><code>glyph</code>; more than one per side refused. |
steal_value |
function | (widths: Sequence[float], spans: Sequence[tuple[float, float]], reference: float) -> tuple[int, float, float] |
Kerning for pair 1 so its gap matches pair 2 (kerned by <code>reference</code>). |
target_key |
function | (data: MasterData, left: str, right: str) -> Pair |
The record an edit writes: the most specific existing one, else the class record. |
text_pairs |
function | (words: Iterable[Sequence[str]]) -> list[Pair] |
Adjacent pairs inside each word, first occurrence order, no repeats. |