merger

Merge OpenType Layout tables (GDEF / GPOS / GSUB).

class fontTools.varLib.merger.Merger(font=None)[source]

Bases: object

classmethod merger(clazzes, attrs=(None,))[source]
classmethod mergersFor(thing, _default={})[source]
mergeObjects(out, lst, exclude=())[source]
mergeLists(out, lst)[source]
mergeThings(out, lst)[source]
mergeTables(font, master_ttfs, tableTags)[source]
class fontTools.varLib.merger.AligningMerger(font=None)[source]

Bases: Merger

mergers = {<class 'fontTools.ttLib.tables.otBase.ValueRecord'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.Anchor'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.CursivePos'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.EntryExitRecord'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.GDEF'>: {'GlyphClassDef': <function merge>}, <class 'fontTools.ttLib.tables.otTables.Lookup'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.MarkBasePos'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.MarkMarkPos'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.PairPos'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.PairSet'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.SinglePos'>: {None: <function merge>}}
class fontTools.varLib.merger.InstancerMerger(font, model, location)[source]

Bases: AligningMerger

A merger that takes multiple master fonts, and instantiates an instance.

mergers = {<class 'fontTools.ttLib.tables.otBase.ValueRecord'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.Anchor'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.CaretValue'>: {None: <function merge>}}
class fontTools.varLib.merger.MutatorMerger(font, instancer, deleteVariations=True)[source]

Bases: AligningMerger

A merger that takes a variable font, and instantiates an instance. While there’s no “merging” to be done per se, the operation can benefit from many operations that the aligning merger does.

mergers = {<class 'fontTools.ttLib.tables.otBase.ValueRecord'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.Anchor'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.CaretValue'>: {None: <function merge>}}
class fontTools.varLib.merger.VariationMerger(model, axisTags, font)[source]

Bases: AligningMerger

A merger that takes multiple master fonts, and builds a variable font.

setModel(model)[source]
mergeThings(out, lst)[source]
mergers = {<class 'fontTools.ttLib.tables.otBase.ValueRecord'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.Anchor'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.BaseCoord'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.CaretValue'>: {None: <function merge>}}
fontTools.varLib.merger.buildVarDevTable(store_builder, master_values)[source]
class fontTools.varLib.merger.COLRVariationMerger(model, axisTags, font, allowLayerReuse=True)[source]

Bases: VariationMerger

A specialized VariationMerger that takes multiple master fonts containing COLRv1 tables, and builds a variable COLR font.

COLR tables are special in that variable subtables can be associated with multiple delta-set indices (via VarIndexBase). They also contain tables that must change their type (not simply the Format) as they become variable (e.g. Affine2x3 -> VarAffine2x3) so this merger takes care of that too.

mergers = {<class 'fontTools.ttLib.tables.otTables.Affine2x3'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.BaseGlyphList'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.ClipBox'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.ClipList'>: {'clips': <function merge>}, <class 'fontTools.ttLib.tables.otTables.ColorLine'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.ColorStop'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.LayerList'>: {None: <function merge>}, <class 'fontTools.ttLib.tables.otTables.Paint'>: {None: <function merge>}}
mergeTables(font, master_ttfs, tableTags=('COLR',))[source]
checkFormatEnum(out, lst, validate=<function COLRVariationMerger.<lambda>>)[source]
mergeSparseDict(out, lst)[source]
mergeAttrs(out, lst, attrs)[source]
storeMastersForAttr(out, lst, attr)[source]
storeVariationIndices(varIdxes) int[source]
mergeVariableAttrs(out, lst, attrs) int[source]
classmethod convertSubTablesToVarType(table)[source]
static expandPaintColrLayers(colr)[source]

Rebuild LayerList without PaintColrLayers reuse.

Each base paint graph is fully DFS-traversed (with exception of PaintColrGlyph which are irrelevant for this); any layers referenced via PaintColrLayers are collected into a new LayerList and duplicated when reuse is detected, to ensure that all paints are distinct objects at the end of the process. PaintColrLayers’s FirstLayerIndex/NumLayers are updated so that no overlap is left. Also, any consecutively nested PaintColrLayers are flattened. The COLR table’s LayerList is replaced with the new unique layers. A side effect is also that any layer from the old LayerList which is not referenced by any PaintColrLayers is dropped.