Contour

Description

A Contour is a single path of any number of points. A Glyph usually consists of a couple of contours, and this is the object that represents each one. The Contour object offers access to the outline matter in various ways. The parent of Contour is usually Glyph.

Overview

Copy

BaseContour.copy Copy this object into a new object of the same type.

Parents

BaseContour.glyph The contour’s parent BaseGlyph.
BaseContour.layer The contour’s parent layer.
BaseContour.font The contour’s parent font.

Identification

BaseContour.identifier The unique identifier for the contour.
BaseContour.index The index of the contour within the ordered list of the parent glyph’s contours.

Winding Direction

BaseContour.clockwise Boolean indicating if the contour’s winding direction is clockwise.
BaseContour.reverse Reverse the direction of the contour.

Queries

BaseContour.bounds The bounds of the contour: (xMin, yMin, xMax, yMax) or None.
BaseContour.pointInside Determine if point is in the black or white of the contour.

Pens and Drawing

BaseContour.draw Draw the contour with the given Pen.
BaseContour.drawPoints Draw the contour with the given PointPen.

Segments

BaseContour.segments
BaseContour.__len__
BaseContour.__iter__
BaseContour.__getitem__
BaseContour.appendSegment Append a segment to the contour.
BaseContour.insertSegment Insert a segment into the contour.
BaseContour.removeSegment Remove segment from the contour.
BaseContour.setStartSegment Set the first segment on the contour.
BaseContour.autoStartSegment Automatically set the segment with on curve in the lower left of the contour as the first segment.

bPoints

BaseContour.bPoints
BaseContour.appendBPoint Append a bPoint to the contour.
BaseContour.insertBPoint Insert a bPoint at index in the contour.

Points

BaseContour.points
BaseContour.appendPoint Append a point to the contour.
BaseContour.insertPoint Insert a point into the contour.
BaseContour.removePoint Remove the point from the contour.

Transformations

BaseContour.transformBy Transform the object.
BaseContour.moveBy Move the object.
BaseContour.scaleBy Scale the object.
BaseContour.rotateBy Rotate the object.
BaseContour.skewBy Skew the object.

Normalization

BaseContour.round Round coordinates in all points.

Environment

BaseContour.naked Return the environment’s native object that has been wrapped by this object.
BaseContour.changed Tell the environment that something has changed in the object.

Reference

class fontParts.base.BaseContour(*args, **kwargs)

Copy

BaseContour.copy()

Copy this object into a new object of the same type. The returned object will not have a parent object.

Parents

BaseContour.glyph

The contour’s parent BaseGlyph.

BaseContour.layer

The contour’s parent layer.

BaseContour.font

The contour’s parent font.

Identification

BaseContour.identifier

The unique identifier for the contour.

BaseContour.index

The index of the contour within the ordered list of the parent glyph’s contours.

Winding Direction

BaseContour.clockwise

Boolean indicating if the contour’s winding direction is clockwise.

BaseContour.reverse(**kwargs)

Reverse the direction of the contour.

Queries

BaseContour.bounds

The bounds of the contour: (xMin, yMin, xMax, yMax) or None.

BaseContour.pointInside(point)

Determine if point is in the black or white of the contour.

point must be an (x, y) tuple.

Pens and Drawing

BaseContour.draw(pen, **kwargs)

Draw the contour with the given Pen.

BaseContour.drawPoints(pen, **kwargs)

Draw the contour with the given PointPen.

Segments

BaseContour.segments
BaseContour.__len__()
BaseContour.__iter__()
BaseContour.__getitem__(index)
BaseContour.appendSegment(type, points, smooth=False, **kwargs)

Append a segment to the contour.

BaseContour.insertSegment(index, type, points, smooth=False, **kwargs)

Insert a segment into the contour.

BaseContour.removeSegment(segment, **kwargs)

Remove segment from the contour.

BaseContour.setStartSegment(segment, **kwargs)

Set the first segment on the contour. segment can be a segment object or an index.

BaseContour.autoStartSegment(**kwargs)

Automatically set the segment with on curve in the lower left of the contour as the first segment.

bPoints

BaseContour.bPoints
BaseContour.appendBPoint(type, anchor, bcpIn=None, bcpOut=None, **kwargs)

Append a bPoint to the contour.

BaseContour.insertBPoint(index, type, anchor, bcpIn=None, bcpOut=None, **kwargs)

Insert a bPoint at index in the contour.

Points

BaseContour.points
BaseContour.appendPoint(position, type='line', smooth=False, name=None, identifier=None, **kwargs)

Append a point to the contour.

BaseContour.insertPoint(index, position, type='line', smooth=False, name=None, identifier=None, **kwargs)

Insert a point into the contour.

BaseContour.removePoint(point, **kwargs)

Remove the point from the contour. point can be a point object or an index.

Transformations

BaseContour.transformBy(matrix, origin=None)

Transform the object.

>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0))
>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))

matrix must be a Transformation Matrix. origin defines the point at with the transformation should originate. It must be a Coordinate or None. The default is (0, 0).

BaseContour.moveBy(value)

Move the object.

>>> obj.transformBy((10, 0))

value must be an iterable containing two Integer/Float values defining the x and y values to move the object by.

BaseContour.scaleBy(value, origin=None)

Scale the object.

>>> obj.transformBy(2.0)
>>> obj.transformBy((0.5, 2.0), origin=(500, 500))

value must be an iterable containing two Integer/Float values defining the x and y values to scale the object by. origin defines the point at with the scale should originate. It must be a Coordinate or None. The default is (0, 0).

BaseContour.rotateBy(value, origin=None)

Rotate the object.

>>> obj.transformBy(45)
>>> obj.transformBy(45, origin=(500, 500))

value must be a Integer/Float values defining the angle to rotate the object by. origin defines the point at with the rotation should originate. It must be a Coordinate or None. The default is (0, 0).

BaseContour.skewBy(value, origin=None)

Skew the object.

>>> obj.skewBy(11)
>>> obj.skewBy((25, 10), origin=(500, 500))

value must be rone of the following:

  • single Integer/Float indicating the value to skew the x direction by.
  • iterable cointaining type Integer/Float defining the values to skew the x and y directions by.

origin defines the point at with the skew should originate. It must be a Coordinate or None. The default is (0, 0).

Normalization

BaseContour.round(**kwargs)

Round coordinates in all points.

Environment

BaseContour.naked()

Return the environment’s native object that has been wrapped by this object.

>>> loweLevelObj = obj.naked()
BaseContour.changed(*args, **kwargs)

Tell the environment that something has changed in the object. The behavior of this method will vary from environment to environment.

>>> obj.changed()