vfbLib.parsers.numeric.DoubleListParser

class vfbLib.parsers.numeric.DoubleListParser

Bases: FloatListParser

A parser that reads data as a list of doubles.

__init__()

Methods

__init__()

parse(stream, size[, master_count, ...])

Prepare the parsing of the stream, then call the specialized parser and return the decompiled VFB entry structure.

parse_hex(hexstr[, master_count])

Parse the data given in hex string format, e.g. "8c 8d 89 8b".

read_double()

Return a double-precision float from the stream.

read_doubles(num)

Return a tuple of num double-precision floats from the stream.

read_float()

Return a float from the stream.

read_floats(num)

Return a tuple of num floats from the stream.

read_int16()

Return a signed 16-bit integer from the stream.

read_int32()

Return a signed 32-bit integer from the stream.

read_int8()

Return a signed 8-bit integer from the stream.

read_str(size)

Return a string of the specified size from the current stream with the current encoding

read_str_all()

Return the remaining bytes of the current stream as a string with the current encoding.

read_uint16()

Return an unsigned 16-bit integer from the stream.

read_uint32()

Return an unsigned 32-bit integer from the stream.

read_uint8()

Return an unsigned 8-bit integer from the stream.

read_value([signed])

Return an encoded integer value from the stream.

Attributes

encoding

master_count

stream

ttStemsH_count

ttStemsV_count

parse(stream: BytesIO, size: int, master_count: int = 0, ttStemsV_count: int | None = None, ttStemsH_count: int | None = None) Any

Prepare the parsing of the stream, then call the specialized parser and return the decompiled VFB entry structure.

The specialized parsing is done by calling the _parse method, which must be implemented for all entry parser sublasses.

Parameters:
  • stream (BytesIO) – The stream to read from.

  • size (int) – The number of bytes that will be read from the input stream and parsed.

  • master_count (int, optional) – The number of masters in the font. This is needed for some multiple-master-enabled VFB parsers. Defaults to 0.

  • ttStemsV_count (int | None, optional) – The number of TrueType hinting stems in the vertical hint direction, This is needed for some TrueType-hinting-related parsers. Defaults to None.

  • ttStemsH_count (int | None, optional) – The number of TrueType hinting stems in the horizontal hint direction, This is needed for some TrueType-hinting-related parsers. Defaults to None.

Raises:

AssertionError – If bytes remain in the stream after the parsing finished.

Returns:

The parsed structure. The type depends on the specific entry that is being parsed.

Return type:

Any

parse_hex(hexstr: str, master_count: int = 0)

Parse the data given in hex string format, e.g. “8c 8d 89 8b”. Used for testing.

Parameters:

hexstr (str) – The data

read_double() float

Return a double-precision float from the stream.

Returns:

The float

Return type:

float

read_doubles(num) tuple[float]

Return a tuple of num double-precision floats from the stream.

Parameters:

num (int) – The number of double-precision floats to read from the stream

Returns:

The tuple of floats

Return type:

tuple[float]

read_float() float

Return a float from the stream.

Returns:

The float

Return type:

float

read_floats(num: int) tuple[float]

Return a tuple of num floats from the stream.

Parameters:

num (int) – The number of floats to read from the stream

Returns:

The tuple of floats

Return type:

tuple[float]

read_int16() int

Return a signed 16-bit integer from the stream.

Returns:

The integer

Return type:

int

read_int32() int

Return a signed 32-bit integer from the stream.

Returns:

The integer

Return type:

int

read_int8() int

Return a signed 8-bit integer from the stream.

Returns:

The integer

Return type:

int

read_str(size: int) str

Return a string of the specified size from the current stream with the current encoding

Parameters:

size (int) – The size in bytes to be converted to a string

Returns:

The string

Return type:

str

read_str_all() str

Return the remaining bytes of the current stream as a string with the current encoding. Null bytes and whitespace are stripped from the string.

Returns:

The string

Return type:

str

read_uint16() int

Return an unsigned 16-bit integer from the stream.

Returns:

The integer

Return type:

int

read_uint32() int

Return an unsigned 32-bit integer from the stream.

Returns:

The integer

Return type:

int

read_uint8() int

Return an unsigned 8-bit integer from the stream.

Returns:

The integer

Return type:

int

read_value(signed: bool = True) int

Return an encoded integer value from the stream.

Parameters:
  • signed (bool, optional) – Whether the value is interpreted as a signed value.

  • True. (Defaults to)

Returns:

The integer

Return type:

int