# merger

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

class fontTools.varLib.merger.Merger(font=None)

  Bases: `object`

  classmethod merger(clazzes, attrs=(None,))
  classmethod mergersFor(thing, _default={})
  mergeObjects(out, lst, exclude=())
  mergeLists(out, lst)
  mergeThings(out, lst)
  mergeTables(font, master_ttfs, tableTags)

class fontTools.varLib.merger.AligningMerger(font=None)

  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)

  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)

  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)

  Bases: `AligningMerger`

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

  setModel(model)
  mergeThings(out, lst)
  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)

class fontTools.varLib.merger.COLRVariationMerger(model, axisTags, font, allowLayerReuse=True)

  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',))
  checkFormatEnum(out, lst, validate=<function COLRVariationMerger.<lambda>>)
  mergeSparseDict(out, lst)
  mergeAttrs(out, lst, attrs)
  storeMastersForAttr(out, lst, attr)
  storeVariationIndices(varIdxes) → int
  mergeVariableAttrs(out, lst, attrs) → int
  classmethod convertSubTablesToVarType(table)
  static expandPaintColrLayers(colr)

    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.