Anchor

Description

Anchors are single points in a glyph which are not part of a contour. They can be used as reference positions for doing things like assembling components. In most font editors, anchors have a special appearance and can be edited.

glyph = CurrentGlyph()
for anchor in glyph.anchors:
    print(anchor)

Overview

Copy

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

Parents

BaseAnchor.glyph The anchor’s parent BaseGlyph.
BaseAnchor.layer The anchor’s parent BaseLayer.
BaseAnchor.font The anchor’s parent BaseFont.

Identification

BaseAnchor.name The name of the anchor.
BaseAnchor.color The anchor’s color.
BaseAnchor.identifier The unique identifier for the object.
BaseAnchor.index The index of the anchor within the ordered list of the parent glyph’s anchors.

Coordinate

BaseAnchor.x The x coordinate of the anchor.
BaseAnchor.y The y coordinate of the anchor.

Transformations

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

Normalization

BaseAnchor.round Round the anchor’s coordinate.

Environment

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

Reference

class fontParts.base.BaseAnchor(*args, **kwargs)[source]

An anchor object. This object is almost always created with BaseGlyph.appendAnchor. An orphan anchor can be created like this:

>>> anchor = RAnchor()

Copy

BaseAnchor.copy()

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

Parents

BaseAnchor.glyph

The anchor’s parent BaseGlyph.

BaseAnchor.layer

The anchor’s parent BaseLayer.

BaseAnchor.font

The anchor’s parent BaseFont.

Identification

BaseAnchor.name

The name of the anchor. This will be a String or None.

>>> anchor.name
'my anchor'
>>> anchor.name = None
BaseAnchor.color

The anchor’s color. This will be a Color or None.

>>> anchor.color
None
>>> anchor.color = (1, 0, 0, 0.5)
BaseAnchor.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()

BaseAnchor.index

The index of the anchor within the ordered list of the parent glyph’s anchors. This attribute is read only.

>>> anchor.index
0

Coordinate

BaseAnchor.x

The x coordinate of the anchor. It must be an Integer/Float.

>>> anchor.x
100
>>> anchor.x = 101
BaseAnchor.y

The y coordinate of the anchor. It must be an Integer/Float.

>>> anchor.y
100
>>> anchor.y = 101

Transformations

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

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

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

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

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

BaseAnchor.round()[source]

Round the anchor’s coordinate.

>>> anchor.round()

This applies to the following:

  • x
  • y

Environment

BaseAnchor.naked()

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

>>> loweLevelObj = obj.naked()
BaseAnchor.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()