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¶
Copy the current object into a new object of the same type. |
Parents¶
Get or set the anchor's parent glyph object. |
|
Get the anchor's parent layer object. |
|
Get the anchor's parent font object. |
Identification¶
Get or set the anchor's name. |
|
Get or set the anchor's color. |
|
Get the object's unique identifier. |
|
Get the anchor's index. |
Coordinate¶
Get or set the anchor's x-coordinate. |
|
Get or set the anchor's y-coordinate. |
Transformations¶
Transform the object according to the given matrix. |
|
Move the object according to the given coordinates. |
|
Scale the object according to the given values. |
|
Rotate the object by the specified value. |
|
Skew the object by the given value. |
Normalization¶
Round the anchor's coordinate. |
Environment¶
Return the environment's native object wrapped by the current object. |
|
Tell the environment that something has changed in the object. |
Reference¶
- class fontParts.base.BaseAnchor(*args: Any, **kwargs: Any)[source]¶
Represent the basis for 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() 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
BaseObjectsubclass instance with the same attributes.
Parents¶
- BaseAnchor.glyph: dynamicProperty¶
Get or set the anchor’s parent glyph object.
The value must be a
BaseGlyphinstance orNone.- Returns:
- Raises:
AssertionError – If attempting to set the glyph when it has already been set.
Example:
>>> glyph = anchor.glyph
- BaseAnchor.layer: dynamicProperty¶
Get the anchor’s parent layer object.
This property is read-only.
Example:
>>> layer = anchor.layer
Identification¶
- BaseAnchor.name: dynamicProperty¶
Get or set the anchor’s name.
- BaseAnchor.color: dynamicProperty¶
Get or set the anchor’s color.
The value must be a Color or
None.Example:
>>> anchor.color None >>> anchor.color = (1, 0, 0, 0.5)
- BaseAnchor.identifier¶
Get the object’s unique identifier.
This attribute is read-only. Use
IdentifierMixin.getIdentifierto request an identifier if it does not exist.- Returns:
The unique identifier assigned to the object as a
str, orNoneindicating the object has no identifier.
Example
>>> object.identifier 'ILHGJlygfds'
Coordinate¶
Transformations¶
- BaseAnchor.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))
- BaseAnchor.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))
- BaseAnchor.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:
Example:
>>> obj.scaleBy(2.0) >>> obj.scaleBy((0.5, 2.0), origin=(500, 500))
- BaseAnchor.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
intor afloat.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))
- BaseAnchor.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
intorfloatcorresponding to the x direction, or atupleof twointorfloatvalues 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¶
Environment¶
- BaseAnchor.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()