tables

This folder is a subpackage of fontTools.ttLib. Each module here is a specialized TT/OT table converter: they can convert raw data to Python objects and vice versa. Usually you don’t need to use the modules directly: they are imported and used automatically when needed by fontTools.ttLib.

If you are writing you own table converter the following is important.

The modules here have pretty strange names: this is due to the fact that we need to map TT table tags (which are case sensitive) to filenames (which on Mac and Win aren’t case sensitive) as well as to Python identifiers. The latter means it can only contain [A-Za-z0-9_] and cannot start with a number.

fontTools.ttLib provides functions to expand a tag into the format used here:

>>> from fontTools import ttLib
>>> ttLib.tagToIdentifier("FOO ")
'F_O_O_'
>>> ttLib.tagToIdentifier("cvt ")
'_c_v_t'
>>> ttLib.tagToIdentifier("OS/2")
'O_S_2f_2'
>>> ttLib.tagToIdentifier("glyf")
'_g_l_y_f'
>>>

And vice versa:

>>> ttLib.identifierToTag("F_O_O_")
'FOO '
>>> ttLib.identifierToTag("_c_v_t")
'cvt '
>>> ttLib.identifierToTag("O_S_2f_2")
'OS/2'
>>> ttLib.identifierToTag("_g_l_y_f")
'glyf'
>>>

Eg. the ‘glyf’ table converter lives in a Python file called:

_g_l_y_f.py

The converter itself is a class, named “table_” + expandedtag. Eg:

class table__g_l_y_f:
        etc.

Note that if you _do_ need to use such modules or classes manually, there are two convenient API functions that let you find them by tag:

>>> ttLib.getTableModule('glyf')
<module 'ttLib.tables._g_l_y_f'>
>>> ttLib.getTableClass('glyf')
<class ttLib.tables._g_l_y_f.table__g_l_y_f at 645f400>
>>

You must subclass from fontTools.ttLib.tables.DefaultTable.DefaultTable. It provides some default behavior, as well as a constructor method (__init__) that you don’t need to override.

Your converter should minimally provide two methods:

class table_F_O_O_(DefaultTable.DefaultTable): # converter for table 'FOO '

    def decompile(self, data, ttFont):
        # 'data' is the raw table data. Unpack it into a
        # Python data structure.
        # 'ttFont' is a ttLib.TTfile instance, enabling you to
        # refer to other tables. Do ***not*** keep a reference to
        # it: it will cause a circular reference (ttFont saves
        # a reference to us), and that means we'll be leaking
        # memory. If you need to use it in other methods, just
        # pass it around as a method argument.

    def compile(self, ttFont):
        # Return the raw data, as converted from the Python
        # data structure.
        # Again, 'ttFont' is there so you can access other tables.
        # Same warning applies.

If you want to support TTX import/export as well, you need to provide two additional methods:

def toXML(self, writer, ttFont):
        # XXX

def fromXML(self, (name, attrs, content), ttFont):
        # XXX

_a_n_k_r

