Point

Description

Point represents one single point with a particular coordinate in a contour. It is used to access off-curve and on-curve points alike. Its cousin BPoint also provides access to incoming and outgoing bcps. Point is exclusively only one single point.

glyph = CurrentGlyph()
for contour in glyph:
    for point in contour.points:
        print(point)

Overview

Copy

BasePoint.copy

Copy the current object into a new object of the same type.

Parents

BasePoint.contour

Get or set the point's parent contour object.

BasePoint.glyph

Get the point's parent glyph object.

BasePoint.layer

Get the point's parent layer object.

BasePoint.font

Get the point's parent font object.

Identification

BasePoint.name

Get or set the name of the point.

BasePoint.identifier

Get the object's unique identifier.

BasePoint.index

Get the index of the point.

Coordinate

BasePoint.x

Get or set the x coordinate of the point.

BasePoint.y

Get or set the y coordinate of the point.

Type

BasePoint.type

Get or set the point's type.

BasePoint.smooth

Get or set the point's smooth state.

Transformations

BasePoint.transformBy

Transform the object according to the given matrix.

BasePoint.moveBy

Move the object according to the given coordinates.

BasePoint.scaleBy

Scale the object according to the given values.

BasePoint.rotateBy

Rotate the object by the specified value.

BasePoint.skewBy

Skew the object by the given value.

Normalization

BasePoint.round

Round the point's coordinates.

Environment

BasePoint.naked

Return the environment's native object wrapped by the current object.

BasePoint.changed

Tell the environment that something has changed in the object.

Reference

class fontParts.base.BasePoint(*args: Any, **kwargs: Any)[source]

Represent the basis for a point object.

This object is almost always created with BaseContour.appendPoint, the pen returned by BaseGlyph.getPen or the point pen returned by BaseGlyph.getPointPen.

An orphan point can be created like this:

>>> point = RPoint()

Copy

BasePoint.copy() BaseObjectType

Copy the current object into a new object of the same type.

The returned object will not have a parent object.

Returns:

A new BaseObject subclass instance with the same attributes.

Parents

BasePoint.contour: dynamicProperty

Get or set the point’s parent contour object.

The value must be a BaseContour instance or None.

Returns:

The BaseContour instance containing the point or None.

Raises:

AssertionError – If attempting to set the contour when it has already been set.

Example:

>>> contour = point.contour
BasePoint.glyph: dynamicProperty

Get the point’s parent glyph object.

This property is read-only.

The value must be a BaseGlyph instance or None.

Returns:

The BaseGlyph instance containing the point or None.

Example:

>>> glyph = point.glyph
BasePoint.layer: dynamicProperty

Get the point’s parent layer object.

This property is read-only.

Returns:

The BaseLayer instance containing the point or None.

Example:

>>> layer = point.layer
BasePoint.font: dynamicProperty

Get the point’s parent font object.

This property is read-only.

Returns:

The BaseFont instance containing the point or None.

Example:

>>> font = point.font

Identification

BasePoint.name: dynamicProperty

Get or set the name of the point.

The value must be a str or None.

Returns:

A str representing the point’s name or None.

Example:

>>> point.name
'my point'
>>> point.name = None
BasePoint.identifier

Get the object’s unique identifier.

This attribute is read-only. Use IdentifierMixin.getIdentifier to request an identifier if it does not exist.

Returns:

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

Example

>>> object.identifier
'ILHGJlygfds'
BasePoint.index: dynamicProperty

Get the index of the point.

This property is read-only.

Returns:

An int representing the point’s index within an ordered list of the parent contour’s points, or None if the point does not belong to a contour.

Example:

>>> point.index
0

Coordinate

BasePoint.x: dynamicProperty

Get or set the x coordinate of the point.

The value must be an int or a float.

Returns:

An int or a float representing the point’s x coordinate.

Example:

>>> point.x
100
>>> point.x = 101
BasePoint.y: dynamicProperty

Get or set the y coordinate of the point.

The value must be an int or a float.

Returns:

An int or a float representing the point’s y coordinate.

Example:

>>> point.y
100
>>> point.y = 101

Type

BasePoint.type: dynamicProperty

Get or set the point’s type.

The value must be a str containing one of the following alternatives:

Type

Description

'move' 'line' 'curve' 'qcurve' 'offcurve'

An on-curve move to. An on-curve line to. An on-curve cubic curve to. An on-curve quadratic curve to. An off-curve.

Returns:

A str representing the type of the point.

BasePoint.smooth: dynamicProperty

Get or set the point’s smooth state.

The value must be a bool indicating the point’s smooth state.

Returns:

True if the point is smooth, False if it is sharp.

Example:

>>> point.smooth
False
>>> point.smooth = True

Transformations

BasePoint.transformBy(matrix: list[int | float] | tuple[float, float, float, float, float, float], origin: list[int | float] | tuple[int | float, int | float] | None = None) None

Transform the object according to the given matrix.

Parameters:
  • matrix – The Transformation Matrix to apply.

  • origin – The optional point at which the transformation should originate as a:ref:type-coordinate. Defaults to None, representing an origin of (0, 0).

Example:

>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0))
>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))
BasePoint.moveBy(value: list[int | float] | tuple[int | float, int | float]) None

Move the object according to the given coordinates.

Parameters:

value – The x and y values to move the object by as a Coordinate.

Example:

>>> obj.moveBy((10, 0))
BasePoint.scaleBy(value: int | float | list[int | float] | tuple[float, float], origin: list[int | float] | tuple[int | float, int | float] | None = None) None

Scale the object according to the given values.

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

  • origin – The optional point at which the scale should originate as a Coordinate. Defaults to None, representing an origin of (0, 0).

Example:

>>> obj.scaleBy(2.0)
>>> obj.scaleBy((0.5, 2.0), origin=(500, 500))
BasePoint.rotateBy(value: int | float, origin: list[int | float] | tuple[int | float, int | float] | None = None) None

Rotate the object by the specified value.

Parameters:
  • value – The angle at which to rotate the object as an int or a float.

  • origin – The optional point at which the rotation should originate as a Coordinate. Defaults to None, representing an origin of (0, 0).

Example:

>>> obj.rotateBy(45)
>>> obj.rotateBy(45, origin=(500, 500))
BasePoint.skewBy(value: int | float | list[int | float] | tuple[float, float], origin: list[int | float] | tuple[int | float, int | float] | None = None) None

Skew the object by the given value.

Parameters:
  • value – The value by which to skew the object as either a single int or float corresponding to the x direction, or a tuple of two int or float values corresponding to the x and y directions.

  • origin – The optional point at which the rotation should originate as a Coordinate. Defaults to None, representing an origin of (0, 0).

Example:

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

Normalization

BasePoint.round() None[source]

Round the point’s coordinates.

This applies to:

Example:

>>> point.round()

Environment

BasePoint.naked() Any

Return the environment’s native object wrapped by the current object.

Raises:

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

Example:

>>> loweLevelObj = obj.naked()
BasePoint.changed(*args: Any, **kwargs: Any) None

Tell the environment that something has changed in the object.

The behavior of this method will vary from environment to environment.

Parameters:
  • *args – Any positional arguments.

  • **kwargs – Any keyword arguments.

Example:

>>> obj.changed()