Component

Description

A component can be a part of a glyph, and it is a reference to another glyph in the same font. With components you can make glyphs depend on other glyphs. Changes to the base glyph will reflect in the component as well.

The parent of a component is usually a glyph. Components can be decomposed: they replace themselves with the actual outlines from the base glyph. When that happens, the link between the original and the component is broken: changes to the base glyph will no longer reflect in the glyph that had the component.

Overview

Parents

BaseComponent.glyph The component’s parent glyph.
BaseComponent.layer The component’s parent layer.
BaseComponent.font The component’s parent font.

Copy

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

Identification

BaseComponent.identifier The unique identifier for the object.
BaseComponent.index The index of the component within the ordered list of the parent glyph’s components.

Attributes

BaseComponent.baseGlyph The name of the glyph the component references.
BaseComponent.transformation The component’s transformation matrix.
BaseComponent.offset The component’s offset.
BaseComponent.scale The component’s scale.

Queries

BaseComponent.bounds The bounds of the component: (xMin, yMin, xMax, yMax) or None.
BaseComponent.pointInside Determine if point is in the black or white of the component.

Pens and Drawing

BaseComponent.draw Draw the component with the given Pen.
BaseComponent.drawPoints Draw the contour with the given PointPen.

Transformations

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

Normalization

BaseComponent.decompose Decompose the component.
BaseComponent.round Round offset coordinates.

Environment

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

Reference

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

Parents

BaseComponent.glyph

The component’s parent glyph.

BaseComponent.layer

The component’s parent layer.

BaseComponent.font

The component’s parent font.

Copy

BaseComponent.copy()

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

Identification

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

BaseComponent.index

The index of the component within the ordered list of the parent glyph’s components.

Attributes

BaseComponent.baseGlyph

The name of the glyph the component references.

BaseComponent.transformation

The component’s transformation matrix.

BaseComponent.offset

The component’s offset.

BaseComponent.scale

The component’s scale.

Queries

BaseComponent.bounds

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

BaseComponent.pointInside(point)[source]

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

point must be an (x, y) tuple.

Pens and Drawing

BaseComponent.draw(pen)[source]

Draw the component with the given Pen.

BaseComponent.drawPoints(pen)[source]

Draw the contour with the given PointPen.

Transformations

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

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

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

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

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

BaseComponent.decompose()[source]

Decompose the component.

BaseComponent.round()[source]

Round offset coordinates.

Environment

BaseComponent.naked()

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

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