Skip to content

fontlab_glyport.ui.nib_archive

nib_archive

Read compiled NIBs (no Objective-C runtime) into plain Python objects (R031).

Two container formats occur in Glyphs plugin bundles: NIBArchive (the default since macOS 10.13; a single file or keyedobjects-101300.nib) and NSKeyedArchiver binary plists (keyedobjects.nib). Both decode to the same shape: :class:Archived objects (class name plus fields) with strings, numbers and collections already turned into Python values. A .nib directory is read through its keyed archive when present.

NIBArchive layout, all integers little-endian: magic, two format words, then (count, offset) pairs for objects, keys, values and class names. Variable integers keep 7 bits per byte, and a set high bit marks the last byte. Value types: 0-3 signed ints of 1/2/4/8 bytes, 4 false, 5 true, 6 float, 7 double, 8 data (length-prefixed), 9 nil, 10 object reference (4 bytes). Collections store their elements under the repeated key UINibEncoderEmptyKey.

Hostile input is rejected with :class:NibFormatError, never expanded: files over MAX_BYTES, variable integers wider than 5 bytes (32 bits), table counts larger than the file, offsets and references outside their tables, reference chains deeper than MAX_DECODE_DEPTH, and any malformed record. Shared and cyclic references decode once (memoised by object index).

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
MAGIC attribute
MAX_BYTES attribute
MAX_DECODE_DEPTH attribute
MAX_VARINT_BYTES attribute
read_nib function (path: str | Path) -> Archived Return the root object (<code>NSIBObjectData</code><code>) of a </code><code>.nib</code> file or bundle.
read_nib_data function (data: bytes, path: str | Path='<nib data>') -> Archived The root of NIB bytes (a file's, or a table view's archived prototype cell views); <code>path</code> only names it in errors.