Glyph

BaseGlyph(*args, **kwargs) A glyph object.
BaseGlyph.addImage([path, data, scale, …]) Set the image in the glyph.
BaseGlyph.anchors An Immutable List of all anchors in the glyph.
BaseGlyph.appendAnchor([name, position, …]) Append an anchor to this glyph.
BaseGlyph.appendComponent([baseGlyph, …]) Append a component to this glyph.
BaseGlyph.appendContour(contour[, offset]) Append a contour containing the same data as contour to this glyph.
BaseGlyph.appendGlyph(other[, offset]) Append the data from other to new objects in this glyph.
BaseGlyph.appendGuideline([position, angle, …]) Append a guideline to this glyph.
BaseGlyph.area The area of the glyph as a Integer/Float or, in the case of empty glyphs None.
BaseGlyph.autoContourOrder() Automatically order the contours based on heuristics.
BaseGlyph.autoUnicodes() Use heuristics to set the Unicode values in the glyph.
BaseGlyph.bottomMargin The glyph’s bottom margin.
BaseGlyph.bounds The bounds of the glyph in the form (x minimum, y minimum, x maximum, y maximum) or, in the case of empty glyphs None.
BaseGlyph.box Deprecated Glyph.box
BaseGlyph.center([padding])
BaseGlyph.changed(*args, **kwargs) Tell the environment that something has changed in the object.
BaseGlyph.clear([contours, components, …]) Clear the glyph.
BaseGlyph.clearAnchors() Clear all anchors in the glyph.
BaseGlyph.clearComponents() Clear all components in the glyph.
BaseGlyph.clearContours() Clear all contours in the glyph.
BaseGlyph.clearGuidelines() Clear all guidelines in the glyph.
BaseGlyph.clearHGuides()
BaseGlyph.clearImage() Remove the image from the glyph.
BaseGlyph.clearVGuides()
BaseGlyph.compatibilityReporterClass alias of fontParts.base.compatibility.GlyphCompatibilityReporter
BaseGlyph.components An Immutable List of all components in the glyph.
BaseGlyph.contours An Immutable List of all contours in the glyph.
BaseGlyph.copy() Copy this glyph’s data into a new glyph object.
BaseGlyph.copyAttributes
BaseGlyph.copyClass
BaseGlyph.copyData(source) Subclasses may override this method.
BaseGlyph.correctDirection([trueType]) Correct the winding direction of the contours following the PostScript recommendations.
BaseGlyph.decompose() Decompose all components in the glyph to contours.
BaseGlyph.draw(pen[, contours, components]) Draw the glyph’s outline data (contours and components) to the given type-pen.
BaseGlyph.drawPoints(pen[, contours, components]) Draw the glyph’s outline data (contours and components) to the given type-pointpen.
BaseGlyph.dumpToGLIF([glyphFormatVersion]) This will return the glyph’s contents as a string in GLIF format.
BaseGlyph.font The glyph’s parent font.
BaseGlyph.fromMathGlyph(mathGlyph) Replaces the contents of this glyph with the contents of mathGlyph.
BaseGlyph.getAnchors()
BaseGlyph.getComponents()
BaseGlyph.getLayer(name) Get the type-glyph-layer with name in this glyph.
BaseGlyph.getParent()
BaseGlyph.getPen() Return a type-pen object for adding outline data to the glyph.
BaseGlyph.getPointPen() Return a type-pointpen object for adding outline data to the glyph.
BaseGlyph.guidelines An Immutable List of all guidelines in the glyph.
BaseGlyph.height The glyph’s height.
BaseGlyph.image The BaseImage for the glyph.
BaseGlyph.interpolate(factor, minGlyph, maxGlyph) Interpolate the contents of this glyph at location factor in a linear interpolation between minGlyph and maxGlyph.
BaseGlyph.isCompatible(other) Evaluate the interpolation compatibility of this glyph and other.
BaseGlyph.isEmpty() This will return type-bool indicating if there are contours and/or components in the glyph.
BaseGlyph.layer The glyph’s parent layer.
BaseGlyph.layers Immutable tuple of the glyph’s layers.
BaseGlyph.leftMargin The glyph’s left margin.
BaseGlyph.lib The BaseLib for the glyph.
BaseGlyph.loadFromGLIF(glifData) Reads glifData, in GLIF format, into this glyph.
BaseGlyph.mark Deprecated Mark color
BaseGlyph.markColor The glyph’s mark color.
BaseGlyph.move(*args, **kwargs)
BaseGlyph.moveBy(value) Move the object.
BaseGlyph.naked() Return the environment’s native object that has been wrapped by this object.
BaseGlyph.name The glyph’s name.
BaseGlyph.newLayer(name) Make a new layer with name in this glyph.
BaseGlyph.note The glyph’s note.
BaseGlyph.pointInside(point) Determine if point is in the black or white of the glyph.
BaseGlyph.raiseNotImplementedError() This exception needs to be raised frequently by the base classes.
BaseGlyph.readGlyphFromString(glifData)
BaseGlyph.removeAnchor(anchor) Remove anchor from the glyph.
BaseGlyph.removeComponent(component) Remove component from the glyph.
BaseGlyph.removeContour(contour) Remove contour from the glyph.
BaseGlyph.removeGuideline(guideline) Remove guideline from the glyph.
BaseGlyph.removeLayer(layer) Remove layer from this glyph.
BaseGlyph.removeOverlap() Perform a remove overlap operation on the contours.
BaseGlyph.rightMargin The glyph’s right margin.
BaseGlyph.rotate(*args, **kwargs)
BaseGlyph.rotateBy(value[, origin]) Rotate the object.
BaseGlyph.round() Round coordinates to the nearest integer.
BaseGlyph.scale(*args, **kwargs)
BaseGlyph.scaleBy(value[, origin, width, height]) Scale the object.
BaseGlyph.selected The object’s selection state.
BaseGlyph.selectedAnchors An Immutable List of anchors selected in the glyph.
BaseGlyph.selectedComponents An Immutable List of components selected in the glyph.
BaseGlyph.selectedContours An Immutable List of contours selected in the glyph.
BaseGlyph.selectedGuidelines An Immutable List of guidelines selected in the glyph.
BaseGlyph.setChanged()
BaseGlyph.setParent(parent)
BaseGlyph.skew(*args, **kwargs)
BaseGlyph.skewBy(value[, origin]) Skew the object.
BaseGlyph.toMathGlyph() Returns the glyph as an object that follows the MathGlyph protocol.
BaseGlyph.topMargin The glyph’s top margin.
BaseGlyph.transform(*args, **kwargs)
BaseGlyph.transformBy(matrix[, origin]) Transform the object.
BaseGlyph.translate(*args, **kwargs)
BaseGlyph.unicode The glyph’s primary unicode value.
BaseGlyph.unicodes The glyph’s unicode values in order from most to least important.
BaseGlyph.update()
BaseGlyph.width The glyph’s width.
BaseGlyph.writeGlyphToString([…])

