Guideline

Description

Guidelines are reference lines in a glyph that are not part of a contour or the generated font data. They are defined by a point and an angle; the guideline extends from the point in both directions on the specified angle. They are most often used to keep track of design information for a font (‘my overshoots should be here’) or to measure positions in a glyph (‘line the ends of my serifs on this line’). They can also be used as reference positions for doing things like assembling components. In most font editors, guidelines have a special appearance and can be edited.

glyph = CurrentGlyph()
for guideline in glyph.guidelines:
    print(guideline)

Overview

Copy

BaseGuideline.copy

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

Parents

BaseGuideline.glyph

Get or set the guideline's parent glyph object.

BaseGuideline.layer

Get the guideline's parent layer object.

BaseGuideline.font

Get the guideline's parent font object.

Identification

BaseGuideline.name

Get or set the guideline's name.

BaseGuideline.color

Get or set the guideline's color.

BaseGuideline.identifier

Get the object's unique identifier.

BaseGuideline.index

Get the guideline's index.

Attributes

BaseGuideline.x

Get or set the guideline's x-coordinate.

BaseGuideline.y

Get or set the guideline's y-coordinate.

BaseGuideline.angle

Get or set the guideline's angle.

Transformations

BaseGuideline.transformBy

Transform the object according to the given matrix.

BaseGuideline.moveBy

Move the object according to the given coordinates.

BaseGuideline.scaleBy

Scale the object according to the given values.

BaseGuideline.rotateBy

Rotate the object by the specified value.

BaseGuideline.skewBy

Skew the object by the given value.

Normalization

BaseGuideline.round

Round the guideline's coordinate.

Environment

BaseGuideline.naked

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

BaseGuideline.changed

Tell the environment that something has changed in the object.

Reference

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

Represent the basis for a guideline object.

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

>>> guideline = RGuideline()

Copy

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

BaseGuideline.glyph: dynamicProperty

Get or set the guideline’s parent glyph object.

The value must be a BaseGlyph instance or None.

Returns:

The BaseGlyph instance containing the guideline or None.

Raises:

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

Example:

>>> glyph = guideline.glyph
BaseGuideline.layer: dynamicProperty

Get the guideline’s parent layer object.

This property is read-only.

Returns:

The BaseLayer instance containing the guideline or None.

Example:

>>> layer = guideline.layer
BaseGuideline.font: dynamicProperty

Get the guideline’s parent font object.

This property is read-only.

Returns:

The BaseFont instance containing the guideline or None.

Example:

>>> font = guideline.font

Identification

BaseGuideline.name: dynamicProperty

Get or set the guideline’s name.

The value must be a str or None.

Returns:

A str representing the name of the guideline, or None.

>>> guideline.name
'my guideline'
>>> guideline.name = None

BaseGuideline.color: dynamicProperty

Get or set the guideline’s color.

The value must be a Color or None.

Returns:

A Color instance representing the color of the guideline, or None.

Example:

>>> guideline.color
None
>>> guideline.color = (1, 0, 0, 0.5)
BaseGuideline.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'
BaseGuideline.index: dynamicProperty

Get the guideline’s index.

This property is read-only.

Returns:

An int representing the index of the guideline within the ordered list of the parent glyph’s guidelines.

Example:

>>> guideline.index
0

Attributes

BaseGuideline.x: dynamicProperty

Get or set the guideline’s x-coordinate.

The value must be an int or a flat.

Returns:

An int or a flat representing the x-coordinate of the guideline.

Example:

>>> guideline.x
100
>>> guideline.x = 101
BaseGuideline.y: dynamicProperty

Get or set the guideline’s y-coordinate.

The value must be an int or a flat.

Returns:

An int or a flat representing the y-coordinate of the guideline.

Example:

>>> guideline.y
100
>>> guideline.y = 101
BaseGuideline.angle: dynamicProperty

Get or set the guideline’s angle.

The value must be int, float or None. If set to None, the angle is automatically derived based on the guideline’s x and y values:

  • If both x and y are 0, the angle defaults to 0.0.

  • If x is 0 and y is not, the angle is 90.0.

  • If y is 0 and x is not, the angle is 0.0.

Returns:

A float representing the angle of the guideline.

Example:

>>> guideline.angle
45.0
>>> guideline.angle = 90

Transformations

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

BaseGuideline.round() None[source]

Round the guideline’s coordinate.

This applies to:

  • x

  • :attr:`y

It does not apply to angle.

Example::`

>>> guideline.round()

Environment

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