vfbLib.vfb.vfb.Vfb

class vfbLib.vfb.vfb.Vfb(vfb_path: Path | None = None, timing=True, minimal=False, drop_keys: set[str] | None = None, only_header=False, unicode_strings=False)

Bases: object

Object to represent the vfb data, with the ability to read and write. You can use the Vfb object to access glyphs through dict methods, where the glyph name is the key and the glyph object is the value.

__init__(vfb_path: Path | None = None, timing=True, minimal=False, drop_keys: set[str] | None = None, only_header=False, unicode_strings=False) None

Methods

__init__([vfb_path, timing, minimal, ...])

add_entry(entry)

Add an entry to the Vfb.

as_dict()

Return the Vfb structure as Dict, e.g. for saving as JSON.

clear()

Clear any data that may have been read before.

decompile()

Decompile all entries, except for the ones listed in drop_keys.

getGlyphMaster(key, master_index)

get_masters()

items()

keys()

read()

Read data from the file at vfb_path, without decompiling

read_stream(stream)

Lazily read and parse the vfb stream, i.e. parse the header, but only read the binary data of other entries.

write(out_path)

Compile any entries with changes, and write the VFB to out_path.

add_entry(entry: VfbEntry) None

Add an entry to the Vfb. Also sets the parent of the entry to the Vfb.

Parameters:

entry (VfbEntry) – The VfbEntry to be added to Vfb.entries.

as_dict() VfbDict

Return the Vfb structure as Dict, e.g. for saving as JSON. The dict has the keys “header” and “entries”.

clear() None

Clear any data that may have been read before.

decompile() None

Decompile all entries, except for the ones listed in drop_keys.

read()

Read data from the file at vfb_path, without decompiling

read_stream(stream: BufferedReader)

Lazily read and parse the vfb stream, i.e. parse the header, but only read the binary data of other entries.

write(out_path: Path) None

Compile any entries with changes, and write the VFB to out_path.