class fontTools.ttLib.tables._a_n_k_r.table__a_n_k_r(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
subset_glyphs(s)
toXML(writer, font)

_a_v_a_r

class fontTools.ttLib.tables._a_v_a_r.table__a_v_a_r(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['fvar']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

_b_s_l_n

class fontTools.ttLib.tables._b_s_l_n.table__b_s_l_n(tag=None)[source]
closure_glyphs(s)
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
subset_glyphs(s)
toXML(writer, font)

_c_i_d_g

class fontTools.ttLib.tables._c_i_d_g.table__c_i_d_g(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
toXML(writer, font)

_c_m_a_p

class fontTools.ttLib.tables._c_m_a_p.CmapSubtable(format)[source]
decompileHeader(data, ttFont)[source]
getEncoding(default=None)[source]

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)[source]

Return the subtable class for a format.

isSymbol()[source]
isUnicode()[source]
static newSubtable(format)[source]

Return a new instance of a subtable for format.

toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._c_m_a_p.SubHeader[source]
class fontTools.ttLib.tables._c_m_a_p.cmap_format_0(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)
class fontTools.ttLib.tables._c_m_a_p.cmap_format_12(format=12)[source]
compile(ttFont)
decompile(data, ttFont)
decompileHeader(data, ttFont)
fromXML(name, attrs, content, ttFont)
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)
class fontTools.ttLib.tables._c_m_a_p.cmap_format_12_or_13(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._c_m_a_p.cmap_format_13(format=13)[source]
compile(ttFont)
decompile(data, ttFont)
decompileHeader(data, ttFont)
fromXML(name, attrs, content, ttFont)
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)
class fontTools.ttLib.tables._c_m_a_p.cmap_format_14(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._c_m_a_p.cmap_format_2(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

setIDDelta(subHeader)[source]
toXML(writer, ttFont)
class fontTools.ttLib.tables._c_m_a_p.cmap_format_4(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)
class fontTools.ttLib.tables._c_m_a_p.cmap_format_6(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)
class fontTools.ttLib.tables._c_m_a_p.cmap_format_unknown(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
decompileHeader(data, ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default=None)

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)

Return the subtable class for a format.

isSymbol()
isUnicode()
static newSubtable(format)

Return a new instance of a subtable for format.

toXML(writer, ttFont)[source]
fontTools.ttLib.tables._c_m_a_p.cvtFromUVS(val)[source]
fontTools.ttLib.tables._c_m_a_p.cvtToUVS(threeByteString)[source]
fontTools.ttLib.tables._c_m_a_p.splitRange(startCode, endCode, cmap)[source]
class fontTools.ttLib.tables._c_m_a_p.table__c_m_a_p(tag=None)[source]
buildReversed()[source]

Returns a reverse cmap such as {‘one’:{0x31}, ‘A’:{0x41,0x391}}.

The values are sets of Unicode codepoints because some fonts map different codepoints to the same glyph. For example, U+0041 LATIN CAPITAL LETTER A and U+0391 GREEK CAPITAL LETTER ALPHA are sometimes the same glyph.

closure_glyphs(s)
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
getBestCmap(cmapPreferences=((3, 10), (0, 6), (0, 4), (3, 1), (0, 3), (0, 2), (0, 1), (0, 0)))[source]

Return the ‘best’ unicode cmap dictionary available in the font, or None, if no unicode cmap subtable is available.

By default it will search for the following (platformID, platEncID) pairs:

(3, 10), (0, 6), (0, 4), (3, 1), (0, 3), (0, 2), (0, 1), (0, 0)

This can be customized via the cmapPreferences argument.

getcmap(platformID, platEncID)[source]
merge(m, tables)
prune_pre_subset(font, options)
subset_glyphs(s)
toXML(writer, ttFont)[source]

_c_v_a_r

class fontTools.ttLib.tables._c_v_a_r.table__c_v_a_r(tag=None)[source]
compile(ttFont, useSharedPoints=False)[source]
decompile(data, ttFont)[source]
dependencies = ['cvt ', 'fvar']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

_c_v_t

class fontTools.ttLib.tables._c_v_t.table__c_v_t(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap(lst)
toXML(writer, ttFont)[source]

_f_e_a_t

class fontTools.ttLib.tables._f_e_a_t.table__f_e_a_t(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
toXML(writer, font)

_f_p_g_m

class fontTools.ttLib.tables._f_p_g_m.table__f_p_g_m(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap(lst)
toXML(writer, ttFont)[source]

_f_v_a_r

class fontTools.ttLib.tables._f_v_a_r.Axis[source]
compile()[source]
decompile(data)[source]
fromXML(name, _attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._f_v_a_r.NamedInstance[source]
compile(axisTags, includePostScriptName)[source]
decompile(data, axisTags)[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._f_v_a_r.table__f_v_a_r(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['name']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

_g_a_s_p

class fontTools.ttLib.tables._g_a_s_p.table__g_a_s_p(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap(lst)
toXML(writer, ttFont)[source]

_g_c_i_d

class fontTools.ttLib.tables._g_c_i_d.table__g_c_i_d(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
toXML(writer, font)

_g_l_y_f

_g_l_y_f.py – Converter classes for the ‘glyf’ table.

class fontTools.ttLib.tables._g_l_y_f.CompositeMaxpValues(nPoints, nContours, maxComponentDepth)
count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

maxComponentDepth

Alias for field number 2

nContours

Alias for field number 1

nPoints

Alias for field number 0

class fontTools.ttLib.tables._g_l_y_f.Glyph(data='')[source]
compact(glyfTable, recalcBBoxes=True)[source]
compile(glyfTable, recalcBBoxes=True)[source]
compileComponents(glyfTable)[source]
compileCoordinates()[source]
compileDeltasGreedy(flags, deltas)[source]
compileDeltasOptimal(flags, deltas)[source]
decompileComponents(data, glyfTable)[source]
decompileCoordinates(data)[source]
decompileCoordinatesRaw(nCoordinates, data)[source]
draw(pen, glyfTable, offset=0)[source]
drawPoints(pen, glyfTable, offset=0)[source]

Draw the glyph using the supplied pointPen. Opposed to Glyph.draw(), this will not change the point indices.

expand(glyfTable)[source]
fromXML(name, attrs, content, ttFont)[source]
getComponentNames(glyfTable)[source]
getCompositeMaxpValues(glyfTable, maxComponentDepth=1)[source]
getCoordinates(glyfTable)[source]
getMaxpValues()[source]
isComposite()[source]

Can be called on compact or expanded glyph.

recalcBounds(glyfTable)[source]
remapComponentsFast(glyphidmap)
removeHinting()[source]
toXML(writer, ttFont)[source]
trim(remove_hinting=False)[source]

Remove padding and, if requested, hinting, from a glyph. This works on both expanded and compacted glyphs, without expanding it.

class fontTools.ttLib.tables._g_l_y_f.GlyphComponent[source]
compile(more, haveInstructions, glyfTable)[source]
decompile(data, glyfTable)[source]
fromXML(name, attrs, content, ttFont)[source]
getComponentInfo()[source]

Return the base glyph name and a transform.

toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._g_l_y_f.GlyphCoordinates(iterable=[], typecode='h')[source]
absoluteToRelative()[source]
append(p)[source]
property array
copy()[source]
extend(iterable)[source]
isFloat()[source]
relativeToAbsolute()[source]
scale(p)[source]
>>> GlyphCoordinates([(1,2)]).scale((.5,0))
toInt()[source]
transform(t)[source]
>>> GlyphCoordinates([(1,2)]).transform(((.5,0),(.2,.5)))
translate(p)[source]
>>> GlyphCoordinates([(1,2)]).translate((.5,0))
static zeros(count)[source]
fontTools.ttLib.tables._g_l_y_f.flagBest(x, y, onCurve)[source]

For a given x,y delta pair, returns the flag that packs this pair most efficiently, as well as the number of byte cost of such flag.

fontTools.ttLib.tables._g_l_y_f.flagEncodeCoord(flag, mask, coord, coordBytes)[source]
fontTools.ttLib.tables._g_l_y_f.flagEncodeCoords(flag, x, y, xBytes, yBytes)[source]
fontTools.ttLib.tables._g_l_y_f.flagFits(newFlag, oldFlag, mask)[source]
fontTools.ttLib.tables._g_l_y_f.flagSupports(newFlag, oldFlag)[source]
fontTools.ttLib.tables._g_l_y_f.reprflag(flag)[source]
class fontTools.ttLib.tables._g_l_y_f.table__g_l_y_f(tag=None)[source]
closure_glyphs(s)
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
getCoordinatesAndControls(glyphName, ttFont, defaultVerticalOrigin=None)[source]

Return glyph coordinates and controls as expected by “gvar” table.

The coordinates includes four “phantom points” for the glyph metrics, as mandated by the “gvar” spec.

The glyph controls is a namedtuple with the following attributes:
  • numberOfContours: -1 for composite glyphs.

  • endPts: list of indices of end points for each contour in simple

glyphs, or component indices in composite glyphs (used for IUP optimization). - flags: array of contour point flags for simple glyphs (None for composite glyphs). - components: list of base glyph names (str) for each component in composite glyphs (None for simple glyphs).

The “ttFont” and “defaultVerticalOrigin” args are used to compute the “phantom points” (see “getPhantomPoints” method).

Return None if the requested glyphName is not present.

getGlyphID(glyphName)[source]
getGlyphName(glyphID)[source]
getPhantomPoints(glyphName, ttFont, defaultVerticalOrigin=None)[source]

Compute the four “phantom points” for the given glyph from its bounding box and the horizontal and vertical advance widths and sidebearings stored in the ttFont’s “hmtx” and “vmtx” tables.

If the ttFont doesn’t contain a “vmtx” table, the hhea.ascent is used as the vertical origin, and the head.unitsPerEm as the vertical advance.

The “defaultVerticalOrigin” (Optional[int]) is needed when the ttFont contains neither a “vmtx” nor an “hhea” table, as may happen with ‘sparse’ masters. The value should be the hhea.ascent of the default master.

https://docs.microsoft.com/en-us/typography/opentype/spec/tt_instructing_glyphs#phantoms

has_key(glyphName)[source]
keys()[source]
merge(m, tables)
mergeMap = {'glyphOrder': <function sumLists>, 'glyphs': <function sumDicts>, 'tableTag': <function equal>}
padding = 1
prune_post_subset(font, options)
prune_pre_subset(font, options)
removeHinting()[source]
setCoordinates(glyphName, coord, ttFont)[source]

Set coordinates and metrics for the given glyph.

“coord” is an array of GlyphCoordinates which must include the “phantom points” as the last four coordinates.

Both the horizontal/vertical advances and left/top sidebearings in “hmtx” and “vmtx” tables (if any) are updated from four phantom points and the glyph’s bounding boxes.

setGlyphOrder(glyphOrder)[source]
subset_glyphs(s)
toXML(writer, ttFont, splitGlyphs=False)[source]

_g_v_a_r

fontTools.ttLib.tables._g_v_a_r.compileGlyph_(variations, pointCount, axisTags, sharedCoordIndices)[source]
fontTools.ttLib.tables._g_v_a_r.decompileGlyph_(pointCount, sharedTuples, axisTags, data)[source]
class fontTools.ttLib.tables._g_v_a_r.table__g_v_a_r(tag=None)[source]
compile(ttFont)[source]
compileGlyphs_(ttFont, axisTags, sharedCoordIndices)[source]
static compileOffsets_(offsets)[source]

Packs a list of offsets into a ‘gvar’ offset table.

Returns a pair (bytestring, tableFormat). Bytestring is the packed offset table. Format indicates whether the table uses short (tableFormat=0) or long (tableFormat=1) integers. The returned tableFormat should get packed into the flags field of the ‘gvar’ header.

decompile(data, ttFont)[source]
static decompileOffsets_(data, tableFormat, glyphCount)[source]
dependencies = ['fvar', 'glyf']
fromXML(name, attrs, content, ttFont)[source]
static getNumPoints_(glyph)[source]
merge(m, tables)
prune_pre_subset(font, options)
subset_glyphs(s)
toXML(writer, ttFont)[source]

_h_d_m_x

class fontTools.ttLib.tables._h_d_m_x.table__h_d_m_x(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
subset_glyphs(s)
toXML(writer, ttFont)[source]

_h_e_a_d

class fontTools.ttLib.tables._h_e_a_d.table__h_e_a_d(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['maxp', 'loca', 'CFF ', 'CFF2']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap = {'checkSumAdjustment': <function <lambda>>, 'created': <function current_time>, 'flags': <function mergeBits.<locals>.wrapper>, 'fontDirectionHint': <function <lambda>>, 'fontRevision': <built-in function max>, 'glyphDataFormat': <function equal>, 'indexToLocFormat': <function recalculate>, 'lowestRecPPEM': <built-in function max>, 'macStyle': <function first>, 'magicNumber': <function equal>, 'modified': <function current_time>, 'tableTag': <function equal>, 'tableVersion': <built-in function max>, 'unitsPerEm': <function equal>, 'xMax': <built-in function max>, 'xMin': <built-in function min>, 'yMax': <built-in function max>, 'yMin': <built-in function min>}
prune_post_subset(font, options)
toXML(writer, ttFont)[source]

_h_h_e_a

class fontTools.ttLib.tables._h_h_e_a.table__h_h_e_a(tag=None)[source]
property ascender
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['hmtx', 'glyf', 'CFF ', 'CFF2']
property descender
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap = {'*': <function equal>, 'advanceWidthMax': <built-in function max>, 'ascent': <built-in function max>, 'caretOffset': <function first>, 'caretSlopeRise': <function first>, 'caretSlopeRun': <function first>, 'descent': <built-in function min>, 'lineGap': <built-in function max>, 'minLeftSideBearing': <built-in function min>, 'minRightSideBearing': <built-in function min>, 'numberOfHMetrics': <function recalculate>, 'tableTag': <function equal>, 'tableVersion': <built-in function max>, 'xMaxExtent': <built-in function max>}
recalc(ttFont)[source]
toXML(writer, ttFont)[source]

_h_m_t_x

class fontTools.ttLib.tables._h_m_t_x.table__h_m_t_x(tag=None)[source]
advanceName = 'width'
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
headerTag = 'hhea'
longMetricFormat = 'Hh'
merge(m, tables)
mergeMap = {'metrics': <function sumDicts>, 'tableTag': <function equal>}
numberOfMetricsName = 'numberOfHMetrics'
sideBearingName = 'lsb'
subset_glyphs(s)
toXML(writer, ttFont)[source]

_k_e_r_n

class fontTools.ttLib.tables._k_e_r_n.KernTable_format_0(apple=False)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
format = 0
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
version = 0
class fontTools.ttLib.tables._k_e_r_n.KernTable_format_unkown(format)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables._k_e_r_n.table__k_e_r_n(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
getkern(format)[source]
merge(m, tables)
prune_pre_subset(font, options)
subset_glyphs(s)
toXML(writer, ttFont)[source]

_l_c_a_r

class fontTools.ttLib.tables._l_c_a_r.table__l_c_a_r(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
subset_glyphs(s)
toXML(writer, font)

_l_o_c_a

class fontTools.ttLib.tables._l_o_c_a.table__l_o_c_a(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['glyf']
fromXML(name, attrs, content, ttFont)
merge(m, tables)
mergeMap = {'*': <function recalculate>, 'tableTag': <function equal>}
set(locations)[source]
toXML(writer, ttFont)[source]

_l_t_a_g

class fontTools.ttLib.tables._l_t_a_g.table__l_t_a_g(tag=None)[source]
addTag(tag)[source]

Add ‘tag’ to the list of langauge tags if not already there.

Returns the integer index of ‘tag’ in the list of all tags.

compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

_m_a_x_p

class fontTools.ttLib.tables._m_a_x_p.table__m_a_x_p(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['glyf']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap = {'*': <built-in function max>, 'maxFunctionDefs': <function first>, 'maxInstructionDefs': <function first>, 'maxStorage': <function first>, 'numGlyphs': <built-in function sum>, 'tableTag': <function equal>, 'tableVersion': <function equal>}
prune_pre_subset(font, options)
recalc(ttFont)[source]

Recalculate the font bounding box, and most other maxp values except for the TT instructions values. Also recalculate the value of bit 1 of the flags field and the font bounding box of the ‘head’ table.

testrepr()[source]
toXML(writer, ttFont)[source]

_m_e_t_a

class fontTools.ttLib.tables._m_e_t_a.table__m_e_t_a(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

_m_o_r_t

class fontTools.ttLib.tables._m_o_r_t.table__m_o_r_t(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
toXML(writer, font)

_m_o_r_x

class fontTools.ttLib.tables._m_o_r_x.table__m_o_r_x(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
toXML(writer, font)

_n_a_m_e

class fontTools.ttLib.tables._n_a_m_e.NameRecord[source]
encodingIsUnicodeCompatible()[source]
fromXML(name, attrs, content, ttFont)[source]
getEncoding(default='ascii')[source]

Returns the Python encoding name for this name entry based on its platformID, platEncID, and langID. If encoding for these values is not known, by default ‘ascii’ is returned. That can be overriden by passing a value to the default argument.

isUnicode()[source]
toBytes(errors='strict')[source]

If self.string is a bytes object, return it; otherwise try encoding the Unicode string in self.string to bytes using the encoding of this entry as returned by self.getEncoding(); Note that self.getEncoding() returns ‘ascii’ if the encoding is unknown to the library.

If the Unicode string cannot be encoded to bytes in the chosen encoding, the error is handled according to the errors parameter to this function, which is passed to the underlying encode() function; by default it throws a UnicodeEncodeError exception.

toStr(errors='strict')

If self.string is a Unicode string, return it; otherwise try decoding the bytes in self.string to a Unicode string using the encoding of this entry as returned by self.getEncoding(); Note that self.getEncoding() returns ‘ascii’ if the encoding is unknown to the library.

Certain heuristics are performed to recover data from bytes that are ill-formed in the chosen encoding, or that otherwise look misencoded (mostly around bad UTF-16BE encoded bytes, or bytes that look like UTF-16BE but marked otherwise). If the bytes are ill-formed and the heuristics fail, the error is handled according to the errors parameter to this function, which is passed to the underlying decode() function; by default it throws a UnicodeDecodeError exception.

Note: The mentioned heuristics mean that roundtripping a font to XML and back to binary might recover some misencoded data whereas just loading the font and saving it back will not change them.

toUnicode(errors='strict')[source]

If self.string is a Unicode string, return it; otherwise try decoding the bytes in self.string to a Unicode string using the encoding of this entry as returned by self.getEncoding(); Note that self.getEncoding() returns ‘ascii’ if the encoding is unknown to the library.

Certain heuristics are performed to recover data from bytes that are ill-formed in the chosen encoding, or that otherwise look misencoded (mostly around bad UTF-16BE encoded bytes, or bytes that look like UTF-16BE but marked otherwise). If the bytes are ill-formed and the heuristics fail, the error is handled according to the errors parameter to this function, which is passed to the underlying decode() function; by default it throws a UnicodeDecodeError exception.

Note: The mentioned heuristics mean that roundtripping a font to XML and back to binary might recover some misencoded data whereas just loading the font and saving it back will not change them.

toXML(writer, ttFont)[source]
fontTools.ttLib.tables._n_a_m_e.makeName(string, nameID, platformID, platEncID, langID)[source]
class fontTools.ttLib.tables._n_a_m_e.table__n_a_m_e(tag=None)[source]
addMultilingualName(names, ttFont=None, nameID=None, windows=True, mac=True, minNameID=0)[source]

Add a multilingual name, returning its name ID

‘names’ is a dictionary with the name in multiple languages, such as {‘en’: ‘Pale’, ‘de’: ‘Blaß’, ‘de-CH’: ‘Blass’}. The keys can be arbitrary IETF BCP 47 language codes; the values are Unicode strings.

‘ttFont’ is the TTFont to which the names are added, or None. If present, the font’s ‘ltag’ table can get populated to store exotic language codes, which allows encoding names that otherwise cannot get encoded at all.

‘nameID’ is the name ID to be used, or None to let the library find an existing set of name records that match, or pick an unused name ID.

If ‘windows’ is True, a platformID=3 name record will be added. If ‘mac’ is True, a platformID=1 name record will be added.

If the ‘nameID’ argument is None, the created nameID will not be less than the ‘minNameID’ argument.

addName(string, platforms=((1, 0, 0), (3, 1, 1033)), minNameID=255)[source]

Add a new name record containing ‘string’ for each (platformID, platEncID, langID) tuple specified in the ‘platforms’ list.

The nameID is assigned in the range between ‘minNameID’+1 and 32767 (inclusive), following the last nameID in the name table. If no ‘platforms’ are specified, two English name records are added, one for the Macintosh (platformID=0), and one for the Windows platform (3).

The ‘string’ must be a Unicode string, so it can be encoded with different, platform-specific encodings.

Return the new nameID.

compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['ltag']
findMultilingualName(names, windows=True, mac=True, minNameID=0)[source]

Return the name ID of an existing multilingual name that matches the ‘names’ dictionary, or None if not found.

‘names’ is a dictionary with the name in multiple languages, such as {‘en’: ‘Pale’, ‘de’: ‘Blaß’, ‘de-CH’: ‘Blass’}. The keys can be arbitrary IETF BCP 47 language codes; the values are Unicode strings.

If ‘windows’ is True, the returned name ID is guaranteed exist for all requested languages for platformID=3 and platEncID=1. If ‘mac’ is True, the returned name ID is guaranteed to exist for all requested languages for platformID=1 and platEncID=0.

The returned name ID will not be less than the ‘minNameID’ argument.

fromXML(name, attrs, content, ttFont)[source]
getDebugName(nameID)[source]
getName(nameID, platformID, platEncID, langID=None)[source]
merge(m, tables)
mergeMap = {'names': <function first>, 'tableTag': <function equal>}
prune_pre_subset(font, options)
removeNames(nameID=None, platformID=None, platEncID=None, langID=None)[source]

Remove any name records identified by the given combination of ‘nameID’, ‘platformID’, ‘platEncID’ and ‘langID’.

setName(string, nameID, platformID, platEncID, langID)[source]

Set the ‘string’ for the name record identified by ‘nameID’, ‘platformID’, ‘platEncID’ and ‘langID’. If a record with that nameID doesn’t exist, create it and append to the name table.

‘string’ can be of type str (unicode in PY2) or bytes. In the latter case, it is assumed to be already encoded with the correct plaform-specific encoding identified by the (platformID, platEncID, langID) triplet. A warning is issued to prevent unexpected results.

toXML(writer, ttFont)[source]

_o_p_b_d

class fontTools.ttLib.tables._o_p_b_d.table__o_p_b_d(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
subset_glyphs(s)
toXML(writer, font)

_p_o_s_t

fontTools.ttLib.tables._p_o_s_t.packPStrings(strings)[source]
class fontTools.ttLib.tables._p_o_s_t.table__p_o_s_t(tag=None)[source]
build_psNameMapping(ttFont)[source]
compile(ttFont)[source]
decode_format_1_0(data, ttFont)[source]
decode_format_2_0(data, ttFont)[source]
decode_format_3_0(data, ttFont)[source]
decode_format_4_0(data, ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
encode_format_2_0(ttFont)[source]
encode_format_4_0(ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
getGlyphOrder()[source]

This function will get called by a ttLib.TTFont instance. Do not call this function yourself, use TTFont().getGlyphOrder() or its relatives instead!

merge(m, tables)
mergeMap = {'*': <function first>, 'extraNames': <function <lambda>>, 'formatType': <built-in function max>, 'isFixedPitch': <built-in function min>, 'mapping': <function onlyExisting.<locals>.wrapper>, 'maxMemType1': <function <lambda>>, 'maxMemType42': <function <lambda>>, 'minMemType1': <built-in function max>, 'minMemType42': <built-in function max>, 'tableTag': <function equal>}
prune_pre_subset(font, options)
subset_glyphs(s)
toXML(writer, ttFont)[source]
fontTools.ttLib.tables._p_o_s_t.unpackPStrings(data)[source]

_p_r_e_p

class fontTools.ttLib.tables._p_r_e_p.table__p_r_e_p(tag=None)[source]
compile(ttFont)
decompile(data, ttFont)
dependencies = []
fromXML(name, attrs, content, ttFont)
merge(m, tables)
mergeMap(lst)
toXML(writer, ttFont)

_p_r_o_p

class fontTools.ttLib.tables._p_r_o_p.table__p_r_o_p(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
subset_glyphs(s)
toXML(writer, font)

_s_b_i_x

class fontTools.ttLib.tables._s_b_i_x.sbixStrikeOffset[source]
class fontTools.ttLib.tables._s_b_i_x.table__s_b_i_x(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
subset_glyphs(s)
toXML(xmlWriter, ttFont)[source]

_t_r_a_k

class fontTools.ttLib.tables._t_r_a_k.TrackData(initialdata={})[source]
clear() → None. Remove all items from D.
compile(offset)[source]
decompile(data, offset)[source]
fromXML(name, attrs, content, ttFont)[source]
get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D’s items
keys() → a set-like object providing a view on D’s keys[source]
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
sizes()[source]
toXML(writer, ttFont)[source]
tracks()

D.keys() -> a set-like object providing a view on D’s keys

update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → an object providing a view on D’s values
class fontTools.ttLib.tables._t_r_a_k.TrackTableEntry(values={}, nameIndex=None)[source]
clear() → None. Remove all items from D.
fromXML(name, attrs, content, ttFont)[source]
get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D’s items
keys() → a set-like object providing a view on D’s keys[source]
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
sizes()

D.keys() -> a set-like object providing a view on D’s keys

toXML(writer, ttFont)[source]
update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → an object providing a view on D’s values
class fontTools.ttLib.tables._t_r_a_k.table__t_r_a_k(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['name']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

_v_h_e_a

class fontTools.ttLib.tables._v_h_e_a.table__v_h_e_a(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['vmtx', 'glyf', 'CFF ', 'CFF2']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
mergeMap = {'*': <function equal>, 'advanceHeightMax': <built-in function max>, 'ascent': <built-in function max>, 'caretOffset': <function first>, 'caretSlopeRise': <function first>, 'caretSlopeRun': <function first>, 'descent': <built-in function min>, 'lineGap': <built-in function max>, 'minBottomSideBearing': <built-in function min>, 'minTopSideBearing': <built-in function min>, 'numberOfVMetrics': <function recalculate>, 'tableTag': <function equal>, 'tableVersion': <built-in function max>, 'yMaxExtent': <built-in function max>}
recalc(ttFont)[source]
property reserved0
toXML(writer, ttFont)[source]

_v_m_t_x

class fontTools.ttLib.tables._v_m_t_x.table__v_m_t_x(tag=None)[source]
advanceName = 'height'
compile(ttFont)
decompile(data, ttFont)
dependencies = []
fromXML(name, attrs, content, ttFont)
headerTag = 'vhea'
longMetricFormat = 'Hh'
merge(m, tables)
mergeMap = {'metrics': <function sumDicts>, 'tableTag': <function equal>}
numberOfMetricsName = 'numberOfVMetrics'
sideBearingName = 'tsb'
subset_glyphs(s)
toXML(writer, ttFont)

asciiTable

class fontTools.ttLib.tables.asciiTable.asciiTable(tag=None)[source]
compile(ttFont)
decompile(data, ttFont)
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

B_A_S_E

class fontTools.ttLib.tables.B_A_S_E_.table_B_A_S_E_(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
mergeMap = {'table': <function mergeObjects>, 'tableTag': <function onlyExisting.<locals>.wrapper>}
toXML(writer, font)

BitmapGlyphMetrics

class fontTools.ttLib.tables.BitmapGlyphMetrics.BigGlyphMetrics[source]
binaryFormat = '\n > # big endian\n height: B\n width: B\n horiBearingX: b\n horiBearingY: b\n horiAdvance: B\n vertBearingX: b\n vertBearingY: b\n vertAdvance: B\n'
fromXML(name, attrs, content, ttFont)
toXML(writer, ttFont)
class fontTools.ttLib.tables.BitmapGlyphMetrics.BitmapGlyphMetrics[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables.BitmapGlyphMetrics.SmallGlyphMetrics[source]
binaryFormat = '\n > # big endian\n height: B\n width: B\n BearingX: b\n BearingY: b\n Advance: B\n'
fromXML(name, attrs, content, ttFont)
toXML(writer, ttFont)

C_B_D_T

class fontTools.ttLib.tables.C_B_D_T_.ColorBitmapGlyph(data, ttFont)[source]
fileExtension = '.png'
fromXML(name, attrs, content, ttFont)
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>)}
class fontTools.ttLib.tables.C_B_D_T_.cbdt_bitmap_format_17(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.png'
fromXML(name, attrs, content, ttFont)
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>)}
class fontTools.ttLib.tables.C_B_D_T_.cbdt_bitmap_format_18(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.png'
fromXML(name, attrs, content, ttFont)
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>)}
class fontTools.ttLib.tables.C_B_D_T_.cbdt_bitmap_format_19(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.png'
fromXML(name, attrs, content, ttFont)
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>)}
class fontTools.ttLib.tables.C_B_D_T_.table_C_B_D_T_(tag=None)[source]
compile(ttFont)
decompile(data, ttFont)
dependencies = []
fromXML(name, attrs, content, ttFont)
getImageFormatClass(imageFormat)[source]
locatorName = 'CBLC'
merge(m, tables)
subset_glyphs(s)
toXML(writer, ttFont)

C_B_L_C

class fontTools.ttLib.tables.C_B_L_C_.table_C_B_L_C_(tag=None)[source]
compile(ttFont)
decompile(data, ttFont)
dependencies = ['CBDT']
fromXML(name, attrs, content, ttFont)
getIndexFormatClass(indexFormat)
merge(m, tables)
subset_glyphs(s)
toXML(writer, ttFont)

C_F_F

class fontTools.ttLib.tables.C_F_F_.table_C_F_F_(tag=None)[source]
closure_glyphs(s)
compile(otFont)[source]
decompile(data, otFont)[source]
dependencies = []
desubroutinize()
fromXML(name, attrs, content, otFont)[source]
getGlyphOrder()[source]
haveGlyphNames()[source]
merge(m, tables)
prune_post_subset(ttfFont, options)
prune_pre_subset(font, options)
remove_hints()
remove_unused_subroutines()
setGlyphOrder(glyphOrder)[source]
subset_glyphs(s)
toXML(writer, otFont)[source]

C_F_F__2

class fontTools.ttLib.tables.C_F_F__2.table_C_F_F__2(tag=None)[source]
closure_glyphs(s)
compile(otFont)[source]
decompile(data, otFont)[source]
dependencies = []
desubroutinize()
fromXML(name, attrs, content, otFont)
getGlyphOrder()
haveGlyphNames()
merge(m, tables)
prune_post_subset(ttfFont, options)
prune_pre_subset(font, options)
remove_hints()
remove_unused_subroutines()
setGlyphOrder(glyphOrder)
subset_glyphs(s)
toXML(writer, otFont)

C_O_L_R

class fontTools.ttLib.tables.C_O_L_R_.LayerRecord(name=None, colorID=None)[source]
fromXML(eltname, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables.C_O_L_R_.table_C_O_L_R_(tag=None)[source]

This table is structured so that you can treat it like a dictionary keyed by glyph name. ttFont[‘COLR’][<glyphName>] will return the color layers for any glyph ttFont[‘COLR’][<glyphName>] = <value> will set the color layers for any glyph.

closure_glyphs(s)
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
subset_glyphs(s)
toXML(writer, ttFont)[source]

C_P_A_L

class fontTools.ttLib.tables.C_P_A_L_.Color(blue, green, red, alpha)[source]
alpha

Alias for field number 3

blue

Alias for field number 0

count(value, /)

Return number of occurrences of value.

classmethod fromHex(value)[source]
classmethod fromRGBA(red, green, blue, alpha)[source]
green

Alias for field number 1

hex()[source]
index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

red

Alias for field number 2

toXML(writer, ttFont, index=None)[source]
class fontTools.ttLib.tables.C_P_A_L_.table_C_P_A_L_(tag=None)[source]
DEFAULT_PALETTE_TYPE = 0
NO_NAME_ID = 65535
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
prune_post_subset(font, options)
toXML(writer, ttFont)[source]

D_S_I_G

class fontTools.ttLib.tables.D_S_I_G_.SignatureRecord[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
fontTools.ttLib.tables.D_S_I_G_.b64encode(b)[source]
fontTools.ttLib.tables.D_S_I_G_.pem_spam(l, spam={'': True, '-----BEGIN PKCS7-----': True, '-----END PKCS7-----': True})
class fontTools.ttLib.tables.D_S_I_G_.table_D_S_I_G_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
prune_pre_subset(font, options)
toXML(xmlWriter, ttFont)[source]

DefaultTable

class fontTools.ttLib.tables.DefaultTable.DefaultTable(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont, **kwargs)[source]

E_B_D_T

class fontTools.ttLib.tables.E_B_D_T_.BitAlignedBitmapMixin[source]
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)[source]
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)[source]
class fontTools.ttLib.tables.E_B_D_T_.BitmapGlyph(data, ttFont)[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)[source]
getFormat()[source]
readData(name, attrs, content, ttFont)[source]
readMetrics(name, attrs, content, ttFont)[source]
toXML(strikeIndex, glyphName, writer, ttFont)[source]
writeData(strikeIndex, glyphName, writer, ttFont)[source]
writeMetrics(writer, ttFont)[source]
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
fontTools.ttLib.tables.E_B_D_T_.BitmapPlusBigMetricsMixin

alias of fontTools.ttLib.tables.E_B_D_T_._createBitmapPlusMetricsMixin.<locals>.BitmapPlusMetricsMixin

fontTools.ttLib.tables.E_B_D_T_.BitmapPlusSmallMetricsMixin

alias of fontTools.ttLib.tables.E_B_D_T_._createBitmapPlusMetricsMixin.<locals>.BitmapPlusMetricsMixin

class fontTools.ttLib.tables.E_B_D_T_.ByteAlignedBitmapMixin[source]
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)[source]
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)[source]
class fontTools.ttLib.tables.E_B_D_T_.ComponentBitmapGlyph(data, ttFont)[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)[source]
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)[source]
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.EbdtComponent[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_1(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_2(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_5(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_6(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_7(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
getRow(row, bitDepth=1, metrics=None, reverseBytes=False)
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
setRows(dataRows, bitDepth=1, metrics=None, reverseBytes=False)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_8(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.ebdt_bitmap_format_9(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fileExtension = '.bin'
fromXML(name, attrs, content, ttFont)
getFormat()
readData(name, attrs, content, ttFont)
readMetrics(name, attrs, content, ttFont)
toXML(strikeIndex, glyphName, writer, ttFont)
writeData(strikeIndex, glyphName, writer, ttFont)
writeMetrics(writer, ttFont)
xmlDataFunctions = {'bitwise': (<function _writeBitwiseImageData>, <function _readBitwiseImageData>), 'extfile': (<function _writeExtFileImageData>, <function _readExtFileImageData>), 'raw': (<function _writeRawImageData>, <function _readRawImageData>), 'row': (<function _writeRowImageData>, <function _readRowImageData>)}
class fontTools.ttLib.tables.E_B_D_T_.table_E_B_D_T_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
getImageFormatClass(imageFormat)[source]
locatorName = 'EBLC'
merge(m, tables)
subset_glyphs(s)
toXML(writer, ttFont)[source]

E_B_L_C

class fontTools.ttLib.tables.E_B_L_C_.BitmapSizeTable[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables.E_B_L_C_.EblcIndexSubTable(data, ttFont)[source]
compile(ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
padBitmapData(data)[source]
readMetrics(name, attrs, content, ttFont)[source]
removeSkipGlyphs()[source]
toXML(writer, ttFont)[source]
writeMetrics(writer, ttFont)[source]
class fontTools.ttLib.tables.E_B_L_C_.FixedSizeIndexSubTableMixin[source]
padBitmapData(data)[source]
readMetrics(name, attrs, content, ttFont)[source]
writeMetrics(writer, ttFont)[source]
class fontTools.ttLib.tables.E_B_L_C_.SbitLineMetrics[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(name, writer, ttFont)[source]
class fontTools.ttLib.tables.E_B_L_C_.Strike[source]
fromXML(name, attrs, content, ttFont, locator)[source]
toXML(strikeIndex, writer, ttFont)[source]
class fontTools.ttLib.tables.E_B_L_C_.eblc_index_sub_table_1(data, ttFont)[source]
compile(ttFont)
decompile()
fromXML(name, attrs, content, ttFont)
padBitmapData(data)
readMetrics(name, attrs, content, ttFont)
removeSkipGlyphs()
toXML(writer, ttFont)
writeMetrics(writer, ttFont)
class fontTools.ttLib.tables.E_B_L_C_.eblc_index_sub_table_2(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fromXML(name, attrs, content, ttFont)
padBitmapData(data)
readMetrics(name, attrs, content, ttFont)
removeSkipGlyphs()
toXML(writer, ttFont)
writeMetrics(writer, ttFont)
class fontTools.ttLib.tables.E_B_L_C_.eblc_index_sub_table_3(data, ttFont)[source]
compile(ttFont)
decompile()
fromXML(name, attrs, content, ttFont)
padBitmapData(data)
readMetrics(name, attrs, content, ttFont)
removeSkipGlyphs()
toXML(writer, ttFont)
writeMetrics(writer, ttFont)
class fontTools.ttLib.tables.E_B_L_C_.eblc_index_sub_table_4(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fromXML(name, attrs, content, ttFont)
padBitmapData(data)
readMetrics(name, attrs, content, ttFont)
removeSkipGlyphs()
toXML(writer, ttFont)
writeMetrics(writer, ttFont)
class fontTools.ttLib.tables.E_B_L_C_.eblc_index_sub_table_5(data, ttFont)[source]
compile(ttFont)[source]
decompile()[source]
fromXML(name, attrs, content, ttFont)
padBitmapData(data)
readMetrics(name, attrs, content, ttFont)
removeSkipGlyphs()
toXML(writer, ttFont)
writeMetrics(writer, ttFont)
class fontTools.ttLib.tables.E_B_L_C_.table_E_B_L_C_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['EBDT']
fromXML(name, attrs, content, ttFont)[source]
getIndexFormatClass(indexFormat)[source]
merge(m, tables)
subset_glyphs(s)
toXML(writer, ttFont)[source]

F__e_a_t

class fontTools.ttLib.tables.F__e_a_t.Feature[source]
class fontTools.ttLib.tables.F__e_a_t.table_F__e_a_t(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

F_F_T_M

class fontTools.ttLib.tables.F_F_T_M_.table_F_F_T_M_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

G__l_a_t

class fontTools.ttLib.tables.G__l_a_t.table_G__l_a_t(tag=None)[source]

Support Graphite Glat tables

compile(ttFont)[source]
compileAttributes12(attrs, fmt)[source]
compileAttributes3(attrs)[source]
decompile(data, ttFont)[source]
decompileAttributes12(data, fmt)[source]
decompileAttributes3(data)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

G__l_o_c

class fontTools.ttLib.tables.G__l_o_c.table_G__l_o_c(tag=None)[source]

Support Graphite Gloc tables

compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['Glat']
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
set(locations)[source]
toXML(writer, ttFont)[source]

G_D_E_F

class fontTools.ttLib.tables.G_D_E_F_.table_G_D_E_F_(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
mergeMap = {'table': <function mergeObjects>, 'tableTag': <function onlyExisting.<locals>.wrapper>}
prune_post_subset(font, options)
subset_glyphs(s)
toXML(writer, font)

G_M_A_P

class fontTools.ttLib.tables.G_M_A_P_.GMAPRecord(uv=0, cid=0, gid=0, ggid=0, name='')[source]
compile(ttFont)[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables.G_M_A_P_.table_G_M_A_P_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

G_P_K_G

class fontTools.ttLib.tables.G_P_K_G_.table_G_P_K_G_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

G_P_O_S

class fontTools.ttLib.tables.G_P_O_S_.table_G_P_O_S_(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
mergeMap = {'table': <function mergeObjects>, 'tableTag': <function onlyExisting.<locals>.wrapper>}
neuter_lookups(lookup_indices)

Sets lookups not in lookup_indices to None.

prune_features()

Remove unreferenced features

prune_lookups(remap=True)

Remove (default) or neuter unreferenced lookups

prune_post_subset(font, options)
prune_pre_subset(font, options)
remove_redundant_langsys()
retain_empty_scripts()
subset_feature_tags(feature_tags)
subset_glyphs(s)
subset_lookups(lookup_indices)

Retains specified lookups, then removes empty features, language systems, and scripts.

subset_script_tags(tags)
toXML(writer, font)

G_S_U_B

class fontTools.ttLib.tables.G_S_U_B_.table_G_S_U_B_(tag=None)[source]
closure_glyphs(s)
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
mergeMap = {'table': <function mergeObjects>, 'tableTag': <function onlyExisting.<locals>.wrapper>}
neuter_lookups(lookup_indices)

Sets lookups not in lookup_indices to None.

prune_features()

Remove unreferenced features

prune_lookups(remap=True)

Remove (default) or neuter unreferenced lookups

prune_post_subset(font, options)
prune_pre_subset(font, options)
remove_redundant_langsys()
retain_empty_scripts()
subset_feature_tags(feature_tags)
subset_glyphs(s)
subset_lookups(lookup_indices)

Retains specified lookups, then removes empty features, language systems, and scripts.

subset_script_tags(tags)
toXML(writer, font)

grUtils

fontTools.ttLib.tables.grUtils.bininfo(num, size=1)[source]
fontTools.ttLib.tables.grUtils.compress(scheme, data)[source]
fontTools.ttLib.tables.grUtils.decompress(data)[source]
fontTools.ttLib.tables.grUtils.entries(attributes, sameval=False)[source]
fontTools.ttLib.tables.grUtils.num2tag(n)[source]
fontTools.ttLib.tables.grUtils.tag2num(n)[source]

H_V_A_R

class fontTools.ttLib.tables.H_V_A_R_.table_H_V_A_R_(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
subset_glyphs(s)
toXML(writer, font)

J_S_T_F

class fontTools.ttLib.tables.J_S_T_F_.table_J_S_T_F_(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
mergeMap = {'table': <function mergeObjects>, 'tableTag': <function onlyExisting.<locals>.wrapper>}
toXML(writer, font)

L_T_S_H

class fontTools.ttLib.tables.L_T_S_H_.table_L_T_S_H_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

M_A_T_H

class fontTools.ttLib.tables.M_A_T_H_.table_M_A_T_H_(tag=None)[source]
closure_glyphs(s)
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
mergeMap = {'table': <function mergeObjects>, 'tableTag': <function onlyExisting.<locals>.wrapper>}
subset_glyphs(s)
toXML(writer, font)

M_E_T_A

class fontTools.ttLib.tables.M_E_T_A_.GlyphRecord[source]
compile(parentTable)[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
class fontTools.ttLib.tables.M_E_T_A_.StringRecord[source]
compile(parentTable)[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
fontTools.ttLib.tables.M_E_T_A_.getLabelString(labelID)[source]
fontTools.ttLib.tables.M_E_T_A_.mapUTF8toXML(string)[source]
fontTools.ttLib.tables.M_E_T_A_.mapXMLToUTF8(string)[source]
class fontTools.ttLib.tables.M_E_T_A_.table_M_E_T_A_(tag=None)[source]
compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = []
fromXML(name, attrs, content, ttFont)[source]
merge(m, tables)
toXML(writer, ttFont)[source]

M_V_A_R

class fontTools.ttLib.tables.M_V_A_R_.table_M_V_A_R_(tag=None)[source]
compile(font)

Create a top-level OTTableWriter 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.

decompile(data, font)
dependencies = []
fromXML(name, attrs, content, font)
merge(m, tables)
toXML(writer, font)

O_S_2f_2

class fontTools.ttLib.tables.O_S_2f_2.Panose[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
fontTools.ttLib.tables.O_S_2f_2.intersectUnicodeRanges(unicodes, inverse=False)[source]

Intersect a sequence of (int) Unicode codepoints with the Unicode block ranges defined in the OpenType specification v1.7, and return the set of ‘ulUnicodeRanges’ bits for which there is at least ONE intersection. If ‘inverse’ is True, return the the bits for which there is NO intersection.

>>> intersectUnicodeRanges([0x0410]) == {9}
True
>>> intersectUnicodeRanges([0x0410, 0x1F000]) == {9, 57, 122}
True
>>> intersectUnicodeRanges([0x0410, 0x1F000], inverse=True) == (
...     set(range(len(OS2_UNICODE_RANGES))) - {9, 57, 122})
True
class fontTools.ttLib.tables.O_S_2f_2.table_O_S_2f_2(tag=None)[source]

the OS/2 table

compile(ttFont)[source]
decompile(data, ttFont)[source]
dependencies = ['head']
fromXML(name, attrs, content, ttFont)[source]
property fsFirstCharIndex
property fsLastCharIndex
getUnicodeRanges()[source]

Return the set of ‘ulUnicodeRange*’ bits currently enabled.

merge(m, tables)
mergeMap = {'*': <function first>, 'fsFirstCharIndex': <built-in function min>, 'fsLastCharIndex': <built-in function max>, 'fsType': <function mergeOs2FsType>, 'panose': <function first>, 'sCapHeight': <function onlyExisting.<locals>.wrapper>, 'sTypoAscender': <built-in function max>, 'sTypoDescender': <built-in function min>, 'sTypoLineGap': <built-in function max>, 'sxHeight': <function onlyExisting.<locals>.wrapper>, 'tableTag': <function equal>, 'ulCodePageRange1': <function onlyExisting.<locals>.wrapper>, 'ulCodePageRange2': <function onlyExisting.<locals>.wrapper>, 'ulUnicodeRange1': <function bitwise_or>, 'ulUnicodeRange2': <function bitwise_or>, 'ulUnicodeRange3': <function bitwise_or>, 'ulUnicodeRange4': <function bitwise_or>, 'usBreakChar': <function onlyExisting.<locals>.wrapper>, 'usDefaultChar': <function onlyExisting.<locals>.wrapper>, 'usLowerOpticalPointSize': <function onlyExisting.<locals>.wrapper>, 'usMaxContext': <function onlyExisting.<locals>.wrapper>, 'usUpperOpticalPointSize': <function onlyExisting.<locals>.wrapper>, 'usWinAscent': <built-in function max>, 'usWinDescent': <built-in function max>, 'version': <built-in function max>, 'xAvgCharWidth': <function avg_int>}
recalcUnicodeRanges(ttFont, pruneOnly=False)[source]

Intersect the codepoints in the font’s Unicode cmap subtables with the Unicode block ranges defined in the OpenType specification (v1.7), and set the respective ‘ulUnicodeRange*’ bits if there is at least ONE intersection. If ‘pruneOnly’ is True, only clear unused bits with NO intersection.

setUnicodeRanges(bits)[source]

Set the ‘ulUnicodeRange*’ fields to the specified ‘bits’.

toXML(writer, ttFont)[source]
updateFirstAndLastCharIndex(ttFont)[source]
property usMaxContex

otBase

class fontTools.ttLib.tables.otBase.BaseTTXConverter(tag=None)[source]

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.

compile(font)[source]

Create a top-level OTTableWriter 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.

decompile(data, font)[source]
dependencies = []
fromXML(name, attrs, content, font)[source]
merge(m, tables)
toXML(writer, font)[source]
class fontTools.ttLib.tables.otBase.BaseTable[source]

Generic base class for all OpenType (sub)tables.

compile(writer, font)[source]
decompile(reader, font)[source]
ensureDecompiled()[source]
fromXML(name, attrs, content, font)[source]
getConverterByName(name)[source]
getConverters()[source]
classmethod getRecordSize(reader)[source]
populateDefaults(propagator=None)[source]
readFormat(reader)[source]
toXML(xmlWriter, font, attrs=None, name=None)[source]
toXML2(xmlWriter, font)[source]
writeFormat(writer)[source]
class fontTools.ttLib.tables.otBase.CountReference(table, name, size=None, value=None)[source]

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

getCountData()[source]
getValue()[source]
setValue(value)[source]
class fontTools.ttLib.tables.otBase.FormatSwitchingBaseTable[source]

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

compile(writer, font)
decompile(reader, font)
ensureDecompiled()
fromXML(name, attrs, content, font)
getConverterByName(name)[source]
getConverters()[source]
classmethod getRecordSize(reader)[source]
populateDefaults(propagator=None)
readFormat(reader)[source]
toXML(xmlWriter, font, attrs=None, name=None)[source]
toXML2(xmlWriter, font)
writeFormat(writer)[source]
exception fontTools.ttLib.tables.otBase.OTLOffsetOverflowError(overflowErrorRecord)[source]
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class fontTools.ttLib.tables.otBase.OTTableReader(data, localState=None, offset=0, tableTag=None)[source]

Helper class to retrieve data from an OpenType table.

advance(count)[source]
copy()[source]
data
getSubReader(offset)[source]
localState
offset
pos
readArray(typecode, staticSize, count)[source]
readData(count)[source]
readInt8()[source]
readLong()[source]
readShort()[source]
readTag()[source]
readUInt24()[source]
readUInt8()[source]
readULong()[source]
readUShort()[source]
readUShortArray(count)[source]
readValue(typecode, staticSize)[source]
seek(pos)[source]
tableTag
class fontTools.ttLib.tables.otBase.OTTableWriter(localState=None, tableTag=None, offsetSize=2)[source]

Helper class to gather and assemble data for OpenType tables.

getAllData()[source]

Assemble all data, including all subtables.

getData()[source]

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

getDataLength()[source]

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

getOverflowErrorRecord(item)[source]
getSubWriter(offsetSize=2)[source]
property longOffset
writeCountReference(table, name, size=2, value=None)[source]
writeData(data)[source]
writeInt8(value)[source]
writeLong(value)[source]
writeShort(value)[source]
writeStruct(format, values)[source]
writeSubTable(subWriter)[source]
writeTag(tag)[source]
writeUInt24(value)[source]
writeUInt8(value)[source]
writeULong(value)[source]
writeUShort(value)[source]
writeValue(typecode, value)[source]
class fontTools.ttLib.tables.otBase.OverflowErrorRecord(overflowTuple)[source]
class fontTools.ttLib.tables.otBase.UInt8FormatSwitchingBaseTable[source]
compile(writer, font)
decompile(reader, font)
ensureDecompiled()
fromXML(name, attrs, content, font)
getConverterByName(name)
getConverters()
classmethod getRecordSize(reader)
populateDefaults(propagator=None)
readFormat(reader)[source]
toXML(xmlWriter, font, attrs=None, name=None)
toXML2(xmlWriter, font)
writeFormat(writer)[source]
class fontTools.ttLib.tables.otBase.ValueRecord(valueFormat=None, src=None)[source]
fromXML(name, attrs, content, font)[source]
getFormat()[source]
toXML(xmlWriter, font, valueName, attrs=None)[source]
class fontTools.ttLib.tables.otBase.ValueRecordFactory(valueFormat)[source]

Given a format code, this object convert ValueRecords.

readValueRecord(reader, font)[source]
writeValueRecord(writer, font, valueRecord)[source]
fontTools.ttLib.tables.otBase.getFormatSwitchingBaseTableClass(formatType)[source]
fontTools.ttLib.tables.otBase.packUInt24(value)[source]
fontTools.ttLib.tables.otBase.packUInt8(value)[source]
fontTools.ttLib.tables.otBase.packULong(value)[source]
fontTools.ttLib.tables.otBase.packUShort(value)[source]

otConverters

class fontTools.ttLib.tables.otConverters.AATLookup(name, repeat, aux, tableClass)[source]
BIN_SEARCH_HEADER_SIZE = 10
buildFormat0(writer, font, values)[source]
buildFormat2(writer, font, values)[source]
buildFormat6(writer, font, values)[source]
buildFormat8(writer, font, values)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readFormat0(reader, font)[source]
readFormat2(reader, font)[source]
readFormat4(reader, font)[source]
readFormat6(reader, font)[source]
readFormat8(reader, font)[source]
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
static writeBinSearchHeader(writer, numUnits, unitSize)[source]
writeFormat0(writer, font, values)[source]
writeFormat2(writer, font, segments)[source]
writeFormat6(writer, font, values)[source]
writeFormat8(writer, font, values)[source]
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.AATLookupWithDataOffset(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.BaseConverter(name, repeat, aux, tableClass=None)[source]

Base class for converter objects. Apart from the constructor, this is an abstract class.

getRecordSize(reader)[source]
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)[source]

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)[source]
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.CIDGlyphMap(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Char64(name, repeat, aux, tableClass=None)[source]

An ASCII string with up to 64 characters.

Unused character positions are filled with 0x00 bytes. Used in Apple AAT fonts in the gcid table.

static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 64
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.CompositeMode(name, repeat, aux, tableClass=None)[source]
enumClass

alias of fontTools.ttLib.tables.otTables.CompositeMode

classmethod fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 1
classmethod toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.ComputedInt(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.ComputedUInt8(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 1
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.ComputedULong(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 4
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.ComputedUShort(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 2
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.DeciPoints(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 2
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.DeltaValue(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.ExtSubTable(name, repeat, aux, tableClass=None)[source]
getConverter(tableType, lookupType)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readOffset(reader)
staticSize = 4
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
writeNullOffset(writer)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.ExtendMode(name, repeat, aux, tableClass=None)[source]
enumClass

alias of fontTools.ttLib.tables.otTables.ExtendMode

classmethod fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 1
classmethod toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.F2Dot14(name, repeat, aux, tableClass=None)[source]
static fromString(value)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 2
static toString(value)[source]
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.FeatureParams(name, repeat, aux, tableClass=None)[source]
getConverter(featureTag)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readOffset(reader)
staticSize = 2
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
writeNullOffset(writer)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Fixed(name, repeat, aux, tableClass=None)[source]
static fromString(value)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 4
static toString(value)[source]
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Flags32(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 4
static toString(value)[source]
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.FloatValue(name, repeat, aux, tableClass=None)[source]
static fromString(value)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.GlyphCIDMap(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.GlyphID(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)[source]

Read an array of values from the reader.

staticSize = 2
static toString(value)
typecode = 'H'
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.GlyphID32(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 4
static toString(value)
typecode = 'L'
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Int8(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 1
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.IntValue(name, repeat, aux, tableClass=None)[source]
static fromString(value)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.LTable(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readOffset(reader)[source]
staticSize = 4
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
writeNullOffset(writer)[source]
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Long(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 4
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.LookupFlag(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 2
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.MorxSubtableConverter(name, repeat, aux)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.NameID(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 2
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.STXHeader(name, repeat, aux, tableClass)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Short(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 2
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.SimpleValue(name, repeat, aux, tableClass=None)[source]
static fromString(value)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

static toString(value)[source]
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Struct(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)[source]
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)[source]

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.StructWithLength(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.SubStruct(name, repeat, aux, tableClass=None)[source]
getConverter(tableType, lookupType)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.SubTable(name, repeat, aux, tableClass=None)[source]
getConverter(tableType, lookupType)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readOffset(reader)
staticSize = 2
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
writeNullOffset(writer)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)[source]

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Table(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readOffset(reader)[source]
staticSize = 2
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
writeNullOffset(writer)[source]
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Table24(name, repeat, aux, tableClass=None)[source]
getRecordSize(reader)
read(reader, font, tableDict)

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

readOffset(reader)[source]
staticSize = 3
write(writer, font, tableDict, value, repeatIndex=None)

Write a value to the writer.

writeArray(writer, font, tableDict, values)
writeNullOffset(writer)[source]
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.Tag(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 4
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.UInt24(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 3
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class fontTools.ttLib.tables.otConverters.UInt8(name, repeat, aux, tableClass=None)[source]
static fromString(value)
getRecordSize(reader)
read(reader, font, tableDict)[source]

Read a value from the reader.

readArray(reader, font, tableDict, count)

Read an array of values from the reader.

staticSize = 1
static toString(value)
write(writer, font, tableDict, value, repeatIndex=None)[source]

Write a value to the writer.

writeArray(writer, font, tableDict, values)
xmlRead(attrs, content, font)

Read a value from XML.

xmlWrite(xmlWriter, font, value, name, attrs)

Write a value to XML.

class