signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def round(self): | self._round()<EOL> | Round coordinates in all points to integers. | f10848:c0:m18 |
def _round(self, **kwargs): | for point in self.points:<EOL><INDENT>point.round()<EOL><DEDENT> | Subclasses may override this method. | f10848:c0:m19 |
def _transformBy(self, matrix, **kwargs): | for point in self.points:<EOL><INDENT>point.transformBy(matrix)<EOL><DEDENT> | Subclasses may override this method. | f10848:c0:m20 |
def isCompatible(self, other): | return super(BaseContour, self).isCompatible(other, BaseContour)<EOL> | Evaluate interpolation compatibility with **other**. ::
>>> compatible, report = self.isCompatible(otherContour)
>>> compatible
False
>>> compatible
[Fatal] Contour: [0] + [0]
[Fatal] Contour: [0] contains 4 segments | [0] contains 3 segments
[Fatal] Contour: [0] is closed | [0] is open
Th... | f10848:c0:m21 |
def _isCompatible(self, other, reporter): | contour1 = self<EOL>contour2 = other<EOL>if contour1.open != contour2.open:<EOL><INDENT>reporter.openDifference = True<EOL><DEDENT>if contour1.clockwise != contour2.clockwise:<EOL><INDENT>reporter.directionDifference = True<EOL><DEDENT>if len(contour1) != len(contour2.segments):<EOL><INDENT>reporter.segmentCountDiffere... | This is the environment implementation of
:meth:`BaseContour.isCompatible`.
Subclasses may override this method. | f10848:c0:m22 |
def _get_open(self): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10848:c0:m24 |
def _get_clockwise(self): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10848:c0:m27 |
def _set_clockwise(self, value): | if self.clockwise != value:<EOL><INDENT>self.reverse()<EOL><DEDENT> | Subclasses may override this method. | f10848:c0:m28 |
def reverse(self): | self._reverseContour()<EOL> | Reverse the direction of the contour. | f10848:c0:m29 |
def _reverse(self, **kwargs): | self.raiseNotImplementedError()<EOL> | Subclasses may override this method. | f10848:c0:m30 |
def pointInside(self, point): | point = normalizers.normalizeCoordinateTuple(point)<EOL>return self._pointInside(point)<EOL> | Determine if ``point`` is in the black or white of the contour.
>>> contour.pointInside((40, 65))
True
``point`` must be a :ref:`type-coordinate`. | f10848:c0:m31 |
def _pointInside(self, point): | from fontTools.pens.pointInsidePen import PointInsidePen<EOL>pen = PointInsidePen(glyphSet=None, testPoint=point, evenOdd=False)<EOL>self.draw(pen)<EOL>return pen.getResult()<EOL> | Subclasses may override this method. | f10848:c0:m32 |
def contourInside(self, otherContour): | otherContour = normalizers.normalizeContour(otherContour)<EOL>return self._contourInside(otherContour)<EOL> | Determine if ``otherContour`` is in the black or white of this contour.
>>> contour.contourInside(otherContour)
True
``contour`` must be a :class:`BaseContour`. | f10848:c0:m33 |
def _contourInside(self, otherContour): | self.raiseNotImplementedError()<EOL> | Subclasses may override this method. | f10848:c0:m34 |
def _get_bounds(self): | from fontTools.pens.boundsPen import BoundsPen<EOL>pen = BoundsPen(self.layer)<EOL>self.draw(pen)<EOL>return pen.bounds<EOL> | Subclasses may override this method. | f10848:c0:m36 |
def _get_area(self): | from fontTools.pens.areaPen import AreaPen<EOL>pen = AreaPen(self.layer)<EOL>self.draw(pen)<EOL>return abs(pen.value)<EOL> | Subclasses may override this method. | f10848:c0:m38 |
def _get_segments(self): | points = list(self.points)<EOL>segments = [[]]<EOL>lastWasOffCurve = False<EOL>firstIsMove = points[<NUM_LIT:0>].type == "<STR_LIT>"<EOL>for point in points:<EOL><INDENT>segments[-<NUM_LIT:1>].append(point)<EOL>if point.type != "<STR_LIT>":<EOL><INDENT>segments.append([])<EOL><DEDENT>lastWasOffCurve = point.type == "<S... | Subclasses may override this method. | f10848:c0:m40 |
def _len__segments(self, **kwargs): | return len(self.segments)<EOL> | Subclasses may override this method. | f10848:c0:m45 |
def appendSegment(self, type=None, points=None, smooth=False, segment=None): | if segment is not None:<EOL><INDENT>if type is not None:<EOL><INDENT>type = segment.type<EOL><DEDENT>if points is None:<EOL><INDENT>points = [(point.x, point.y) for point in segment.points]<EOL><DEDENT>smooth = segment.smooth<EOL><DEDENT>type = normalizers.normalizeSegmentType(type)<EOL>pts = []<EOL>for pt in points:<E... | Append a segment to the contour. | f10848:c0:m46 |
def _appendSegment(self, type=None, points=None, smooth=False, **kwargs): | self._insertSegment(len(self), type=type, points=points,<EOL>smooth=smooth, **kwargs)<EOL> | Subclasses may override this method. | f10848:c0:m47 |
def insertSegment(self, index, type=None, points=None, smooth=False, segment=None): | if segment is not None:<EOL><INDENT>if type is not None:<EOL><INDENT>type = segment.type<EOL><DEDENT>if points is None:<EOL><INDENT>points = [(point.x, point.y) for point in segment.points]<EOL><DEDENT>smooth = segment.smooth<EOL><DEDENT>index = normalizers.normalizeIndex(index)<EOL>type = normalizers.normalizeSegmentT... | Insert a segment into the contour. | f10848:c0:m48 |
def _insertSegment(self, index=None, type=None, points=None,<EOL>smooth=False, **kwargs): | onCurve = points[-<NUM_LIT:1>]<EOL>offCurve = points[:-<NUM_LIT:1>]<EOL>segments = self.segments<EOL>ptCount = sum([len(segments[s].points) for s in range(index)]) + <NUM_LIT:1><EOL>self.insertPoint(ptCount, onCurve, type=type, smooth=smooth)<EOL>for offCurvePoint in reversed(offCurve):<EOL><INDENT>self.insertPoint(ptC... | Subclasses may override this method. | f10848:c0:m49 |
def removeSegment(self, segment, preserveCurve=False): | if not isinstance(segment, int):<EOL><INDENT>segment = self.segments.index(segment)<EOL><DEDENT>segment = normalizers.normalizeIndex(segment)<EOL>if segment >= self._len__segments():<EOL><INDENT>raise ValueError("<STR_LIT>" % segment)<EOL><DEDENT>preserveCurve = normalizers.normalizeBoolean(preserveCurve)<EOL>self._rem... | Remove segment from the contour.
If ``preserveCurve`` is set to ``True`` an attempt
will be made to preserve the shape of the curve
if the environment supports that functionality. | f10848:c0:m50 |
def _removeSegment(self, segment, preserveCurve, **kwargs): | segment = self.segments[segment]<EOL>for point in segment.points:<EOL><INDENT>self.removePoint(point, preserveCurve)<EOL><DEDENT> | segment will be a valid segment index.
preserveCurve will be a boolean.
Subclasses may override this method. | f10848:c0:m51 |
def setStartSegment(self, segment): | segments = self.segments<EOL>if not isinstance(segment, int):<EOL><INDENT>segmentIndex = segments.index(segment)<EOL><DEDENT>else:<EOL><INDENT>segmentIndex = segment<EOL><DEDENT>if len(self.segments) < <NUM_LIT:2>:<EOL><INDENT>return<EOL><DEDENT>if segmentIndex == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if segmentI... | Set the first segment on the contour.
segment can be a segment object or an index. | f10848:c0:m52 |
def _setStartSegment(self, segmentIndex, **kwargs): | segments = self.segments<EOL>oldStart = segments[-<NUM_LIT:1>]<EOL>oldLast = segments[<NUM_LIT:0>]<EOL>if oldLast.type == "<STR_LIT>" or oldLast.type == "<STR_LIT>":<EOL><INDENT>startOn = oldStart.onCurve<EOL>lastOn = oldLast.onCurve<EOL>if startOn.x == lastOn.x and startOn.y == lastOn.y:<EOL><INDENT>self.removeSegment... | Subclasses may override this method. | f10848:c0:m53 |
def appendBPoint(self, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None): | if bPoint is not None:<EOL><INDENT>if type is None:<EOL><INDENT>type = bPoint.type<EOL><DEDENT>if anchor is None:<EOL><INDENT>anchor = bPoint.anchor<EOL><DEDENT>if bcpIn is None:<EOL><INDENT>bcpIn = bPoint.bcpIn<EOL><DEDENT>if bcpOut is None:<EOL><INDENT>bcpOut = bPoint.bcpOut<EOL><DEDENT><DEDENT>type = normalizers.nor... | Append a bPoint to the contour. | f10848:c0:m55 |
def _appendBPoint(self, type, anchor, bcpIn=None, bcpOut=None, **kwargs): | self.insertBPoint(<EOL>len(self.bPoints),<EOL>type,<EOL>anchor,<EOL>bcpIn=bcpIn,<EOL>bcpOut=bcpOut<EOL>)<EOL> | Subclasses may override this method. | f10848:c0:m56 |
def insertBPoint(self, index, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None): | if bPoint is not None:<EOL><INDENT>if type is None:<EOL><INDENT>type = bPoint.type<EOL><DEDENT>if anchor is None:<EOL><INDENT>anchor = bPoint.anchor<EOL><DEDENT>if bcpIn is None:<EOL><INDENT>bcpIn = bPoint.bcpIn<EOL><DEDENT>if bcpOut is None:<EOL><INDENT>bcpOut = bPoint.bcpOut<EOL><DEDENT><DEDENT>index = normalizers.no... | Insert a bPoint at index in the contour. | f10848:c0:m57 |
def _insertBPoint(self, index, type, anchor, bcpIn, bcpOut, **kwargs): | <EOL>self._insertSegment(index=index, type="<STR_LIT>",<EOL>points=[anchor], smooth=False)<EOL>bPoints = self.bPoints<EOL>index += <NUM_LIT:1><EOL>if index >= len(bPoints):<EOL><INDENT>index = -<NUM_LIT:1><EOL><DEDENT>bPoint = bPoints[index]<EOL>bPoint.bcpIn = bcpIn<EOL>bPoint.bcpOut = bcpOut<EOL>bPoint.type = type<EOL... | Subclasses may override this method. | f10848:c0:m58 |
def removeBPoint(self, bPoint): | if not isinstance(bPoint, int):<EOL><INDENT>bPoint = bPoint.index<EOL><DEDENT>bPoint = normalizers.normalizeIndex(bPoint)<EOL>if bPoint >= self._len__points():<EOL><INDENT>raise ValueError("<STR_LIT>" % bPoint)<EOL><DEDENT>self._removeBPoint(bPoint)<EOL> | Remove the bpoint from the contour.
bpoint can be a point object or an index. | f10848:c0:m59 |
def _removeBPoint(self, index, **kwargs): | bPoint = self.bPoints[index]<EOL>nextSegment = bPoint._nextSegment<EOL>offCurves = nextSegment.offCurve<EOL>if offCurves:<EOL><INDENT>offCurve = offCurves[<NUM_LIT:0>]<EOL>self.removePoint(offCurve)<EOL><DEDENT>segment = bPoint._segment<EOL>offCurves = segment.offCurve<EOL>if offCurves:<EOL><INDENT>offCurve = offCurves... | index will be a valid index.
Subclasses may override this method. | f10848:c0:m60 |
def _get_points(self): | return tuple([self._getitem__points(i)<EOL>for i in range(self._len__points())])<EOL> | Subclasses may override this method. | f10848:c0:m62 |
def _lenPoints(self, **kwargs): | self.raiseNotImplementedError()<EOL> | This must return an integer indicating
the number of points in the contour.
Subclasses must override this method. | f10848:c0:m64 |
def _getPoint(self, index, **kwargs): | self.raiseNotImplementedError()<EOL> | This must return a wrapped point.
index will be a valid index.
Subclasses must override this method. | f10848:c0:m66 |
def appendPoint(self, position=None, type="<STR_LIT>", smooth=False, name=None, identifier=None, point=None): | if point is not None:<EOL><INDENT>if position is None:<EOL><INDENT>position = point.position<EOL><DEDENT>type = point.type<EOL>smooth = point.smooth<EOL>if name is None:<EOL><INDENT>name = point.name<EOL><DEDENT>if identifier is not None:<EOL><INDENT>identifier = point.identifier<EOL><DEDENT><DEDENT>self.insertPoint(<E... | Append a point to the contour. | f10848:c0:m68 |
def insertPoint(self, index, position=None, type="<STR_LIT>", smooth=False, name=None, identifier=None, point=None): | if point is not None:<EOL><INDENT>if position is None:<EOL><INDENT>position = point.position<EOL><DEDENT>type = point.type<EOL>smooth = point.smooth<EOL>if name is None:<EOL><INDENT>name = point.name<EOL><DEDENT>if identifier is not None:<EOL><INDENT>identifier = point.identifier<EOL><DEDENT><DEDENT>index = normalizers... | Insert a point into the contour. | f10848:c0:m69 |
def _insertPoint(self, index, position, type="<STR_LIT>",<EOL>smooth=False, name=None, identifier=None, **kwargs): | self.raiseNotImplementedError()<EOL> | position will be a valid position (x, y).
type will be a valid type.
smooth will be a valid boolean.
name will be a valid name or None.
identifier will be a valid identifier or None.
The identifier will not have been tested for uniqueness.
Subclasses must override this method. | f10848:c0:m70 |
def removePoint(self, point, preserveCurve=False): | if not isinstance(point, int):<EOL><INDENT>point = self.points.index(point)<EOL><DEDENT>point = normalizers.normalizeIndex(point)<EOL>if point >= self._len__points():<EOL><INDENT>raise ValueError("<STR_LIT>" % point)<EOL><DEDENT>preserveCurve = normalizers.normalizeBoolean(preserveCurve)<EOL>self._removePoint(point, pr... | Remove the point from the contour.
point can be a point object or an index.
If ``preserveCurve`` is set to ``True`` an attempt
will be made to preserve the shape of the curve
if the environment supports that functionality. | f10848:c0:m71 |
def _removePoint(self, index, preserveCurve, **kwargs): | self.raiseNotImplementedError()<EOL> | index will be a valid index. preserveCurve will be a boolean.
Subclasses must override this method. | f10848:c0:m72 |
def _get_selectedSegments(self): | return self._getSelectedSubObjects(self.segments)<EOL> | Subclasses may override this method. | f10848:c0:m74 |
def _set_selectedSegments(self, value): | return self._setSelectedSubObjects(self.segments, value)<EOL> | Subclasses may override this method. | f10848:c0:m76 |
def _get_selectedPoints(self): | return self._getSelectedSubObjects(self.points)<EOL> | Subclasses may override this method. | f10848:c0:m78 |
def _set_selectedPoints(self, value): | return self._setSelectedSubObjects(self.points, value)<EOL> | Subclasses may override this method. | f10848:c0:m80 |
def _get_selectedBPoints(self): | return self._getSelectedSubObjects(self.bPoints)<EOL> | Subclasses may override this method. | f10848:c0:m82 |
def _set_selectedBPoints(self, value): | return self._setSelectedSubObjects(self.bPoints, value)<EOL> | Subclasses may override this method. | f10848:c0:m84 |
def __len__(self): | return self._len()<EOL> | An ``int`` representing number of glyphs in the layer. ::
>>> len(layer)
256 | f10849:c0:m1 |
def _len(self, **kwargs): | return len(self.keys())<EOL> | This is the environment implementation of
:meth:`BaseLayer.__len__` and :meth:`BaseFont.__len__`
This must return an ``int`` indicating
the number of glyphs in the layer.
Subclasses may override this method. | f10849:c0:m2 |
def __iter__(self): | return self._iter()<EOL> | Iterate through the :class:`BaseGlyph` objects in the layer. ::
>>> for glyph in layer:
... glyph.name
"A"
"B"
"C" | f10849:c0:m3 |
def _iter(self, **kwargs): | for name in self.keys():<EOL><INDENT>yield self[name]<EOL><DEDENT> | This is the environment implementation of
:meth:`BaseLayer.__iter__` and :meth:`BaseFont.__iter__`
This must return an iterator that returns
instances of a :class:`BaseGlyph` subclass.
Subclasses may override this method. | f10849:c0:m4 |
def __getitem__(self, name): | name = normalizers.normalizeGlyphName(name)<EOL>if name not in self:<EOL><INDENT>raise KeyError("<STR_LIT>" % name)<EOL><DEDENT>glyph = self._getItem(name)<EOL>self._setLayerInGlyph(glyph)<EOL>return glyph<EOL> | Get the :class:`BaseGlyph` with name from the layer. ::
>>> glyph = layer["A"] | f10849:c0:m5 |
def _getItem(self, name, **kwargs): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:meth:`BaseLayer.__getitem__` and :meth:`BaseFont.__getitem__`
This must return an instance of a :class:`BaseGlyph`
subclass. **name** will be a :ref:`type-string` representing
a name of a glyph that is in the layer. It will have been
normalized with :func:`normalizers.normaliz... | f10849:c0:m6 |
def __setitem__(self, name, glyph): | name = normalizers.normalizeGlyphName(name)<EOL>if name in self:<EOL><INDENT>del self[name]<EOL><DEDENT>return self._insertGlyph(glyph, name=name)<EOL> | 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 giv... | f10849:c0:m7 |
def __delitem__(self, name): | name = normalizers.normalizeGlyphName(name)<EOL>if name not in self:<EOL><INDENT>raise KeyError("<STR_LIT>" % name)<EOL><DEDENT>self._removeGlyph(name)<EOL> | Remove the glyph with name from the layer. ::
>>> del layer["A"] | f10849:c0:m8 |
def keys(self): | return self._keys()<EOL> | Get a list of all glyphs in the layer. ::
>>> layer.keys()
["B", "C", "A"]
The order of the glyphs is undefined. | f10849:c0:m9 |
def _keys(self, **kwargs): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:meth:`BaseLayer.keys` and :meth:`BaseFont.keys`
This must return an :ref:`type-immutable-list`
of the names representing all glyphs in the layer.
The order is not defined.
Subclasses must override this method. | f10849:c0:m10 |
def __contains__(self, name): | name = normalizers.normalizeGlyphName(name)<EOL>return self._contains(name)<EOL> | Test if the layer contains a glyph with **name**. ::
>>> "A" in layer
True | f10849:c0:m11 |
def _contains(self, name, **kwargs): | return name in self.keys()<EOL> | This is the environment implementation of
:meth:`BaseLayer.__contains__` and :meth:`BaseFont.__contains__`
This must return ``bool`` indicating if the
layer has a glyph with the defined name.
**name** will be a :ref-type-string` representing
a glyph name. It will have been normalized with
:func:`normalizers.normalizeGl... | f10849:c0:m12 |
def newGlyph(self, name, clear=True): | name = normalizers.normalizeGlyphName(name)<EOL>if name not in self:<EOL><INDENT>glyph = self._newGlyph(name)<EOL><DEDENT>elif clear:<EOL><INDENT>self.removeGlyph(name)<EOL>glyph = self._newGlyph(name)<EOL><DEDENT>else:<EOL><INDENT>glyph = self._getItem(name)<EOL><DEDENT>self._setLayerInGlyph(glyph)<EOL>return glyph<EO... | 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. | f10849:c0:m13 |
def _newGlyph(self, name, **kwargs): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:meth:`BaseLayer.newGlyph` and :meth:`BaseFont.newGlyph`
This must return an instance of a :class:`BaseGlyph` subclass.
**name** will be a :ref:`type-string` representing
a glyph name. It will have been normalized with
:func:`normalizers.normalizeGlyphName`. The
name will have ... | f10849:c0:m14 |
def removeGlyph(self, name): | del self[name]<EOL> | Remove the glyph with name from the layer. ::
>>> layer.removeGlyph("A")
This method is deprecated. :meth:`BaseFont.__delitem__` instead. | f10849:c0:m15 |
def _removeGlyph(self, name, **kwargs): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:meth:`BaseLayer.removeGlyph` and :meth:`BaseFont.removeGlyph`.
**name** will be a :ref:`type-string` representing a
glyph name of a glyph that is in the layer. It will
have been normalized with :func:`normalizers.normalizeGlyphName`.
The newly created :class:`BaseGlyph` must b... | f10849:c0:m16 |
def insertGlyph(self, glyph, name=None): | if name is None:<EOL><INDENT>name = glyph.name<EOL><DEDENT>self[name] = glyph<EOL> | Insert **glyph** into the layer. ::
>>> glyph = layer.insertGlyph(otherGlyph, name="A")
This method is deprecated. :meth:`BaseFont.__setitem__` instead. | f10849:c0:m17 |
def _insertGlyph(self, glyph, name, **kwargs): | if glyph.name is None or (name != glyph.name and glyph.name in self):<EOL><INDENT>glyph = glyph.copy()<EOL>glyph.name = name<EOL><DEDENT>dest = self.newGlyph(name, clear=kwargs.get("<STR_LIT>", True))<EOL>dest.copyData(glyph)<EOL>return dest<EOL> | This is the environment implementation of
:meth:`BaseLayer.__setitem__` and :meth:`BaseFont.__setitem__`.
This must return an instance of a :class:`BaseGlyph` subclass.
**glyph** will be a glyph object with the attributes necessary
for copying as defined in :meth:`BaseGlyph.copy` An environment
must not insert **glyph*... | f10849:c0:m18 |
def _get_selectedGlyphs(self): | return self._getSelectedSubObjects(self)<EOL> | Subclasses may override this method. | f10849:c0:m20 |
def _set_selectedGlyphs(self, value): | return self._setSelectedSubObjects(self, value)<EOL> | Subclasses may override this method. | f10849:c0:m22 |
def _get_selectedGlyphNames(self): | selected = [glyph.name for glyph in self.selectedGlyphs]<EOL>return selected<EOL> | Subclasses may override this method. | f10849:c0:m24 |
def _set_selectedGlyphNames(self, value): | select = [self[name] for name in value]<EOL>self.selectedGlyphs = select<EOL> | Subclasses may override this method. | f10849:c0:m26 |
def copy(self): | return super(BaseLayer, self).copy()<EOL> | Copy the layer into a new layer that does not
belong to a font. ::
>>> copiedLayer = layer.copy()
This will copy:
* name
* color
* lib
* glyphs | f10849:c1:m1 |
def copyData(self, source): | super(BaseLayer, self).copyData(source)<EOL>for name in source.keys():<EOL><INDENT>glyph = self.newGlyph(name)<EOL>glyph.copyData(source[name])<EOL><DEDENT> | Copy data from **source** into this layer.
Refer to :meth:`BaseLayer.copy` for a list
of values that will be copied. | f10849:c1:m2 |
def _get_name(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of :attr:`BaseLayer.name`.
This must return a :ref:`type-string` defining the name of the
layer. If the layer is the default layer, the returned value
must be ``None``. It will be normalized with
:func:`normalizers.normalizeLayerName`.
Subclasses must override this method. | f10849:c1:m7 |
def _set_name(self, value, **kwargs): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of :attr:`BaseLayer.name`.
**value** will be a :ref:`type-string` defining the name of the
layer. It will have been normalized with
:func:`normalizers.normalizeLayerName`.
No layer with the same name will exist.
Subclasses must override this method. | f10849:c1:m8 |
def _get_color(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of :attr:`BaseLayer.color`.
This must return a :ref:`type-color` defining the
color assigned to the layer. If the layer does not
have an assigned color, the returned value must be
``None``. It will be normalized with
:func:`normalizers.normalizeColor`.
Subclasses must override th... | f10849:c1:m11 |
def _set_color(self, value, **kwargs): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of :attr:`BaseLayer.color`.
**value** will be a :ref:`type-color` or ``None`` defining the
color to assign to the layer. It will have been normalized with
:func:`normalizers.normalizeColor`.
Subclasses must override this method. | f10849:c1:m12 |
def _get_lib(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of :attr:`BaseLayer.lib`.
This must return an instance of a :class:`BaseLib` subclass. | f10849:c1:m14 |
def round(self): | self._round()<EOL> | Round all approriate data to integers. ::
>>> layer.round()
This is the equivalent of calling the round method on:
* all glyphs in the layer | f10849:c1:m15 |
def _round(self): | for glyph in self:<EOL><INDENT>glyph.round()<EOL><DEDENT> | This is the environment implementation of :meth:`BaseLayer.round`.
Subclasses may override this method. | f10849:c1:m16 |
def autoUnicodes(self): | self._autoUnicodes()<EOL> | Use heuristics to set Unicode values in all glyphs. ::
>>> layer.autoUnicodes()
Environments will define their own heuristics for
automatically determining values. | f10849:c1:m17 |
def _autoUnicodes(self): | for glyph in self:<EOL><INDENT>glyph.autoUnicodes()<EOL><DEDENT> | This is the environment implementation of
:meth:`BaseLayer.autoUnicodes`.
Subclasses may override this method. | f10849:c1:m18 |
def interpolate(self, factor, minLayer, maxLayer, round=True,<EOL>suppressError=True): | factor = normalizers.normalizeInterpolationFactor(factor)<EOL>if not isinstance(minLayer, BaseLayer):<EOL><INDENT>raise TypeError(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>% (self.__class__.__name__, minLayer.__class__.__name__))<EOL><DEDENT>if not isinstance(maxLayer, BaseLayer):<EOL><INDENT>raise TypeError(("<STR_LIT>"<EOL>"... | Interpolate all possible data in the layer. ::
>>> layer.interpolate(0.5, otherLayer1, otherLayer2)
>>> layer.interpolate((0.5, 2.0), otherLayer1, otherLayer2, round=False)
The interpolation occurs on a 0 to 1.0 range where **minLayer**
is located at 0 and **maxLayer** is located at 1.0. **factor**
is the int... | f10849:c1:m19 |
def _interpolate(self, factor, minLayer, maxLayer, round=True,<EOL>suppressError=True): | for glyphName in self.keys():<EOL><INDENT>del self[glyphName]<EOL><DEDENT>for glyphName in minLayer.keys():<EOL><INDENT>if glyphName not in maxLayer:<EOL><INDENT>continue<EOL><DEDENT>minGlyph = minLayer[glyphName]<EOL>maxGlyph = maxLayer[glyphName]<EOL>dstGlyph = self.newGlyph(glyphName)<EOL>dstGlyph.interpolate(factor... | This is the environment implementation of
:meth:`BaseLayer.interpolate`.
Subclasses may override this method. | f10849:c1:m20 |
def isCompatible(self, other): | return super(BaseLayer, self).isCompatible(other, BaseLayer)<EOL> | Evaluate interpolation compatibility with **other**. ::
>>> compat, report = self.isCompatible(otherLayer)
>>> compat
False
>>> report
A
-
[Fatal] The glyphs do not contain the same number of contours.
This will return a ``bool`` indicating if the layer is
compatible for interpolation with... | f10849:c1:m21 |
def _isCompatible(self, other, reporter): | layer1 = self<EOL>layer2 = other<EOL>glyphs1 = set(layer1.keys())<EOL>glyphs2 = set(layer2.keys())<EOL>if len(glyphs1) != len(glyphs2):<EOL><INDENT>reporter.glyphCountDifference = True<EOL>reporter.warning = True<EOL><DEDENT>if len(glyphs1.difference(glyphs2)) != <NUM_LIT:0>:<EOL><INDENT>reporter.warning = True<EOL>rep... | This is the environment implementation of
:meth:`BaseLayer.isCompatible`.
Subclasses may override this method. | f10849:c1:m22 |
def getReverseComponentMapping(self): | return self._getReverseComponentMapping()<EOL> | Create a dictionary of unicode -> [glyphname, ...] mappings.
All glyphs are loaded. Note that one glyph can have multiple
unicode values, and a unicode value can have multiple glyphs
pointing to it. | f10849:c1:m23 |
def _getReverseComponentMapping(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:meth:`BaseFont.getReverseComponentMapping`.
Subclasses may override this method. | f10849:c1:m24 |
def getCharacterMapping(self): | return self._getCharacterMapping()<EOL> | Get a reversed map of component references in the font.
{
'A' : ['Aacute', 'Aring']
'acute' : ['Aacute']
'ring' : ['Aring']
etc.
} | f10849:c1:m25 |
def _getCharacterMapping(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:meth:`BaseFont.getCharacterMapping`.
Subclasses may override this method. | f10849:c1:m26 |
def _get_baseGlyph(self): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10851:c0:m7 |
def _set_baseGlyph(self, value): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10851:c0:m8 |
def _get_transformation(self): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10851:c0:m11 |
def _set_transformation(self, value): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10851:c0:m12 |
def _get_offset(self): | sx, sxy, syx, sy, ox, oy = self.transformation<EOL>return ox, oy<EOL> | Subclasses may override this method. | f10851:c0:m15 |
def _set_offset(self, value): | sx, sxy, syx, sy, ox, oy = self.transformation<EOL>ox, oy = value<EOL>self.transformation = sx, sxy, syx, sy, ox, oy<EOL> | Subclasses may override this method. | f10851:c0:m16 |
def _get_scale(self): | sx, sxy, syx, sy, ox, oy = self.transformation<EOL>return sx, sy<EOL> | Subclasses may override this method. | f10851:c0:m19 |
def _set_scale(self, value): | sx, sxy, syx, sy, ox, oy = self.transformation<EOL>sx, sy = value<EOL>self.transformation = sx, sxy, syx, sy, ox, oy<EOL> | Subclasses may override this method. | f10851:c0:m20 |
def _get_index(self): | glyph = self.glyph<EOL>return glyph.components.index(self)<EOL> | Subclasses may override this method. | f10851:c0:m23 |
def _set_index(self, value): | self.raiseNotImplementedError()<EOL> | Subclasses must override this method. | f10851:c0:m24 |
def draw(self, pen): | self._draw(pen)<EOL> | Draw the component with the given Pen. | f10851:c0:m25 |
def _draw(self, pen, **kwargs): | from fontTools.ufoLib.pointPen import PointToSegmentPen<EOL>adapter = PointToSegmentPen(pen)<EOL>self.drawPoints(adapter)<EOL> | Subclasses may override this method. | f10851:c0:m26 |
def drawPoints(self, pen): | self._drawPoints(pen)<EOL> | Draw the contour with the given PointPen. | f10851:c0:m27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.