class RLayer()

This class exists to provide common glyph interaction code to BaseFont and BaseLayer. It should not be directly subclassed.


Preferred curve type for the layer.


Return the display options.


Remove the glyph with name from the layer. :


renameGlyph(oldName, newName, renameComponents=True, renameGroups=True, renameKerning=True, renameGlyphOrder=True)

Rename a glyph. optionally you can rename this glyph in components, groups, kerning and glyphOrder.

font = CurrentFont()
layer = font.getLayer(font.defaultLayer)
layer.renameGlyph(oldName, newName, renameComponents=True, renameGroups=True, renameKerning=True, renameGlyphOrder=True)

setDisplayOption(option, value)

Set a display option.

must be Fill, Stroke, Points, Coordinates or all


Update all component references.

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.


Notifiy the object has changed.

Inherits from subclass: fontParts.nonelab.layer.RLayer



Deprecated ‘guides’: use ‘guidelines’



Use heuristics to set Unicode values in all glyphs. :

>>> layer.autoUnicodes()

Environments will define their own heuristics for automatically determining values.


Copy data from source into this layer. Refer to BaseLayer.copy for a list of values that will be copied.


Get a reversed map of component references in the font. { ‘A’ : [‘Aacute’, ‘Aring’] ‘acute’ : [‘Aacute’] ‘ring’ : [‘Aring’] etc. }


This is a backwards compatibility method.


Create a dictionary of unicode -> [glyphname, …] mappings. All glyphs are loaded. Note that one glyph can have multiple unicode values, and a unicode value can have multiple glyphs pointing to it.

interpolate(factor, minLayer, maxLayer, round=True, suppressError=True)

Interpolate all possible data in the layer. :

>>> layer.interpolate(0.5, otherLayer1, otherLayer2)
>>> layer.interpolate((0.5, 2.0), otherLayer1, otherLayer2, round=False)

The interpolation occurs on a 0 to 1.0 range where minLayer is located at 0 and maxLayer 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 integer/float or a tuple of two integer/float. 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(otherLayer)
>>> compat
>>> report
[Fatal] The glyphs do not contain the same number of contours.

This will return a bool indicating if the layer is compatible for interpolation with other and a string of compatibility notes.


Round all approriate data to integers. :

>>> layer.round()

This is the equivalent of calling the round method on:

  • all glyphs in the layer


Test if the layer contains a glyph with name. :

>>> "A" in layer

insertGlyph(glyph, name=None)

Insert glyph into the layer. :

>>> glyph = layer.insertGlyph(otherGlyph, name="A")

This does not necessarily insert the glyph directly. In many cases, the environment will create a new glyph and copy the data from glyph to the new glyph. name indicates the name that should be assigned to the glyph after insertion. If name is not given, the glyph’s original name must be used. If the glyph does not have a name, an error must be raised. The data that will be inserted from glyph is the same data as documented in BaseGlyph.copy.


Get a list of all glyphs in the layer. :

>>> layer.keys()
["B", "C", "A"]

The order of the glyphs is undefined.

newGlyph(name, clear=True)

Make a new glyph with name in the layer. :

>>> glyph = layer.newGlyph("A")

The newly created BaseGlyph will be returned.

If the glyph exists in the layer and clear is set to False, the existing glyph will be returned, otherwise the default behavior is to clear the exisiting glyph.

addGuide(position, angle, name=None)

Deprecated: use appendGuideline(position, angle)


Deprecated: use clearGuidelines()


Deprecated: use removeGuideline(guideline)

Last edited on 14/03/2018