Esempio n. 1
0
 def insertBPoint(self,
                  index,
                  type=None,
                  anchor=None,
                  bcpIn=None,
                  bcpOut=None,
                  bPoint=None):
     """
     Insert a bPoint at index in the contour.
     """
     if bPoint is not None:
         if type is None:
             type = bPoint.type
         if anchor is None:
             anchor = bPoint.anchor
         if bcpIn is None:
             bcpIn = bPoint.bcpIn
         if bcpOut is None:
             bcpOut = bPoint.bcpOut
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._insertBPoint(index=index,
                        type=type,
                        anchor=anchor,
                        bcpIn=bcpIn,
                        bcpOut=bcpOut)
Esempio n. 2
0
 def insertPoint(self, index, position=None, type="line", smooth=False, name=None, identifier=None, point=None):
     """
     Insert a point into the contour.
     """
     if point is not None:
         if position is None:
             position = point.position
         type = point.type
         smooth = point.smooth
         if name is None:
             name = point.name
         if identifier is not None:
             identifier = point.identifier
     index = normalizers.normalizeIndex(index)
     position = normalizers.normalizeCoordinateTuple(position)
     type = normalizers.normalizePointType(type)
     smooth = normalizers.normalizeBoolean(smooth)
     if name is not None:
         name = normalizers.normalizePointName(name)
     if identifier is not None:
         identifier = normalizers.normalizeIdentifier(identifier)
     self._insertPoint(
         index,
         position=position,
         type=type,
         smooth=smooth,
         name=name,
         identifier=identifier
     )
Esempio n. 3
0
 def insertBPoint(self,
                  index,
                  type,
                  anchor,
                  bcpIn=None,
                  bcpOut=None,
                  **kwargs):
     """
     Insert a bPoint at index in the contour.
     """
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._insertBPoint(index=index,
                        type=type,
                        anchor=anchor,
                        bcpIn=bcpIn,
                        bcpOut=bcpOut,
                        **kwargs)
Esempio n. 4
0
 def insertPoint(self, index, position=None, type="line", smooth=False, name=None, identifier=None, point=None):
     """
     Insert a point into the contour.
     """
     if point is not None:
         if position is None:
             position = point.position
         type = point.type
         smooth = point.smooth
         if name is None:
             name = point.name
         if identifier is not None:
             identifier = point.identifier
     index = normalizers.normalizeIndex(index)
     position = normalizers.normalizeCoordinateTuple(position)
     type = normalizers.normalizePointType(type)
     smooth = normalizers.normalizeBoolean(smooth)
     if name is not None:
         name = normalizers.normalizePointName(name)
     if identifier is not None:
         identifier = normalizers.normalizeIdentifier(identifier)
     self._insertPoint(
         index,
         position=position,
         type=type,
         smooth=smooth,
         name=name,
         identifier=identifier
     )
Esempio n. 5
0
 def insertSegment(self,
                   index,
                   type=None,
                   points=None,
                   smooth=False,
                   segment=None):
     """
     Insert a segment into the contour.
     """
     if segment is not None:
         if type is not None:
             type = segment.type
         if points is None:
             points = [(point.x, point.y) for point in segment.points]
         smooth = segment.smooth
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._insertSegment(index=index,
                         type=type,
                         points=points,
                         smooth=smooth)
Esempio n. 6
0
 def _get_base_index(self):
     glyph = self.glyph
     if glyph is None:
         return None
     value = self._get_index()
     value = normalizers.normalizeIndex(value)
     return value
Esempio n. 7
0
 def _getitem__points(self, index):
     index = normalizers.normalizeIndex(index)
     if index >= self._len__points():
         raise ValueError("No point located at index %d." % index)
     point = self._getPoint(index)
     self._setContourInPoint(point)
     return point
Esempio n. 8
0
 def _get_base_index(self):
     glyph = self.glyph
     if glyph is None:
         return None
     value = self._get_index()
     value = normalizers.normalizeIndex(value)
     return value
Esempio n. 9
0
 def _getitem__points(self, index):
     index = normalizers.normalizeIndex(index)
     if index >= self._len__points():
         raise ValueError("No point located at index %d." % index)
     point = self._getPoint(index)
     self._setContourInPoint(point)
     return point
Esempio n. 10
0
 def removeSegment(self, segment):
     """
     Remove segment from the contour.
     """
     if not isinstance(segment, int):
         segment = self.segments.index(segment)
     segment = normalizers.normalizeIndex(segment)
     if segment >= self._len__segments():
         raise ValueError("No segment located at index %d." % segment)
     self._removeSegment(segment)
Esempio n. 11
0
 def removeBPoint(self, bPoint):
     """
     Remove the bpoint from the contour.
     bpoint can be a point object or an index.
     """
     if not isinstance(bPoint, int):
         bPoint = bPoint.index
     bPoint = normalizers.normalizeIndex(bPoint)
     if bPoint >= self._len__points():
         raise ValueError("No bPoint located at index %d." % bPoint)
     self._removeBPoint(bPoint)
Esempio n. 12
0
 def _set_base_index(self, value):
     glyph = self.glyph
     if glyph is None:
         raise FontPartsError("The contour does not belong to a glyph.")
     value = normalizers.normalizeIndex(value)
     contourCount = len(glyph.contours)
     if value < 0:
         value = -(value % contourCount)
     if value >= contourCount:
         value = contourCount
     self._set_index(value)
