Contour

Must Override

BaseContour._getPoint(index: int, **kwargs: Any) BasePoint[source]

Get the given point from the native contour.

Parameters:
  • index – The index representing the BaseBPoint subclass instance to retrieve as an int. The value will have been normalized with normalizers.normalizeIndex.

  • **kwargs – Additional keyword arguments.

Returns:

A BasePoint subclass instance.

Important

Subclasses must override this method.

BaseContour._get_clockwise() bool[source]

Determine whether the native contour’s winding direction is clockwise.

This is the environment implementation of the BaseContour.clockwise property getter.

Returns:

True if the contour’s winding direction is clockwise, otherwise False. The value will have been normalized with normalizers.normalizeBoolean.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseContour._get_identifier() str | None

Get the native object’s unique identifier.

This is the environment implementation of IdentifierMixin.identifier.

If the native object does not have an identifier assigned, one may be assigned with IdentifierMixin.getIdentifier

Returns:

The unique identifier assigned to the object as a str, or None indicating the object has no identifier.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseContour._insertPoint(index: int, position: list[int | float] | tuple[int | float, int | float], type: str, smooth: bool, name: str | None, identifier: str | None, **kwargs: Any) None[source]

Insert the given point into the native contour.

This is the environment implementation of BaseContour.insertPoint.

Parameters:
Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseContour._lenPoints(**kwargs: Any) int[source]

Return the number of points in the native contour.

Parameters:

**kwargs – Additional keyword arguments.

Returns:

An int representing the number of BasePoint subclass instances belonging to the contour.

Important

Subclasses must override this method.

BaseContour._removePoint(index: int, preserveCurve: bool, **kwargs: Any) None[source]

Remove the given point from the native contour.

This is the environment implementation of BaseContour.removePoint.

Parameters:
  • index – The index representing the BasePoint subclass instance to remove as an int. The value will have been normalized with normalizers.normalizeIndex.

  • preserveCurve – A bool indicating whether to preserve the curve’s shape after the point is removed. The value will have been normalized with normalizers.normalizeBoolean.

  • **kwargs – Additional keyword arguments.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseContour._set_index(value: int) None[source]

Set the index of the contour.

This is the environment implementation of the BaseContour.index property setter.

Parameters:

value – The index to set as an int. The value will have been normalized with normalizers.normalizeIndex.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

May Override

BaseContour._appendBPoint(type: str, anchor: list[int | float] | tuple[int | float, int | float], bcpIn: list[int | float] | tuple[int | float, int | float], bcpOut: list[int | float] | tuple[int | float, int | float], **kwargs: Any) None[source]

Append the given bPoint to the native contour.

This is the environment implementation of BaseContour.appendBPoint.

Parameters:

Note

Subclasses may override this method.

BaseContour._appendSegment(type: str, points: list[list[int | float] | tuple[int | float, int | float]] | tuple[list[int | float] | tuple[int | float, int | float], ...], smooth: bool, **kwargs: Any) None[source]

Append the given segment to the native contour.

This is the environment implementation of BaseContour.appendSegment.

Parameters:

Note

Subclasses may override this method.

BaseContour._autoStartSegment(**kwargs: Any) None[source]

Automatically calculate and set the native contour’s first segment.

This is the environment implementation of BaseContour.autoStartSegment.

Parameters:

**kwargs – Additional keyword arguments.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseContour._draw(pen: AbstractPen, **kwargs: Any) None[source]

Draw the native contour’s outline data to the given pen.

This is the environment implementation of BaseContour.draw.

Parameters:
  • pen – The fontTools.pens.basePen.AbstractPen to which the outline data should be drawn.

  • **kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._drawPoints(pen: AbstractPointPen, **kwargs: Any) None[source]

Draw the native contour’s outline data to the given point pen.

This is the environment implementation of BaseContour.drawPoints.

Parameters:
  • pen – The fontTools.pens.basePen.AbstractPointPen to which the outline data should be drawn.

  • **kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._get_bounds() tuple[float, float, float, float] | None[source]

Get the bounds of the contour.

This is the environment implementation of the BaseContour.bounds property getter.

Returns:

A tuple of four int or float values in the form (x minimum, y minimum, x maximum, y maximum) representing the bounds of the contour, or None if the contour is open.

Note

Subclasses may override this method.

BaseContour._get_index() int | None[source]

Get the index of the native contour.

This is the environment implementation of the BaseContour.index property getter.

Returns:

An int representing the contour’s index within an ordered list of the parent glyph’s contours, or None if the contour does not belong to a glyph. The value will be normalized with normalizers.normalizeIndex.

Note

Subclasses may override this method.

BaseContour._get_points() tuple[BasePoint, ...][source]

Get a list of all points in the native contour.

This is the environment implementation of the BaseContour.points property getter.

Returns:

A tuple of :class`BasePoint` subclass instances.

Note

Subclasses may override this method.

BaseContour._get_segments() tuple[BaseSegment, ...][source]

Get the native contour’s segments.

This is the environment implementation of the BaseContour.segments property getter.

Returns:

A tuple of BaseSegment subclass instances.

Note

Subclasses may override this method.

