コード例 #1
0
 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
コード例 #2
0
    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)
コード例 #3
0
ファイル: component.py プロジェクト: moyogo/fontparts
 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
コード例 #4
0
ファイル: layer.py プロジェクト: robofab-developers/fontParts
    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)
コード例 #5
0
    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)
コード例 #6
0
    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)
コード例 #7
0
ファイル: layer.py プロジェクト: robofab-developers/fontParts
    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
コード例 #8
0
    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
コード例 #9
0
ファイル: groups.py プロジェクト: moyogo/fontparts
    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
コード例 #10
0
ファイル: groups.py プロジェクト: gitter-badger/fontParts
    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
コード例 #11
0
ファイル: layer.py プロジェクト: robofab-developers/fontParts
    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)
コード例 #12
0
    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)
コード例 #13
0
    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)
コード例 #14
0
    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
コード例 #15
0
ファイル: layer.py プロジェクト: robofab-developers/fontParts
    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
コード例 #16
0
ファイル: component.py プロジェクト: gitter-badger/fontParts
 def _get_base_baseGlyph(self):
     value = self._get_baseGlyph()
     value = normalizers.normalizeGlyphName(value)
     return value
コード例 #17
0
 def _set_base_selectedGlyphNames(self, value):
     normalized = [normalizers.normalizeGlyphName(name) for name in value]
     self._set_selectedGlyphNames(normalized)
コード例 #18
0
 def _get_base_selectedGlyphNames(self):
     selected = tuple([
         normalizers.normalizeGlyphName(name)
         for name in self._get_selectedGlyphNames()
     ])
     return selected
コード例 #19
0
ファイル: component.py プロジェクト: moyogo/fontparts
 def _set_base_baseGlyph(self, value):
     value = normalizers.normalizeGlyphName(value)
     self._set_baseGlyph(value)
コード例 #20
0
 def _set_base_baseGlyph(self, value):
     value = normalizers.normalizeGlyphName(value)
     self._set_baseGlyph(value)
コード例 #21
0
ファイル: layer.py プロジェクト: robofab-developers/fontParts
 def _set_base_selectedGlyphNames(self, value):
     normalized = [normalizers.normalizeGlyphName(name) for name in value]
     self._set_selectedGlyphNames(normalized)
コード例 #22
0
ファイル: layer.py プロジェクト: robofab-developers/fontParts
 def _get_base_selectedGlyphNames(self):
     selected = tuple([normalizers.normalizeGlyphName(name) for name in
                      self._get_selectedGlyphNames()])
     return selected