class RGlyph()

Glyph object.


Angled left margin of the glyph, used when italic slant is set


Angled right margin of the glyph, used when italic slant is set




Deprecated: use Glyph.layer.name


Preferred curve type for the glyph.


Selection of glyph in font window


Return a list of selected points.


Center the glyph.


Notifiy the object has changed.

copyLayerToLayer(layer1Name, layer2Name)

Copy layer from layer1Name to layer2Name

copyToLayer(layerName, clear=True)

Copies the glyph to the ‘layerName’, optional clear will clear the destination glyph.


Deselect all objects for this glyph.


Add extreme points in the glyph. Optionally a round value can be provided.

flipLayers(layer1Name, layer2Name)

Flip layers from layer1Name and layer2Name


Deprecated: use Glyph.font[glyphName]


Return a glyph from an other layer with the same name.


Return the parent object.


Return a PointPen object for modifying the glyph.

>>> pointPen = glyph.getPointPen()

getRayLeftMargin(position, italicAngle=None)

Get the left margin at a given position.

Optionally an italicAngle can be provided.

getRayRightMargin(position, italicAngle=None)

Get the right margin at a given position.

Optionally an italicAngle can be provided.


Set the glyph has changed to True.


Return if the glyph has overlaps. If an overlap is found a list of intersection points will be returned.


Return a bool indicting if the glyph is empty. An empty glyph does not contain any contours, segments, anchors, images or guidelines.

rasterize(*args, **kwrags)

Deprecated: seriously???


Perform a remove overlap in the glyph. Optionally a round value can be provided.

removeSelection(removePoints=True, removeComponents=True, removeAnchors=True, removeImages=True)

Remove the selection from the glyph.

Optionally parts can be toggled on or off: removePoints, removeComponents, removeAnchors, removeImages


Set the parent object for the glyph.

setRayLeftMargin(position, value, italicAngle=None)

Set the left margin at a given position.

Optionally an italicAngle can be provided.

setRayRightMargin(position, value, italicAngle=None)

Set the right margin at a given position.

Optionally an italicAngle can be provided.


Swap the glyph to the layer with layerName.


Update the selection.

addObserver(observer, methodName, notification)

Add an observer object. that will receive notification for the given methodName.

getRepresentation(name, **kwargs)

Get a representation by name.

Optionally arguments could be provided if the representation factory requires arguments.


Create a undo item and add it the the undo manager.


Save the current state of the object.

removeObserver(observer, notification)

Remove an observer object for a notification.

Inherits from subclass: fontParts.nonelab.glyph.RGlyph



Deprecated Glyph.box


Deprecated Mark color


Deprecated ‘guides’: use ‘guidelines’


Return a Pen object for modifying the glyph.

>>> pen = glyph.getPen()


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

Set the image in the glyph.

>>> image = glyph.addImage(path="/path/to/my/image.png", color=(1, 0, 0, 0.5))

path is a path to an image file. data is the raw image data. scale (x, y) is the scale of the image (optional). position (x, y) is the position of the image (optional). color is the color of the image (optional).

The image data format is not defined. That will be environment specific and is handled in the Image object.

appendAnchor(name, position, color=None)

Append a new anchor to the glyph.

>>> anchor = glyph.appendAnchor("top", (50, 500))
>>> anchor = glyph.appendAnchor("top", (50, 500), (1, 0, 0, 0.5))

name indicates the name that should be assigned to the anchor. position is an (x, y) tuple defining the position for the anchor. color is None or a color tuple.

appendComponent(baseGlyph, offset=None, scale=None)

Append a new component to the glyph.

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

baseGlyph indicates the glyph that the component will reference. offset indictaes the offset that should be defined in the component. The default is (0, 0). scale indicates the scale that should be defined in the component. The default is (1.0, 1.0).

appendContour(contour, offset=None)

A copy of the given contour to the glyph.

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

offset indicates the distance that the contour should be offset when added to the glyph. The default is (0, 0).

appendGlyph(other, offset=None)

Append copies of the contours, components, anchors and guidelines from other.

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

offset indicates the offset that should be applied to the appended data. The default is (0, 0).

appendGuideline(position, angle, name=None, color=None)

Append a new guideline to the glyph.