BaseContour._init(*args: Any, **kwargs: Any) None

Initialize the native object.

This is the environment implementation of BaseObject.__init__.

Parameters:
  • *args – Any positional arguments.

  • **kwargs – Any keyword arguments.

Note

Subclasses may override this method.

BaseContour._insertBPoint(index: int, type: str, anchor: list[int | float] | tuple[int | float, int | float], bcpIn: list[int | float] | tuple[int | float, int | float], bcpOut: list[int | float] | tuple[int | float, int | float], **kwargs: Any) None[source]

Insert the given bPoint into the native contour.

This is the environment implementation of BaseContour.insertBPoint.

Parameters:

Note

Subclasses may override this method.

BaseContour._insertSegment(index: int, type: str, points: list[list[int | float] | tuple[int | float, int | float]] | tuple[list[int | float] | tuple[int | float, int | float], ...], smooth: bool, **kwargs: Any) None[source]

Insert the given segment into the native contour.

This is the environment implementation of BaseContour.insertSegment.

Parameters:

Note

Subclasses may override this method.

BaseContour._len__segments(**kwargs: Any) int[source]

Return the number of segments in the native contour.

This is the environment implementation of BaseContour.__len__.

Returns:

An int representing the number of BaseSegment subclass instances belonging to the contour.

Parameters:

**kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._moveBy(value: list[int | float] | tuple[int | float, int | float], **kwargs: Any) None

Move the native object according to the given coordinates.

This is the environment implementation of BaseObject.moveBy.

Parameters:

Note

Subclasses may override this method.

BaseContour._pointInside(point: list[int | float] | tuple[int | float, int | float]) bool[source]

Check if point is within the filled area of the native contour.

This is the environment implementation of BaseContour.pointInside.

Parameters:

point

The point to check as a Coordinate. The value

will have been normalized with normalizers.normalizeCoordinateTuple.

return:

True if point is inside the filled area of the contour, False otherwise.

Note

Subclasses may override this method.

BaseContour._removeSegment(index: int, preserveCurve: bool, **kwargs: Any) None[source]

Remove the given segment from the native contour.

This is the environment implementation of BaseContour.removeSegment.

Parameters:
  • index – The segment to remove as an int representing the segment’s index. The value will have been normalized with normalizers.normalizeIndex.

  • preserveCurve – A bool indicating whether to preserve the curve’s shape after the segment is removed. Defaults to False. The value will have been normalized with normalizers.normalizeBoolean.

  • **kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._reverse(**kwargs) None[source]

Reverse the direction of the contour.

This is the environment implementation of BaseContour.reverse.

Parameters:

**kwargs – Additional keyword arguments.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseContour._rotateBy(value: float, origin: list[int | float] | tuple[int | float, int | float], **kwargs: Any) None

Rotate the native object by the specified value.

This is the environment implementation of TransformationMixin.rotateBy.

Parameters:
  • value – The angle at which to rotate the object as an int or a float. The value will have been normalized with normalizers.normalizeRotationAngle.

  • origin – The point at which the rotation should originate as a Coordinate or None. The value will have been normalized with normalizers.normalizeCoordinateTuple.

  • **kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._round(**kwargs: Any) None[source]

Round all point coordinates in the native contour to the nearest integer.

This is the environment implementation of BaseContour.round.

Parameters:

**kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._scaleBy(value: list[int | float] | tuple[float, float], origin: list[int | float] | tuple[int | float, int | float], **kwargs: Any) None

Scale the native object according to the given values.

This is the environment implementation of BaseObject.scaleBy.

Parameters:
  • value – The value to scale the glyph by as a single int or float, or a tuple or list of two int or float values representing the values (x, y). The value will have been normalized with normalizeTransformationScale.

  • origin – The point at which the scale should originate as a Coordinate or None. The value will have been normalized with normalizers.normalizeCoordinateTuple.

  • **kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._setStartSegment(segmentIndex: int, **kwargs: Any) None[source]

Set the first segment in the native contour.

This is the environment implementation of BaseContour.setStartSegment.

Parameters:
  • segmentIndex – An int representing the index of the segment to be set as the first instance in the contour.

  • **kwargs – Additional keyword arguments.

Note

Subclasses may override this method.

BaseContour._set_clockwise(value: bool) None[source]

Specify whether the native contour’s winding direction is clockwise.

This is the environment implementation of the BaseContour.clockwise property setter.

Parameters:

value – A bool indicating the desired winding direction. True sets the direction to clockwise, and False to counter-clockwise. The value will have been normalized with normalizers.normalizeBoolean.

Note

Subclasses may override this method.

BaseContour._skewBy(value: list[int | float] | tuple[float, float], origin: list[int | float] | tuple[int | float, int | float], **kwargs: Any) None

Skew the native object by the given value.

This is the environment implementation of TransformationMixin.skewBy.

Parameters:

Note

Subclasses may override this method.

BaseContour._transformBy(matrix: list[int | float] | tuple[float, float, float, float, float, float], **kwargs: Any) None[source]

Transform the contour according to the given matrix.

This is the environment implementation of BaseContour.transformBy.

Parameters:

Note

Subclasses may override this method.