Skip to content

fontlabapp.fontui.feature_blocks · declarations 001

Back to fontlabapp.fontui.feature_blocks

read_feature_blocks

read_feature_blocks(package: Any) -> dict

Read exact ordered VFJ feature source through Fontport and fontpr.

Requires an active registered font inside FontLab (fontpr is host-provided). Native object ids guard the UI binding; fgId identifies the fontpr font. Raise ValueError when the bound font is no longer the active font.

write_feature_blocks

write_feature_blocks(package: Any, expected: dict, updated: dict, *, references: Iterable[str], undo_name: str) -> dict[str, int]

Apply an exact source-bound feature plan with Fontport's history checks.

All referenced glyphs and the complete source snapshot must still match. Fontport validates split-back, language synthesis and empty history slots before mutation, and notifies only package/features. Groups are untouched. Unexpected native errors may leave partial changes; they are not hidden.

Refuse with ValueError when the font is inactive, the source differs from expected, or a referenced glyph is gone. Return {"changed": 0} when expected == updated and {"changed": 1} after a write. Feature codes missing a final newline, or with trailing spaces/tabs after it, are normalised by _terminated before comparing and staging. The master that was active before the write is restored in finally.