Description

The Glyph object represents a glyph, its parts and associated data.

Glyph can be used as a list of Contour objects.

When a Glyph is obtained from a Font object, the font is the parent object of the glyph.

Overview

Copy

BaseGlyph.copy Copy this glyph’s data into a new glyph object.

Parents

BaseGlyph.layer The glyph’s parent layer.
BaseGlyph.font The glyph’s parent font.

Identification

BaseGlyph.name The glyph’s name.
BaseGlyph.unicodes The glyph’s unicode values in order from most to least important.
BaseGlyph.unicode The glyph’s primary unicode value.

Metrics

BaseGlyph.width The glyph’s width.
BaseGlyph.leftMargin The glyph’s left margin.
BaseGlyph.rightMargin The glyph’s right margin.
BaseGlyph.height The glyph’s height.
BaseGlyph.bottomMargin The glyph’s bottom margin.
BaseGlyph.topMargin The glyph’s top margin.

Queries

BaseGlyph.bounds The bounds of the glyph in the form (x minimum, y minimum, x maximum, y maximum) or, in the case of empty glyphs None.
BaseGlyph.pointInside Determine if point is in the black or white of the glyph.

Pens and Drawing

BaseGlyph.getPen Return a type-pen object for adding outline data to the glyph.
BaseGlyph.getPointPen Return a type-pointpen object for adding outline data to the glyph.
BaseGlyph.draw Draw the glyph’s outline data (contours and components) to the given type-pen.
BaseGlyph.drawPoints Draw the glyph’s outline data (contours and components) to the given type-pointpen.

Layers

BaseGlyph.layers Immutable tuple of the glyph’s layers.
BaseGlyph.getLayer Get the type-glyph-layer with name in this glyph.
BaseGlyph.newLayer Make a new layer with name in this glyph.
BaseGlyph.removeLayer Remove layer from this glyph.

