def makeInstance(self, instanceDescriptor,<EOL>doRules=False,<EOL>glyphNames=None,<EOL>pairs=None,<EOL>bend=False):
font = self._instantiateFont(None)<EOL>loc = Location(instanceDescriptor.location)<EOL>anisotropic = False<EOL>locHorizontal = locVertical = loc<EOL>if self.isAnisotropic(loc):<EOL><INDENT>anisotropic = True<EOL>locHorizontal, locVertical = self.splitAnisotropic(loc)<EOL><DEDENT>renameMap = getattr(self.fonts[self.default.name], "<STR_LIT>", None)<EOL>font.kerningGroupConversionRenameMaps = renameMap if renameMap is not None else {'<STR_LIT>': {}, '<STR_LIT>': {}}<EOL>if instanceDescriptor.kerning:<EOL><INDENT>if pairs:<EOL><INDENT>try:<EOL><INDENT>kerningMutator = self.getKerningMutator(pairs=pairs)<EOL>kerningObject = kerningMutator.makeInstance(locHorizontal, bend=bend)<EOL>kerningObject.extractKerning(font)<EOL><DEDENT>except:<EOL><INDENT>self.problems.append("<STR_LIT>" % (loc, traceback.format_exc()))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>kerningMutator = self.getKerningMutator()<EOL>kerningObject = kerningMutator.makeInstance(locHorizontal, bend=bend)<EOL>kerningObject.extractKerning(font)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>infoMutator = self.getInfoMutator()<EOL>if not anisotropic:<EOL><INDENT>infoInstanceObject = infoMutator.makeInstance(loc, bend=bend)<EOL><DEDENT>else:<EOL><INDENT>horizontalInfoInstanceObject = infoMutator.makeInstance(locHorizontal, bend=bend)<EOL>verticalInfoInstanceObject = infoMutator.makeInstance(locVertical, bend=bend)<EOL>infoInstanceObject = (<NUM_LIT:1>,<NUM_LIT:0>)*horizontalInfoInstanceObject + (<NUM_LIT:0>,<NUM_LIT:1>)*verticalInfoInstanceObject<EOL><DEDENT>if self.roundGeometry:<EOL><INDENT>try:<EOL><INDENT>infoInstanceObject = infoInstanceObject.round()<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>infoInstanceObject.extractInfo(font.info)<EOL>font.info.familyName = instanceDescriptor.familyName<EOL>font.info.styleName = instanceDescriptor.styleName<EOL>font.info.postscriptFontName = instanceDescriptor.postScriptFontName <EOL>font.info.styleMapFamilyName = instanceDescriptor.styleMapFamilyName<EOL>font.info.styleMapStyleName = instanceDescriptor.styleMapStyleName<EOL><DEDENT>except:<EOL><INDENT>self.problems.append("<STR_LIT>" % (loc, traceback.format_exc()))<EOL><DEDENT>for sourceDescriptor in self.sources:<EOL><INDENT>if sourceDescriptor.copyInfo:<EOL><INDENT>if self.fonts[sourceDescriptor.name] is not None:<EOL><INDENT>self._copyFontInfo(self.fonts[sourceDescriptor.name].info, font.info)<EOL><DEDENT><DEDENT>if sourceDescriptor.copyLib:<EOL><INDENT>if self.fonts[sourceDescriptor.name] is not None:<EOL><INDENT>for key, value in self.fonts[sourceDescriptor.name].lib.items():<EOL><INDENT>font.lib[key] = value<EOL><DEDENT><DEDENT><DEDENT>if sourceDescriptor.copyGroups:<EOL><INDENT>if self.fonts[sourceDescriptor.name] is not None:<EOL><INDENT>sides = font.kerningGroupConversionRenameMaps.get('<STR_LIT>', {})<EOL>sides.update(font.kerningGroupConversionRenameMaps.get('<STR_LIT>', {}))<EOL>for key, value in self.fonts[sourceDescriptor.name].groups.items():<EOL><INDENT>if key not in sides:<EOL><INDENT>font.groups[key] = value<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if sourceDescriptor.copyFeatures:<EOL><INDENT>if self.fonts[sourceDescriptor.name] is not None:<EOL><INDENT>featuresText = self.fonts[sourceDescriptor.name].features.text<EOL>font.features.text = featuresText<EOL><DEDENT><DEDENT><DEDENT>if glyphNames:<EOL><INDENT>selectedGlyphNames = glyphNames<EOL><DEDENT>else:<EOL><INDENT>selectedGlyphNames = self.glyphNames<EOL><DEDENT>if not '<STR_LIT>' in font.lib.keys():<EOL><INDENT>font.lib['<STR_LIT>'] = selectedGlyphNames<EOL><DEDENT>for glyphName in selectedGlyphNames:<EOL><INDENT>try:<EOL><INDENT>glyphMutator = self.getGlyphMutator(glyphName)<EOL>if glyphMutator is None:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except:<EOL><INDENT>self.problems.append("<STR_LIT>" % (glyphName, traceback.format_exc()))<EOL>continue<EOL><DEDENT>if glyphName in instanceDescriptor.glyphs.keys():<EOL><INDENT>glyphData = instanceDescriptor.glyphs[glyphName]<EOL><DEDENT>else:<EOL><INDENT>glyphData = {}<EOL><DEDENT>font.newGlyph(glyphName)<EOL>font[glyphName].clear()<EOL>if glyphData.get('<STR_LIT>', False):<EOL><INDENT>continue<EOL><DEDENT>glyphInstanceLocation = glyphData.get("<STR_LIT>", instanceDescriptor.location)<EOL>glyphInstanceLocation = Location(glyphInstanceLocation)<EOL>uniValues = []<EOL>neutral = glyphMutator.get(())<EOL>if neutral is not None:<EOL><INDENT>uniValues = neutral[<NUM_LIT:0>].unicodes<EOL><DEDENT>else:<EOL><INDENT>neutralFont = self.getNeutralFont()<EOL>if glyphName in neutralFont:<EOL><INDENT>uniValues = neutralFont[glyphName].unicodes<EOL><DEDENT><DEDENT>glyphInstanceUnicodes = glyphData.get("<STR_LIT>", uniValues)<EOL>note = glyphData.get("<STR_LIT>")<EOL>if note:<EOL><INDENT>font[glyphName] = note<EOL><DEDENT>masters = glyphData.get("<STR_LIT>", None)<EOL>if masters is not None:<EOL><INDENT>items = []<EOL>for glyphMaster in masters:<EOL><INDENT>sourceGlyphFont = glyphMaster.get("<STR_LIT>")<EOL>sourceGlyphName = glyphMaster.get("<STR_LIT>", glyphName)<EOL>m = self.fonts.get(sourceGlyphFont)<EOL>if not sourceGlyphName in m:<EOL><INDENT>continue<EOL><DEDENT>if hasattr(m[sourceGlyphName], "<STR_LIT>"):<EOL><INDENT>sourceGlyph = m[sourceGlyphName].toMathGlyph()<EOL><DEDENT>else:<EOL><INDENT>sourceGlyph = MathGlyph(m[sourceGlyphName])<EOL><DEDENT>sourceGlyphLocation = glyphMaster.get("<STR_LIT:location>")<EOL>items.append((Location(sourceGlyphLocation), sourceGlyph))<EOL><DEDENT>bias, glyphMutator = self.getVariationModel(items, axes=self.serializedAxes, bias=self.newDefaultLocation())<EOL><DEDENT>try:<EOL><INDENT>if not self.isAnisotropic(glyphInstanceLocation):<EOL><INDENT>glyphInstanceObject = glyphMutator.makeInstance(glyphInstanceLocation, bend=bend)<EOL><DEDENT>else:<EOL><INDENT>horizontal, vertical = self.splitAnisotropic(glyphInstanceLocation)<EOL>horizontalGlyphInstanceObject = glyphMutator.makeInstance(horizontal, bend=bend)<EOL>verticalGlyphInstanceObject = glyphMutator.makeInstance(vertical, bend=bend)<EOL>glyphInstanceObject = (<NUM_LIT:1>,<NUM_LIT:0>)*horizontalGlyphInstanceObject + (<NUM_LIT:0>,<NUM_LIT:1>)*verticalGlyphInstanceObject<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>continue<EOL><DEDENT>font.newGlyph(glyphName)<EOL>font[glyphName].clear()<EOL>if self.roundGeometry:<EOL><INDENT>try:<EOL><INDENT>glyphInstanceObject = glyphInstanceObject.round()<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if hasattr(font[glyphName], "<STR_LIT>"):<EOL><INDENT>font[glyphName].fromMathGlyph(glyphInstanceObject)<EOL><DEDENT>else:<EOL><INDENT>glyphInstanceObject.extractGlyph(font[glyphName], onlyGeometry=True)<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pPen = font[glyphName].getPointPen()<EOL>font[glyphName].clear()<EOL>glyphInstanceObject.drawPoints(pPen)<EOL><DEDENT>font[glyphName].width = glyphInstanceObject.width<EOL>font[glyphName].unicodes = glyphInstanceUnicodes<EOL><DEDENT>if doRules:<EOL><INDENT>resultNames = processRules(self.rules, loc, self.glyphNames)<EOL>for oldName, newName in zip(self.glyphNames, resultNames):<EOL><INDENT>if oldName != newName:<EOL><INDENT>swapGlyphNames(font, oldName, newName)<EOL><DEDENT><DEDENT><DEDENT>font.lib['<STR_LIT>'] = list(instanceDescriptor.location.items())<EOL>return font<EOL>
Generate a font object for this instance