RContour

class RContour()

selection

Return a list of selected points.

wrapper(*args, **kwargs)

breakContour(point)

Break the contour at a given point. Point could also be the index.

changed()

Notifiy the object has changed.

convertToCubic(round=1)

Convert all curves to cubic curves. Optionally a round value can be provided.

convertToQuadratic(round=1)

Convert all curves to quadratic curves. Optionally a round value can be provided.

extremePoints(round=1)

Add extreme points in the contour. Optionally a round value can be provided.

hasOverlap()

Return a boolean if the contour has overlaps.

join()

Join the contour, if the contour.open

removeBPoint(bPoint, preserveCurve=False)

Remove BP point from contour.

Optionally preserveCurve can be enabled.

removeOverlap(round=1)

Perform a remove overlap on a contour. Optionally a round value can be provided.

updateSelection(sender)

Update the selection.

addObserver(observer, methodName, notification)

Add an observer object. that will receive notification for the given methodName.

asDefcon()

Return the defcon object.

asFontParts()

Return a fontParts object

getRepresentation(name, **kwargs)

Get a representation by name.

Optionally arguments could be provided if the representation factory requires arguments.

holdChanges()

Capture changes and bundle them in a single change in a with statement.

performUndo()

Create a undo item and add it the the undo manager.

prepareUndo(undoTitle='')

Save the current state of the object.

releaseHeldChanges()

removeObserver(observer, notification)

Remove an observer object for a notification.

undo(undoTitle='')

Capture the current state of the object and create a undo item in a with statement.

Optionally an undoTitle can be provided.

Inherits from subclass: fontParts.fontshell.contour.RContour

area

The area of the contour: A positive number or None.

bPoints

bounds

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

clockwise

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

font

The contour’s parent font.

glyph

The contour’s parent BaseGlyph.

index

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

>>> contour.index
1
>>> contour.index = 0

The value will always be a type-int.

layer

The contour’s parent layer.

open

Boolean indicating if the contour is open.

points

segments

selectedBPoints

A list of bPoints selected in the contour.

Getting selected bPoint objects:

>>> for bPoint in contour.selectedBPoints:
...     bPoint.move((10, 20))

Setting selected bPoint objects:

>>> contour.selectedBPoints = someBPoints

Setting also supports bPoint indexes:

>>> contour.selectedBPoints = [0, 2]

selectedPoints

A list of points selected in the contour.

Getting selected point objects:

>>> for point in contour.selectedPoints:
...     point.move((10, 20))

Setting selected point objects:

>>> contour.selectedPoints = somePoints

Setting also supports point indexes:

>>> contour.selectedPoints = [0, 2]

selectedSegments

A list of segments selected in the contour.

Getting selected segment objects:

>>> for segment in contour.selectedSegments:
...     segment.move((10, 20))

Setting selected segment objects:

>>> contour.selectedSegments = someSegments

Setting also supports segment indexes:

>>> contour.selectedSegments = [0, 2]

copyAttributes

selected

The object’s selection state.

>>> obj.selected
False
>>> obj.selected = True

identifier

The unique identifier for the object. This value will be an identifier or a None. This attribute is read only.

>>> object.identifier
'ILHGJlygfds'

To request an identifier if it does not exist use object.getIdentifier()

box

Deprecated Contour.box

naked()

appendBPoint(type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None)

Append a bPoint to the contour.

appendPoint(position=None, type='line', smooth=False, name=None, identifier=None, point=None)

Append a point to the contour.

appendSegment(type=None, points=None, smooth=False, segment=None)

Append a segment to the contour.

contourInside(otherContour)

Determine if otherContour is in the black or white of this contour.

>>> contour.contourInside(otherContour)
True

contour must be a BaseContour.

copyData(source)

Subclasses may override this method. If so, they should call the super.

draw(pen)

Draw the contour’s outline data to the given type-pen.

>>> contour.draw(pen)

drawPoints(pen)

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

>>> contour.drawPoints(pointPen)

getIdentifierForPoint(point)

Create a unique identifier for and assign it to point. If the point already has an identifier, the existing identifier will be returned.

>>> contour.getIdentifierForPoint(point)
'ILHGJlygfds'

point must be a BasePoint. The returned value will be a identifier.

insertBPoint(index, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None)

Insert a bPoint at index in the contour.

insertPoint(index, position=None, type='line', smooth=False, name=None, identifier=None, point=None)

Insert a point into the contour.

insertSegment(index, type=None, points=None, smooth=False, segment=None)

Insert a segment into the contour.

isCompatible(other)

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

This will return a bool indicating if the contour is compatible for interpolation with other and a string of compatibility notes.

pointInside(point)

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

>>> contour.pointInside((40, 65))
True

point must be a coordinate.

removePoint(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.

removeSegment(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.

reverse()

Reverse the direction of the contour.

round()

Round coordinates in all points to integers.

setStartPoint(point)

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

setStartSegment(segment)

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

moveBy(value)

Move the object.

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

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

rotateBy(value, origin=None)

Rotate the object.

>>> obj.rotateBy(45)
>>> obj.rotateBy(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).

scaleBy(value, origin=None)

Scale the object.

>>> obj.scaleBy(2.0)
>>> obj.scaleBy((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).

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).

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. origin defines the point at with the transformation should originate. It must be a coordinate or None. The default is (0, 0).

getIdentifier()

Create a new, unique identifier for and assign it to the object. If the object already has an identifier, the existing one should be returned.

generateIdentifier()

generateIdentifierforPoint(point)

getParent()

reverseContour()

setChanged()

update()

move(*args, **kwargs)

rotate(*args, **kwargs)

scale(*args, **kwargs)

skew(*args, **kwargs)

transform(*args, **kwargs)

translate(*args, **kwargs)

setParent(parent)

Last edited on 18/03/2024