Global

BaseGlyph.clear Clear the glyph.
BaseGlyph.appendGlyph Append the data from other to new objects in this glyph.

Contours

BaseGlyph.contours An Immutable List of all contours in the glyph.
BaseGlyph.__len__ The number of contours in the glyph.
BaseGlyph.__iter__ Iterate through all contours in the glyph.
BaseGlyph.__getitem__ Get the contour located at index from the glyph.
BaseGlyph.appendContour Append a contour containing the same data as contour to this glyph.
BaseGlyph.removeContour Remove contour from the glyph.
BaseGlyph.clearContours Clear all contours in the glyph.
BaseGlyph.removeOverlap Perform a remove overlap operation on the contours.

Components

BaseGlyph.components An Immutable List of all components in the glyph.
BaseGlyph.appendComponent Append a component to this glyph.
BaseGlyph.removeComponent Remove component from the glyph.
BaseGlyph.clearComponents Clear all components in the glyph.
BaseGlyph.decompose Decompose all components in the glyph to contours.

Anchors

BaseGlyph.anchors An Immutable List of all anchors in the glyph.
BaseGlyph.appendAnchor Append an anchor to this glyph.
BaseGlyph.removeAnchor Remove anchor from the glyph.
BaseGlyph.clearAnchors Clear all anchors in the glyph.

Guidelines

BaseGlyph.guidelines An Immutable List of all guidelines in the glyph.
BaseGlyph.appendGuideline Append a guideline to this glyph.
BaseGlyph.removeGuideline Remove guideline from the glyph.
BaseGlyph.clearGuidelines Clear all guidelines in the glyph.

Image

BaseGlyph.image The BaseImage for the glyph.
BaseGlyph.addImage Set the image in the glyph.
BaseGlyph.clearImage Remove the image from the glyph.

Note

BaseGlyph.note The glyph’s note.
BaseGlyph.markColor The glyph’s mark color.

Sub-Objects

BaseGlyph.lib The BaseLib for the glyph.

Transformations

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

Interpolation

BaseGlyph.isCompatible Evaluate the interpolation compatibility of this glyph and other.
BaseGlyph.interpolate Interpolate the contents of this glyph at location factor in a linear interpolation between minGlyph and maxGlyph.

Normalization

BaseGlyph.round Round coordinates to the nearest integer.
BaseGlyph.autoUnicodes Use heuristics to set the Unicode values in the glyph.

Environment

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

Reference

class fontParts.base.BaseGlyph(*args, **kwargs)

A glyph object. This object will almost always be created by retrieving it from a font object.

Copy

BaseGlyph.copy()

Copy this glyph’s data into a new glyph object. This new glyph object will not belong to a font.

>>> copiedGlyph = glyph.copy()

This will copy:

  • name
  • unicodes
  • width
  • height
  • note
  • markColor
  • lib
  • contours
  • components
  • anchors
  • guidelines
  • image

Parents

BaseGlyph.layer

The glyph’s parent layer.

>>> layer = glyph.layer
BaseGlyph.font

The glyph’s parent font.

>>> font = glyph.font

Identification

BaseGlyph.name

The glyph’s name. This will be a String.

>>> glyph.name
"A"
>>> glyph.name = "A.alt"
BaseGlyph.unicodes

The glyph’s unicode values in order from most to least important.

>>> glyph.unicodes
(65,)
>>> glyph.unicodes = [65, 66]
>>> glyph.unicodes = []

The values in the returned tuple will be type-int. When setting you may use a list of type-int or type-hex values.

BaseGlyph.unicode

The glyph’s primary unicode value.

>>> glyph.unicode
65
>>> glyph.unicode = None

The returned value will be an type-int or None. When setting you may send type-int or type-hex values or None.

Metrics

BaseGlyph.width

The glyph’s width.

>>> glyph.width
500
>>> glyph.width = 200

The value will be a Integer/Float.

BaseGlyph.leftMargin

The glyph’s left margin.

>>> glyph.leftMargin
35
>>> glyph.leftMargin = 45

The value will be a Integer/Float.

BaseGlyph.rightMargin

The glyph’s right margin.

>>> glyph.rightMargin
35
>>> glyph.rightMargin = 45

The value will be a Integer/Float.

BaseGlyph.height

