otBase

class fontTools.ttLib.tables.otBase.OverflowErrorRecord(overflowTuple)
exception fontTools.ttLib.tables.otBase.OTLOffsetOverflowError(overflowErrorRecord)

Bases: exceptions.Exception

class fontTools.ttLib.tables.otBase.BaseTTXConverter(tag)

Bases: fontTools.ttLib.tables.DefaultTable.DefaultTable

Generic base class for TTX table converters. It functions as an adapter between the TTX (ttLib actually) table model and the model we use for OpenType tables, which is necessarily subtly different.

decompile(data, font)
compile(font)

Create a top-level OTFWriter for the GPOS/GSUB table. Call the compile method for the the table

for each ‘converter’ record in the table converter list
call converter’s write method for each item in the value.
  • For simple items, the write method adds a string to the

writer’s self.items list. - For Struct/Table/Subtable items, it add first adds new writer to the to the writer’s self.items, then calls the item’s compile method. This creates a tree of writers, rooted at the GUSB/GPOS writer, with each writer representing a table, and the writer.items list containing the child data strings and writers.

call the getAllData method

call _doneWriting, which removes duplicates call _gatherTables. This traverses the tables, adding unique occurences to a flat list of tables Traverse the flat list of tables, calling getDataLength on each to update their position Traverse the flat list of tables again, calling getData each get the data in the table, now that pos’s and offset are known.

If a lookup subtable overflows an offset, we have to start all over.

toXML(writer, font)
fromXML((name, attrs, content), font)
class fontTools.ttLib.tables.otBase.OTTableReader(data, tableType, offset=0, valueFormat=None, cachingStats=None)

Helper class to retrieve data from an OpenType table.

getSubReader(offset)
readUShort()
readShort()
readLong()
readULong()
readTag()
readStruct(format, size=None)
setValueFormat(format, which)
readValueRecord(font, which)
class fontTools.ttLib.tables.otBase.OTTableWriter(tableType, valueFormat=None)

Helper class to gather and assemble data for OpenType tables.

getAllData()

Assemble all data, including all subtables.

getDataLength()

Return the length of this table in bytes, without subtables.

getData()

Assemble the data for this writer/table, without subtables.

_doneWriting(internedTables=None)
_gatherTables(tables=None, extTables=None, done=None)
getSubWriter()
writeUShort(value)
writeShort(value)
writeLong(value)
writeULong(value)
writeTag(tag)
writeSubTable(subWriter)
writeCountReference(table, name)
writeStruct(format, values)
writeData(data)
setValueFormat(format, which)
writeValueRecord(value, font, which)
getOverflowErrorRecord(item)
class fontTools.ttLib.tables.otBase.CountReference(table, name)

A reference to a Count value, not a count of references.

getCountData()
fontTools.ttLib.tables.otBase.packUShort(value)
fontTools.ttLib.tables.otBase.packULong(value)
class fontTools.ttLib.tables.otBase.TableStack

A stack of table dicts, working as a stack of namespaces so we can retrieve values from (and store values to) tables higher up the stack.

push(table)
pop()
getTop()
getValue(name)
storeValue(name, value)
_TableStack__findTable(name)
class fontTools.ttLib.tables.otBase.BaseTable
getConverters()
getConverterByName(name)
decompile(reader, font, tableStack=None)
preCompile()
compile(writer, font, tableStack=None)
readFormat(reader)
writeFormat(writer)
postRead(table, font)
preWrite(font)
toXML(xmlWriter, font, attrs=None)
toXML2(xmlWriter, font)
fromXML((name, attrs, content), font)
class fontTools.ttLib.tables.otBase.FormatSwitchingBaseTable

Bases: fontTools.ttLib.tables.otBase.BaseTable

Minor specialization of BaseTable, for tables that have multiple formats, eg. CoverageFormat1 vs. CoverageFormat2.

getConverters()
getConverterByName(name)
readFormat(reader)
writeFormat(writer)
fontTools.ttLib.tables.otBase._buildDict()
class fontTools.ttLib.tables.otBase.ValueRecordFactory

Given a format code, this object convert ValueRecords.

setFormat(valueFormat)
readValueRecord(reader, font)
writeValueRecord(writer, font, valueRecord)
class fontTools.ttLib.tables.otBase.ValueRecord
getFormat()
toXML(xmlWriter, font, valueName, attrs=None)
fromXML((name, attrs, content), font)