Skip to content

fontlabapp.masters.inspect.model · declarations 001

Back to fontlabapp.masters.inspect.model

METRICS module-attribute

METRICS

STAMP_FORMAT module-attribute

STAMP_FORMAT

STEPS module-attribute

STEPS

all_names

all_names() -> list[str]

Read font order from the already available FontGate font, never flGlyph.fgGlyph.

associated_master

associated_master(name: str, masters: Sequence[str]) -> str | None

Return the master that a layer name belongs to, or None.

What: drop a leading |temp|, cut at the first @ (else the first #) and return the rest when it is one of masters. So "Regular@ 2026-10-21" and "Regular#bracket" belong to "Regular"; "mask.Regular" and "Light Copy" belong to none.

Why: this is FontLab's own rule (flLayer::isMasterLayerName, fllayer.cpp:10346-10375, which then calls package.hasMaster). Scripts that step through, copy or promote layers use it to find the master of a backup or a bracket layer. Pure string work; it reads no font.

backup_layer_name

backup_layer_name(base: str, taken: Iterable[str], suffix: str, masters: Sequence[str]) -> str

Return a unique <base> backup <suffix> name, or raise ValueError.

Strip the suffix and refuse an empty value. Append (2), (3) and so on for case-insensitive collisions in taken. Refuse @, # or |temp| anywhere in the candidate, a master name (casefold), or a name that does not resolve exactly to base. These checks keep the backup out of special layer roles and prevent a restore to the wrong master. Example: backup_layer_name("Bold", names, "trial", masters).

backup_master

backup_master(name: str, masters: Sequence[str]) -> str | None

Return the master of a plain or legacy backup layer, or None.

Refuse names equal to any master (casefold), and names with # or |temp| anywhere. For legacy @ names, match the part before @. Otherwise use the longest master plus a space prefix. Prefix matches use exact case, as the layer tools always did: regular sketch is not a backup of Regular, and with masters Bold and BOLD, BOLD backup x belongs to BOLD. With Bold and Bold Italic, Bold Italic backup x belongs to Bold Italic; Bold Italic itself is never a backup. Use this rule for display, cleanup and restore tools.

check_glyph

check_glyph(glyph: Any, masters: list[str]) -> tuple[dict[str, Any], bool, list[str]]

({master: signature or None for auto layers}, ok, [differing aspects]).

default_suffix

default_suffix(now: datetime) -> str

Format now for the backup suffix field, with seconds and a short date.

Pass the local time, for example default_suffix(datetime.now().astimezone()). Read no clock here so callers can use the same time for a whole batch.

ink_area

ink_area(contours: list[list[tuple[float, float, bool]]]) -> float

Filled area of contours [(x, y, on)]: + for even nesting depth, - for odd (counters).

inside

inside(point: tuple[float, float], poly: list[tuple[float, float]]) -> bool

Use ray crossings to determine counter nesting independently of winding.

is_backup_layer

is_backup_layer(name: str, master: str, masters: Sequence[str]) -> bool

Return True if backup_master(name, masters) is exactly master.

Pass all font masters to exclude master layers and resolve overlapping names. Example: is_backup_layer("Bold backup x", "Bold", ["Bold"]) is True.

italic_angles

italic_angles(package: Any, masters: list[str]) -> dict[str, float]

{master: italic angle}; switches the current master briefly and always restores it.

label_tops

label_tops(ys: list[float], height: float) -> list[float]

Tops of value labels for points sorted top to bottom: above the point, or below it when the label above would collide with the previous one, pushed further down if still crowded.

layer_contours

layer_contours(layer: Any) -> list[list[tuple[float, float, bool]]]

Own and component contours, components placed by their transforms.

location_text

location_text(package: Any, master: str) -> str

Format axes in font order, displaying ? for unavailable location coordinates.

master_layers

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

{master: flLayer} for the masters present in this glyph.

master_order

master_order(package: Any) -> list[str]

Masters sorted by their location on the first axis (font order when there is no axis).

muted

muted(widget: Any, alpha: int = 150) -> str

Copy the original active theme color before changing its alpha.

nice_ticks

nice_ticks(low: float, high: float, count: int = 5) -> list[float]

Cover both endpoints with nice ticks, retaining a nonzero constant-range axis.

node_points

node_points(contour: Any) -> list[tuple[float, float, bool]]

Read contour coordinates and on/handle flags in original node order.

overview

overview(package: Any) -> list[tuple[str, str, float, float, float, float, float]]

[(master, location, ascender, cap height, x-height, descender, italic angle)].

own_contours

own_contours(layer: Any) -> list[Any]

Contours drawn in this layer; layer.getContours() also lists the contours of components.

polygon

polygon(points: list[tuple[float, float, bool]]) -> list[tuple[float, float]]

Flatten [(x, y, on)] of a closed contour: cubic for two handles, polyline otherwise.

selected_names module-attribute

selected_names

signature

signature(layer: Any) -> tuple[tuple[str, ...], tuple[str, ...], tuple[str, ...]]

Comparable structure of a layer: contour node patterns, anchor names, component bases.

spread

spread(ys: list[float], gap: float) -> list[float]

Sorted label positions pushed apart so neighbours are at least gap apart.

summary

summary(sig: Any) -> tuple[int, int, int, int]

Return displayed contour, node, anchor and component counts for a signature.

widths

widths(glyph: Any, masters: list[str]) -> list[tuple[str, float | None]]

[(master, advance width or None)] in the given master order.