The glyph’s height.

>>> glyph.height
500
>>> glyph.height = 200

The value will be a Integer/Float.

BaseGlyph.bottomMargin

The glyph’s bottom margin.

>>> glyph.bottomMargin
35
>>> glyph.bottomMargin = 45

The value will be a Integer/Float.

BaseGlyph.topMargin

The glyph’s top margin.

>>> glyph.topMargin
35
>>> glyph.topMargin = 45

The value will be a Integer/Float.

Queries

BaseGlyph.bounds

The bounds of the glyph in the form (x minimum, y minimum, x maximum, y maximum) or, in the case of empty glyphs None.

>>> glyph.bounds
(10, 30, 765, 643)
BaseGlyph.pointInside(point)

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

>>> glyph.pointInside((40, 65))
True

point must be a Coordinate.

Pens and Drawing

BaseGlyph.getPen()

Return a type-pen object for adding outline data to the glyph.

>>> pen = glyph.getPen()
BaseGlyph.getPointPen()

Return a type-pointpen object for adding outline data to the glyph.

>>> pointPen = glyph.getPointPen()
BaseGlyph.draw(pen, contours=True, components=True)

Draw the glyph’s outline data (contours and components) to the given type-pen.

>>> glyph.draw(pen)

If contours is set to False, the glyph’s contours will not be drawn.

>>> glyph.draw(pen, contours=False)

If components is set to False, the glyph’s components will not be drawn.

>>> glyph.draw(pen, components=False)
BaseGlyph.drawPoints(pen, contours=True, components=True)

Draw the glyph’s outline data (contours and components) to the given type-pointpen.

>>> glyph.drawPoints(pointPen)

If contours is set to False, the glyph’s contours will not be drawn.

>>> glyph.drawPoints(pointPen, contours=False)

If components is set to False, the glyph’s components will not be drawn.

>>> glyph.drawPoints(pointPen, components=False)

Layers

Layer interaction in glyphs is very similar to the layer interaction in fonts. When you ask a glyph for a layer, you get a glyph layer in return. A glyph layer lets you do anything that you can do to a glyph. In fact a glyph layer is really just a glyph.

>>> bgdGlyph = glyph.newLayer('background')
>>> bgdGlyph.appendGlyph(glyph)
>>> bgdGlyph.appendGuideline((10, 10), 45)
BaseGlyph.layers

Immutable tuple of the glyph’s layers.

>>> glyphLayers = glyph.layers

This will return a tuple of all type-glyph-layer in the glyph.

BaseGlyph.getLayer(name)

Get the type-glyph-layer with name in this glyph.

>>> glyphLayer = glyph.getLayer("foreground")
BaseGlyph.newLayer(name)

Make a new layer with name in this glyph.

>>> glyphLayer = glyph.newLayer("background")

This will return the new type-glyph-layer. If the layer already exists in this glyph, it will be cleared.

BaseGlyph.removeLayer(layer)

Remove layer from this glyph.

>>> glyph.removeLayer("background")

Layer can be a type-glyph-layer or a String representing a layer name.

Global

BaseGlyph.clear(contours=True, components=True, anchors=True, guidelines=True, image=True)

Clear the glyph.

>>> glyph.clear()

This clears:

  • contours
  • components
  • anchors
  • guidelines
  • image

It’s possible to turn off the clearing of portions of the glyph with the listed arguments.

>>> glyph.clear(guidelines=False)
BaseGlyph.appendGlyph(other, offset=None)

Append the data from other to new objects in this glyph. This will append:

  • contours

  • components

  • anchors

  • guidelines

    >>> glyph.appendGlyph(otherGlyph)
    

offset indicates the x and y shift values that should be applied to the appended data. It must be a Coordinate value or None. If None is given, the offset will be (0, 0).

>>> glyph.appendGlyph(otherGlyph, (100, 0))

Contours

BaseGlyph.contours

An Immutable List of all contours in the glyph.

>>> contours = glyph.contours

The list will contain BaseContour objects.

BaseGlyph.__len__()

The number of contours in the glyph.

>>> len(glyph)
2
BaseGlyph.__iter__()

Iterate through all contours in the glyph.

>>> for contour in glyph:
...     contour.reverse()
BaseGlyph.__getitem__(index)

Get the contour located at index from the glyph.

>>> contour = glyph[0]

The returned value will be a BaseContour object.