>>> guideline = glyph.appendGuideline((50, 0), 90)
>>> guideline = glyph.appendGuideline((0, 540), 0, name="overshoot", color=(0, 0, 0, 0.2))

position (x, y) indicates the position of the guideline. angle indicates the angle of the guideline. name indicates the name for the guideline. color indicates the color for the guideline.


Sort the contours based on their centers.

>>> glyph.autoContourOrder()


Use heuristics to set the Unicode values in the glyph.

>>> glyph.autoUnicodes()

Environments will define their own heuristics for automatically determining values.

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 selectively turn off the clearing of portions of the glyph with the arguments.


Clear all anchors.

>>> glyph.clearAnchors()


Clear all components.

>>> glyph.clearComponents()


Clear all contours.

>>> glyph.clearContours()


Clear all guidelines.

>>> glyph.clearGuidelines()


Remove the image from the glyph.

>>> glyph.clearImage()


Subclasses may override this method. If so, they should call the super.


Correct the direction of the contours in the glyph.

>>> glyph.correctDirection()


Decompose all components.

>>> glyph.decompose()

draw(pen, contours=True, components=True)

Draw the glyph with the given Pen.

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

drawPoints(pen, contours=True, components=True)

Draw the glyph with the given PointPen.

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


Replaces the glyph with the contents of a MathGlyph.

>>> glyph = glyph.fromMathGlyph(mg)

mathGlyph is the mathGlyph to put into the current glyph.

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

Interpolate all possible data in the glyph.

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

The interpolation occurs on a 0 to 1.0 range where minGlyph is located at 0 and maxGlyph is located at 1.0.

factor is the interpolation value. It may be less than 0 and greater than 1.0. It may be a number (integer, float) or a tuple of two numbers. If it is a tuple, the first number indicates the x factor and the second number indicates the y factor.

round indicates if the result should be rounded to integers.

suppressError indicates if incompatible data should be ignored or if an error should be raised when such incompatibilities are found.


Evaluate interpolation compatibility with other.

>>> compat, report = self.isCompatible(otherFont)
>>> compat
>>> report
[Fatal] The glyphs do not contain the same number of contours.

Returns a boolean indicating if the glyph is compatible for interpolation with other and a string of compatibility notes.

newLayer(name, **kwargs)

Make a new layer with name in this glyph.

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

This is the equivalent of using the newGlyph method on a named layer. If the glyph already exists in the layer it will be cleared. Return the new glyph layer.


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

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

point must be an (x, y) tuple.


Reads glif data into a glyph object.

XML formatting of glif data must follow the Unified Font Object specification.


Remove anchor from the glyph.

>>> glyph.removeAnchor(anchor)
>>> glyph.removeAnchor(2)

anchor can be a anchor object or an integer representing the anchor index.


Remove component from the glyph.

>>> glyph.removeComponent(component)
>>> glyph.removeComponent(1)

component can be a component object or an integer representing the component index.


Remove the contour from the glyph.

>>> glyph.removeContour(contour)
>>> glyph.removeContour(0)

Contour may be a contour object or a contour index.


Remove guideline from the glyph.

>>> glyph.removeGuideline(guideline)
>>> glyph.removeGuideline(2)

guideline can be a guideline object or an integer representing the guideline index.

removeLayer(layer, **kwargs)

Remove the layer from the glyph (not the font).

>>> glyph.removeLayer("background")

Layer can be a glyph layer or a layer name.


Round coordinates.

>>> glyph.round()

This applies to the following:

  • width
  • height
  • contours
  • components
  • anchors
  • guidelines


Returns the glyph as a MathGlyph.

>>> mg = glyph.toMathGlyph()


Writes glif data to an UFO XML string.

XML formatting must follow the glyph formating specified by the Unified Font Object specification, defaulting to glyph format version 2.


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.

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

scaleBy(value, origin=None)

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

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

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. origin defines the point at with the transformation should originate. It must be a coordinate or None. The default is (0, 0).





move(*args, **kwargs)

rotate(*args, **kwargs)

scale(*args, **kwargs)

skew(*args, **kwargs)

transform(*args, **kwargs)

translate(*args, **kwargs)



addGuide(position, angle, name=None)

Deprecated: use appendGuideline(position, angle)


Deprecated: use clearGuidelines()


Deprecated: use removeGuideline(guideline)

Last edited on 14/03/2018