Skip to content

fontlabapp.fontui.tmetrics_model

tmetrics_model

Qt-free state of the TMetrics window: shaping, rows, readouts, fingerprint.

What: TMetricsModel holds the settings (text or /names, features, direction, script, language, kerning toggle, point size), shapes them with fontlabapp.fontui.shaping, breaks the run into rows no wider than a wrap width, maps cells to pixels (Geometry), keeps a visual selection and reads out the selected glyph (advance, LSB, RSB) and the kerning pair before it. fingerprint digests the font state the window shows; the window records it after its own writes for fontlabapp.fontui.livesync.Echo. write_metric sets one glyph's LSB, RSB or advance width through a single font.edit_glyph on the default layer. Use: fontlabapp.fontui.tmetrics.TMetrics drives it; tests drive it directly. Why: the Qt layer stays a thin view; every rule here is unit-tested offscreen.

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
DEFAULT_SIZE attribute
DIRECTIONS attribute
KERN1 attribute
KERN2 attribute
MARGIN attribute
METRIC_FIELDS attribute
NO_FONT_NOTE attribute
NO_TEXT_NOTE attribute
ROW_GAP attribute
SHAPED_NOTE attribute
break_rows function (run: tuple[shaping.PlacedGlyph, ...], widths: list[float], width: float | None, direction: str) -> list[tupl… Return <code>(row, x)</code><code> per glyph of </code><code>run</code><code> (visual order), rows at most </code><code>width</code>.
fingerprint function (font: Any, names: list[str] | tuple[str, ...], read: Any=None) -> str Digest what the window shows of <code>font</code><code>: names, metrics, kerning, features and the width, Unicodes and outline of each glyph in </code><code>names</code>.
kerning_pair function (font: Any, left: str, right: str) -> PairReadout Look up the effective kerning of <code>left</code><code>/</code><code>right</code> and which key gives it.
read_metrics function (font: Any) -> Metrics Read upm and vertical metrics from <code>font.info</code>; bad values become None.
sidebearings function (font: Any, name: str, read: Any=None) -> tuple[float | None, float | None, float | None] Return <code>(width, lsb, rsb)</code><code> of glyph </code><code>name</code>; None where unknown.
write_metric function (font: Any, name: str, metric: str, value: float, *, layer: str | None=None, undo_name: str | None=None) -> b… Set <code>metric</code><code> (</code><code>lsb</code><code>, </code><code>rsb</code><code> or </code><code>width</code><code>) of glyph </code><code>name</code><code> to </code><code>value</code>.