def _get_base_baseGlyph(self): value = self._get_baseGlyph() # if the component does not belong to a layer, # it is allowed to have None as its baseGlyph if value is None and self.layer is None: pass else: value = normalizers.normalizeGlyphName(value) return value
def __contains__(self, name): """ Test if the layer contains a glyph with **name**. :: >>> "A" in layer True """ name = normalizers.normalizeGlyphName(name) return self._contains(name)
def __delitem__(self, name): """ Remove the glyph with name from the layer. :: >>> del layer["A"] """ name = normalizers.normalizeGlyphName(name) if name not in self: raise KeyError("No glyph named '%s'." % name) self._removeGlyph(name)
def removeGlyph(self, name): """ Remove the glyph with name from the layer. :: >>> layer.removeGlyph("A") """ name = normalizers.normalizeGlyphName(name) if name not in self: raise ValueError("No glyph with the name '%s' exists." % name) self._removeGlyph(name)
def __getitem__(self, name): """ Get the :class:`BaseGlyph` with name from the layer. :: >>> glyph = layer["A"] """ name = normalizers.normalizeGlyphName(name) if name not in self: raise KeyError("No glyph named '%s'." % name) glyph = self._getItem(name) self._setLayerInGlyph(glyph) return glyph
def __getitem__(self, name): """ Get the :class:`BaseGlyph` with name from the layer. :: >>> glyph = layer["A"] """ name = normalizers.normalizeGlyphName(name) if name not in self: raise ValueError("No glyph named '%s'." % name) glyph = self._getItem(name) self._setLayerInGlyph(glyph) return glyph
def findGlyph(self, glyphName): """ Returns a ``list`` of the group or groups associated with **glyphName**. **glyphName** will be an :ref:`type-string`. If no group is found to contain **glyphName** an empty ``list`` will be returned. :: >>> font.groups.findGlyph("A") ["A_accented"] """ glyphName = normalizers.normalizeGlyphName(glyphName) groupNames = self._findGlyph(glyphName) groupNames = [self.keyNormalizer.__func__( groupName) for groupName in groupNames] return groupNames
def findGlyph(self, glyphName): """ Returns a ``list`` of the group or groups associated with **glyphName**. **glyphName** will be an :ref:`type-string`. If no group is found to contain **glyphName** an empty ``list`` will be returned. :: >>> font.groups.findGlyph("A") ["A_accented"] """ glyphName = normalizers.normalizeGlyphName(glyphName) groupNames = self._findGlyph(glyphName) groupNames = [ self.keyNormalizer.__func__(groupName) for groupName in groupNames ] return groupNames
def __setitem__(self, name, glyph): """ Insert **glyph** into the layer. :: >>> glyph = layer["A"] = otherGlyph This will not insert the glyph directly. Rather, a new glyph will be created and the data from **glyph** will be copied to the new glyph. **name** indicates the name that should be assigned to the glyph after insertion. If **name** is not given, the glyph's original name must be used. If the glyph does not have a name, an error must be raised. The data that will be inserted from **glyph** is the same data as documented in :meth:`BaseGlyph.copy`. """ name = normalizers.normalizeGlyphName(name) if name in self: del self[name] return self._insertGlyph(glyph, name=name)
def insertGlyph(self, glyph, name=None): """ Insert **glyph** into the layer. :: >>> glyph = layer.insertGlyph(otherGlyph, name="A") This does not necessarily insert the glyph directly. In many cases, the environment will create a new glyph and copy the data from **glyph** to the new glyph. **name** indicates the name that should be assigned to the glyph after insertion. If **name** is not given, the glyph's original name must be used. If the glyph does not have a name, an error must be raised. The data that will be inserted from **glyph** is the same data as documented in :meth:`BaseGlyph.copy`. """ if name is None: name = glyph.name name = normalizers.normalizeGlyphName(name) if name in self: self.removeGlyph(name) return self._insertGlyph(glyph, name=name)
def newGlyph(self, name, clear=True): """ Make a new glyph with **name** in the layer. :: >>> glyph = layer.newGlyph("A") The newly created :class:`BaseGlyph` will be returned. If the glyph exists in the layer and clear is set to ``False``, the existing glyph will be returned, otherwise the default behavior is to clear the exisiting glyph. """ name = normalizers.normalizeGlyphName(name) if name not in self: glyph = self._newGlyph(name) elif clear: self.removeGlyph(name) glyph = self._newGlyph(name) else: glyph = self._getItem(name) self._setLayerInGlyph(glyph) return glyph
def _get_base_baseGlyph(self): value = self._get_baseGlyph() value = normalizers.normalizeGlyphName(value) return value
def _set_base_selectedGlyphNames(self, value): normalized = [normalizers.normalizeGlyphName(name) for name in value] self._set_selectedGlyphNames(normalized)
def _get_base_selectedGlyphNames(self): selected = tuple([ normalizers.normalizeGlyphName(name) for name in self._get_selectedGlyphNames() ]) return selected
def _set_base_baseGlyph(self, value): value = normalizers.normalizeGlyphName(value) self._set_baseGlyph(value)
def _get_base_selectedGlyphNames(self): selected = tuple([normalizers.normalizeGlyphName(name) for name in self._get_selectedGlyphNames()]) return selected