fontlabapp.metrics.zones.native
native
The native Alignment Zones backend: capture, check, bounds and apply.
What: backend() returns the zone_editor.Backend for the current font.
It reads and writes PostScript zones the way Font Info does
(fontinfo_data.cpp:565-620): per master setMaster(name, False), read
ps_zonesT/ps_zonesB, write convertZonesToGuidelines(top, bottom)
then updateZonesFromGuidelines(). Apply stages every changed master
through font_history.commit_masters (ONE Undo step, issue 122 M2 route A,
measured on FontLab 9.0.9790).
Values: zones are plain zone_data values. Both native lists hold positive
widths (FontLab stores a bottom zone as a guide with a negative extension,
flpackage.cpp:12433-12523). Origins carry no native id: a zone key is
"Top:<name>" or "Bottom:<name>" from capture. FontLab keeps zone
names unique per list, so apply finds the source zone of a retained row by
its baseline kind and name, and copies that native zone (flZone(zone)):
its tags and lock state stay. A new row gets a new flZone.
What the route changes: convertZonesToGuidelines replaces every zone
guide of a written master. The guides get new ids, x-centre 0 and the custom
font-guideline style; only position, width, name, tags and lock are kept.
Font Info does the same.
Refusals before any history call: RowRefusal (a ValueError; the
dialog stays usable) for an empty zone name (FontLab would rename it
T: 500; Editor.add names new rows as FontLab does), a duplicate name
in one list (FontLab would add .1) and a zero-width row whose kind
FontLab reads differently (zone_native_rules.is_top); then the GUI-thread
and Font-window guards; then ValueError(STALE_TEXT) for a stale snapshot.
Rollback: a failure before the notification restores the zones with the
same convert/update calls, so FontLab re-creates the zone guides with new
ids; the RolledBackError text says so (RESTORED_TEXT). Non-zone
guides are not rebuilt (flpackage.cpp:12456-12462). Restoring the
original guide objects would need guidelinesHost, which is unmeasured.
fl#8554: this route never calls flModelProducer.getClipboardData, so the
serializer arity defect does not affect it. The serializer modules
(zone_capture, zone_prepare, zone_write_plan) stay held.
Known host defect (fl#8574): after Undo/Redo, the font-metric guidelines show 3 of 9
until updateFontMetrics() or a reopen (see font_history). Offline
tests prove the call order only.
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 |
|---|---|---|---|
BOUNDS_GLYPHS |
attribute | ||
CAPTURE_SECONDS |
attribute | (shared captured text) | |
RESTORED_TEXT |
attribute | ||
STALE_TEXT |
attribute | ||
TITLE |
attribute | ||
apply |
function | (before: Snapshot, changes: tuple[Change, ...], *, title: str=TITLE) -> Snapshot |
Write every changed master as ONE Undo step named <code>title</code>; return the new baseline. |
backend |
function | (package_id: int | None=None, *, title: str=TITLE) -> Backend |
Return the native <code>zone_editor.Backend</code><code> for </code><code>package_id</code> or the current font. |
bounds |
function | (snapshot: Snapshot, master: str) -> tuple[Extent, Extent] |
Return the vertical extents of <code>o</code><code> and </code><code>O</code><code> in </code><code>master</code>. |
capture |
function | (expected_id: int | None=None) -> Snapshot |
Read every master of the current font; restore the starting master. |
check |
function | (snapshot: Snapshot) -> None |
Refuse with <code>ValueError(STALE_TEXT)</code><code> unless the font equals </code><code>snapshot</code>. |
read_zones |
function | (package: Any) -> Zones |
Return the zones of the selected master as plain values. |