vfbLib.parsers.numeric.PanoseParser
- class vfbLib.parsers.numeric.PanoseParser
Bases:
BaseParserA parser that reads data as an array representing PANOSE values.
- __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".
Return a double-precision float from the stream.
read_doubles(num)Return a tuple of num double-precision floats from the stream.
Return a float from the stream.
read_floats(num)Return a tuple of num floats from the stream.
Return a signed 16-bit integer from the stream.
Return a signed 32-bit integer from the stream.
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
Return the remaining bytes of the current stream as a string with the current encoding.
Return an unsigned 16-bit integer from the stream.
Return an unsigned 32-bit integer from the stream.
Return an unsigned 8-bit integer from the stream.
read_value([signed])Return an encoded integer value from the stream.
Attributes
encodingmaster_countstreamttStemsH_countttStemsV_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:
- read_str(size: int) str
Return a string of the specified size from the current stream with the current encoding
- 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:
- read_uint16() int
Return an unsigned 16-bit integer from the stream.
- Returns:
The integer
- Return type:
- read_uint32() int
Return an unsigned 32-bit integer from the stream.
- Returns:
The integer
- Return type: