Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Lib/mutatorMath/ufo/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,23 @@ def readLocationElement(self, locationElement):
loc[dimName] = xValue
return loc

def readInstance(self, key, makeGlyphs=True, makeKerning=True, makeInfo=True):
""" Read a single instance element.

key: an (attribute, value) tuple used to find the requested instance.

::

<instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular">

"""
attrib, value = key
for instanceElement in self.root.findall('.instances/instance'):
if instanceElement.attrib.get(attrib) == value:
self._readSingleInstanceElement(instanceElement, makeGlyphs=makeGlyphs, makeKerning=makeKerning, makeInfo=makeInfo)
return
raise MutatorError("No instance found with key: (%s, %s)." % key)

def readInstances(self, makeGlyphs=True, makeKerning=True, makeInfo=True):
""" Read all instance elements.

Expand All @@ -612,7 +629,6 @@ def readInstances(self, makeGlyphs=True, makeKerning=True, makeInfo=True):
<instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular">

"""
instanceElements = self.root.findall('.instances/instance')
for instanceElement in self.root.findall('.instances/instance'):
self._readSingleInstanceElement(instanceElement, makeGlyphs=makeGlyphs, makeKerning=makeKerning, makeInfo=makeInfo)

Expand Down