BaseGlyph.appendContour(contour, offset=None)

Append a contour containing the same data as contour to this glyph.

>>> contour = glyph.appendContour(contour)

This will return a BaseContour object representing the new contour in the glyph. offset indicates the x and y shift values that should be applied to the appended data. It must be a Coordinate value or None. If None is given, the offset will be (0, 0).

>>> contour = glyph.appendContour(contour, (100, 0))
BaseGlyph.removeContour(contour)

Remove contour from the glyph.

>>> glyph.removeContour(contour)

contour may be a BaseContour or an type-int representing a contour index.

BaseGlyph.clearContours()

Clear all contours in the glyph.

>>> glyph.clearContours()
BaseGlyph.removeOverlap()

Perform a remove overlap operation on the contours.

>>> glyph.removeOverlap()

The behavior of this may vary across environments.

Components

BaseGlyph.components

An Immutable List of all components in the glyph.

>>> components = glyph.components

The list will contain BaseComponent objects.

BaseGlyph.appendComponent(baseGlyph=None, offset=None, scale=None, component=None)

Append a component to this glyph.

>>> component = glyph.appendComponent("A")

This will return a BaseComponent object representing the new component in the glyph. offset indicates the x and y shift values that should be applied to the appended component. It must be a Coordinate value or None. If None is given, the offset will be (0, 0).

>>> component = glyph.appendComponent("A", offset=(10, 20))

scale indicates the x and y scale values that should be applied to the appended component. It must be a type-scale value or None. If None is given, the scale will be (1.0, 1.0).

>>> component = glyph.appendComponent("A", scale=(1.0, 2.0))

component may be a BaseComponent object from which attribute values will be copied. If baseGlyph, offset or scale are specified as arguments, those values will be used instead of the values in the given component object.

BaseGlyph.removeComponent(component)

Remove component from the glyph.

>>> glyph.removeComponent(component)

component may be a BaseComponent or an type-int representing a component index.

BaseGlyph.clearComponents()

Clear all components in the glyph.

>>> glyph.clearComponents()
BaseGlyph.decompose()

Decompose all components in the glyph to contours.

>>> glyph.decompose()

Anchors

BaseGlyph.anchors

An Immutable List of all anchors in the glyph.

>>> anchors = glyph.anchors

The list will contain BaseAnchor objects.

BaseGlyph.appendAnchor(name=None, position=None, color=None, anchor=None)

Append an anchor to this glyph.

>>> anchor = glyph.appendAnchor("top", (10, 20))

This will return a BaseAnchor object representing the new anchor in the glyph. name indicated the name to be assigned to the anchor. It must be a String or None. position indicates the x and y location to be applied to the anchor. It must be a Coordinate value. color indicates the color to be applied to the anchor. It must be a Color or None.

>>> anchor = glyph.appendAnchor("top", (10, 20), color=(1, 0, 0, 1))

anchor may be a BaseAnchor object from which attribute values will be copied. If name, position or color are specified as arguments, those values will be used instead of the values in the given anchor object.

BaseGlyph.removeAnchor(anchor)

Remove anchor from the glyph.

>>> glyph.removeAnchor(anchor)

anchor may be an BaseAnchor or an type-int representing an anchor index.

BaseGlyph.clearAnchors()

Clear all anchors in the glyph.

>>> glyph.clearAnchors()

Guidelines

BaseGlyph.guidelines

An Immutable List of all guidelines in the glyph.

>>> guidelines = glyph.guidelines

The list will contain BaseGuideline objects.

BaseGlyph.appendGuideline(position=None, angle=None, name=None, color=None, guideline=None)

Append a guideline to this glyph.

>>> guideline = glyph.appendGuideline((100, 0), 90)

This will return a BaseGuideline object representing the new guideline in the glyph. position indicates the x and y location to be used as the center point of the anchor. It must be a Coordinate value. angle indicates the angle of the guideline, in degrees. This must be a Integer/Float between 0 and 360. name indicates an name to be assigned to the guideline. It must be a String or None.

>>> guideline = glyph.appendGuideline((100, 0), 90, name="left")

color indicates the color to be applied to the guideline. It must be a Color or None.

>>> guideline = glyph.appendGuideline((100, 0), 90, color=(1, 0, 0, 1))

guideline may be a BaseGuideline object from which attribute values will be copied. If position, angle, name or color are specified as arguments, those values will be used instead of the values in the given guideline object.