Esempio n. 13
0
 def _set_base_index(self, value):
     glyph = self.glyph
     if glyph is None:
         raise FontPartsError("The contour does not belong to a glyph.")
     value = normalizers.normalizeIndex(value)
     contourCount = len(glyph.contours)
     if value < 0:
         value = -(value % contourCount)
     if value >= contourCount:
         value = contourCount
     self._set_index(value)
Esempio n. 14
0
 def removeBPoint(self, bPoint):
     """
     Remove the bpoint from the contour.
     bpoint can be a point object or an index.
     """
     if not isinstance(bPoint, int):
         bPoint = bPoint.index
     bPoint = normalizers.normalizeIndex(bPoint)
     if bPoint >= self._len__points():
         raise ValueError("No bPoint located at index %d." % bPoint)
     self._removeBPoint(bPoint)
Esempio n. 15
0
 def removePoint(self, point):
     """
     Remove the point from the contour.
     point can be a point object or an index.
     """
     if not isinstance(point, int):
         point = self.points.index(point)
     point = normalizers.normalizeIndex(point)
     if point >= self._len__points():
         raise ValueError("No point located at index %d." % point)
     self._removePoint(point)
Esempio n. 16
0
 def removeSegment(self, segment, preserveCurve=False):
     """
     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.
     """
     if not isinstance(segment, int):
         segment = self.segments.index(segment)
     segment = normalizers.normalizeIndex(segment)
     if segment >= self._len__segments():
         raise ValueError("No segment located at index %d." % segment)
     preserveCurve = normalizers.normalizeBoolean(preserveCurve)
     self._removeSegment(segment, preserveCurve)
Esempio n. 17
0
 def insertSegment(self, index, type, points, smooth=False):
     """
     Insert a segment into the contour.
     """
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._insertSegment(index=index, type=type,
                         points=points, smooth=smooth)
Esempio n. 18
0
 def removeSegment(self, segment, preserveCurve=False):
     """
     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.
     """
     if not isinstance(segment, int):
         segment = self.segments.index(segment)
     segment = normalizers.normalizeIndex(segment)
     if segment >= self._len__segments():
         raise ValueError("No segment located at index %d." % segment)
     preserveCurve = normalizers.normalizeBoolean(preserveCurve)
     self._removeSegment(segment, preserveCurve)
Esempio n. 19
0
 def removePoint(self, point, preserveCurve=False):
     """
     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.
     """
     if not isinstance(point, int):
         point = self.points.index(point)
     point = normalizers.normalizeIndex(point)
     if point >= self._len__points():
         raise ValueError("No point located at index %d." % point)
     preserveCurve = normalizers.normalizeBoolean(preserveCurve)
     self._removePoint(point, preserveCurve)
Esempio n. 20
0
 def removePoint(self, point, preserveCurve=False):
     """
     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.
     """
     if not isinstance(point, int):
         point = self.points.index(point)
     point = normalizers.normalizeIndex(point)
     if point >= self._len__points():
         raise ValueError("No point located at index %d." % point)
     preserveCurve = normalizers.normalizeBoolean(preserveCurve)
     self._removePoint(point, preserveCurve)
Esempio n. 21
0
 def insertSegment(self, index, type=None, points=None, smooth=False, segment=None):
     """
     Insert a segment into the contour.
     """
     if segment is not None:
         if type is not None:
             type = segment.type
         if points is None:
             points = [(point.x, point.y) for point in segment.points]
         smooth = segment.smooth
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeSegmentType(type)
     pts = []
     for pt in points:
         pt = normalizers.normalizeCoordinateTuple(pt)
         pts.append(pt)
     points = pts
     smooth = normalizers.normalizeBoolean(smooth)
     self._insertSegment(index=index, type=type,
                         points=points, smooth=smooth)
Esempio n. 22
0
 def insertBPoint(self, index, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None):
     """
     Insert a bPoint at index in the contour.
     """
     if bPoint is not None:
         if type is None:
             type = bPoint.type
         if anchor is None:
             anchor = bPoint.anchor
         if bcpIn is None:
             bcpIn = bPoint.bcpIn
         if bcpOut is None:
             bcpOut = bPoint.bcpOut
     index = normalizers.normalizeIndex(index)
     type = normalizers.normalizeBPointType(type)
     anchor = normalizers.normalizeCoordinateTuple(anchor)
     if bcpIn is None:
         bcpIn = (0, 0)
     bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
     if bcpOut is None:
         bcpOut = (0, 0)
     bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
     self._insertBPoint(index=index, type=type, anchor=anchor,
                        bcpIn=bcpIn, bcpOut=bcpOut)
Esempio n. 23
0
 def _get_base_index(self):
     if self.contour is None:
         return None
     value = self._get_index()
     value = normalizers.normalizeIndex(value)
     return value
Esempio n. 24
0
 def _get_base_index(self):
     value = self._get_index()
     value = normalizers.normalizeIndex(value)
     return value
Esempio n. 25
0
 def _get_base_index(self):
     value = self._get_index()
     value = normalizers.normalizeIndex(value)
     return value
Esempio n. 26
0
 def _get_base_index(self):
     if self.contour is None:
         return None
     value = self._get_index()
     value = normalizers.normalizeIndex(value)
     return value