def reloadLayers(self, layerData):
     """
     Reload the layers. This should not be called externally.
     """
     reader = UFOReader(self.font.path)
     # handle the layers
     currentLayerOrder = self.layerOrder
     for layerName, l in list(layerData.get("layers", {}).items()):
         # new layer
         if layerName not in currentLayerOrder:
             glyphSet = reader.getGlyphSet(layerName)
             self.newLayer(layerName, glyphSet)
         # get the layer
         layer = self[layerName]
         # reload the layer info
         if l.get("info"):
             layer.color = None
             layer.lib.clear()
             layer._glyphSet.readLayerInfo(layer)
             self._stampLayerInfoDataState(layer)
         # reload the glyphs
         glyphNames = l.get("glyphNames", [])
         if glyphNames:
             layer.reloadGlyphs(glyphNames)
     # handle the order
     if layerData.get("order", False):
         newLayerOrder = reader.getLayerNames()
         for layerName in self.layerOrder:
             if layerName not in newLayerOrder:
                 newLayerOrder.append(layerName)
         self.layerOrder = newLayerOrder
     # handle the default layer
     if layerData.get("default", False):
         newDefaultLayerName = reader.getDefaultLayerName()
         self.defaultLayer = self[newDefaultLayerName]
Exemple #2
0
 def reloadLayers(self, layerData):
     """
     Reload the layers. This should not be called externally.
     """
     reader = UFOReader(self.font.path)
     # handle the layers
     currentLayerOrder = self.layerOrder
     for layerName, l in list(layerData.get("layers", {}).items()):
         # new layer
         if layerName not in currentLayerOrder:
             glyphSet = reader.getGlyphSet(layerName)
             self.newLayer(layerName, glyphSet)
         # get the layer
         layer = self[layerName]
         # reload the layer info
         if l.get("info"):
             layer.color = None
             layer.lib.clear()
             layer._glyphSet.readLayerInfo(layer)
             self._stampLayerInfoDataState(layer)
         # reload the glyphs
         glyphNames = l.get("glyphNames", [])
         if glyphNames:
             layer.reloadGlyphs(glyphNames)
     # handle the order
     if layerData.get("order", False):
         newLayerOrder = reader.getLayerNames()
         for layerName in self.layerOrder:
             if layerName not in newLayerOrder:
                 newLayerOrder.append(layerName)
         self.layerOrder = newLayerOrder
     # handle the default layer
     if layerData.get("default", False):
         newDefaultLayerName = reader.getDefaultLayerName()
         self.defaultLayer = self[newDefaultLayerName]