BaseGlyph.removeGuideline(guideline)

Remove guideline from the glyph.

>>> glyph.removeGuideline(guideline)

guideline may be a BaseGuideline or an type-int representing an guideline index.

BaseGlyph.clearGuidelines()

Clear all guidelines in the glyph.

>>> glyph.clearGuidelines()

Image

BaseGlyph.image

The BaseImage for the glyph.

BaseGlyph.addImage(path=None, data=None, scale=None, position=None, color=None)

Set the image in the glyph. This will return the assigned BaseImage. The image data can be defined via path to an image file:

>>> image = glyph.addImage(path="/path/to/my/image.png")

The image data can be defined with raw image data via data.

>>> image = glyph.addImage(data=someImageData)

If path and data are both provided, a FontPartsError will be raised. The supported image formats will vary across environments. Refer to BaseImage for complete details.

scale indicates the x and y scale values that should be applied to the image. It must be a type-scale value or None.

>>> image = glyph.addImage(path="/p/t/image.png", scale=(0.5, 1.0))

position indicates the x and y location of the lower left point of the image.

>>> image = glyph.addImage(path="/p/t/image.png", position=(10, 20))

color indicates the color to be applied to the image. It must be a Color or None.

>>> image = glyph.addImage(path="/p/t/image.png", color=(1, 0, 0, 0.5))
BaseGlyph.clearImage()

Remove the image from the glyph.

>>> glyph.clearImage()

Note

BaseGlyph.note

The glyph’s note.

>>> glyph.note
"P.B. said this looks 'awesome.'"
>>> glyph.note = "P.B. said this looks 'AWESOME.'"

The value may be a String or None.

BaseGlyph.markColor

The glyph’s mark color.

>>> glyph.markColor
(1, 0, 0, 0.5)
>>> glyph.markColor = None

The value may be a Color or None.

Sub-Objects

BaseGlyph.lib

The BaseLib for the glyph.

>>> lib = glyph.lib

Transformations

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

BaseGlyph.moveBy(value)

Move the object.

>>> obj.transformBy((10, 0))

value must be an iterable containing two Integer/Float values defining the x and y values to move the object by.

BaseGlyph.scaleBy(value, origin=None, width=False, height=False)

Scale the object.

>>> obj.transformBy(2.0)
>>> obj.transformBy((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).

width indicates if the glyph’s width should be scaled. height indicates if the glyph’s height should be scaled.

The origin must not be specified when scaling the width or height.

BaseGlyph.rotateBy(value, origin=None)

Rotate the object.

>>> obj.transformBy(45)
>>> obj.transformBy(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).

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

Interpolation

BaseGlyph.isCompatible(other)

Evaluate the interpolation compatibility of this glyph and other.

>>> compatible, report = self.isCompatible(otherGlyph)
>>> compatible
False

This will return a type-bool indicating if this glyph is compatible with other and a GlyphCompatibilityReporter containing a detailed report about compatibility errors.

BaseGlyph.interpolate(factor, minGlyph, maxGlyph, round=True, suppressError=True)

Interpolate the contents of this glyph at location factor in a linear interpolation between minGlyph and maxGlyph.

>>> glyph.interpolate(0.5, otherGlyph1, otherGlyph2)

factor may be a Integer/Float or a tuple containing two Integer/Float values representing x and y factors.

>>> glyph.interpolate((0.5, 1.0), otherGlyph1, otherGlyph2)

minGlyph must be a BaseGlyph and will be located at 0.0 in the interpolation range. maxGlyph must be a BaseGlyph and will be located at 1.0 in the interpolation range. If round is True, the contents of the glyph will be rounded to integers after the interpolation is performed.

>>> glyph.interpolate(0.5, otherGlyph1, otherGlyph2, round=True)

This method assumes that minGlyph and maxGlyph are completely compatible with each other for interpolation. If not, any errors encountered will raise a FontPartsError. If suppressError is True, no exception will be raised and errors will be silently ignored.

Normalization

BaseGlyph.round()

Round coordinates to the nearest integer.

>>> glyph.round()

This applies to the following:

  • width
  • height
  • contours
  • components
  • anchors
  • guidelines
BaseGlyph.autoUnicodes()

Use heuristics to set the Unicode values in the glyph.

>>> glyph.autoUnicodes()

Environments will define their own heuristics for automatically determining values.

Environment

BaseGlyph.naked()

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

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