RLayer

class RLayer()

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

preferredSegmentType

Preferred curve type for the layer.

copyGlyphsToPasteboard(glyphNames)

Copy a list of glyph names to the pasteboard.

getDisplayOption()

Return the display options as a dictionary.

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.

removeGlyph(name)

Remove the glyph with name from the layer.

layer.removeGlyph("A")

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

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

Glyph names are not renamed in font.features.text

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

setDisplayOption(options, value=None)

Set a display option.

options
must be a dictionary with the following keys: Fill, Stroke, Points, Coordinates or all

updateComponentReferences(baseGlyphName)

Update all component references.

addObserver(observer, methodName, notification)

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

asDefcon()

Return the defcon object.

asFontParts()

Return a fontParts object

getRepresentation(name, **kwargs)

Get a representation by name.

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

holdChanges()

Capture changes and bundle them in a single change in a with statement.

performUndo()

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

prepareUndo(undoTitle='')

Save the current state of the object.

releaseHeldChanges()

removeObserver(observer, notification)

Remove an observer object for a notification.

undo(undoTitle='')

Capture the current state of the object and create a undo item in a with statement.

Optionally an undoTitle can be provided.

changed()

Tell the environment that something has changed in the object. The behavior of this method will vary from environment to environment.

obj.changed()
Inherits from subclass: fontParts.fontshell.layer.RLayer

color

The layer’s color.

>>> layer.color
None
>>> layer.color = (1, 0, 0, 0.5)

copyAttributes

font

The layer’s parent BaseFont.

>>> font = layer.font

lib

The layer’s BaseLib object.

>>> layer.lib["org.robofab.hello"]
"world"

name

The name of the layer.

>>> layer.name
"foreground"
>>> layer.name = "top"

tempLib

The layer’s BaseLib object.

>>> layer.tempLib["org.robofab.hello"]
"world"

selectedGlyphNames

A list of names of glyphs selected in the layer.

Getting selected glyph names:

>>> for name in layer.selectedGlyphNames:
...     print(name)

Setting selected glyph names:

>>> layer.selectedGlyphNames = ["A", "B", "C"]

selectedGlyphs

A list of glyphs selected in the layer.

Getting selected glyph objects:

>>> for glyph in layer.selectedGlyphs:
...     glyph.markColor = (1, 0, 0, 0.5)

Setting selected glyph objects:

>>> layer.selectedGlyphs = someGlyphs

selected

The object’s selection state.

>>> obj.selected
False
>>> obj.selected = True

guides

Deprecated ‘guides’: use ‘guidelines’

naked()

autoUnicodes()

Use heuristics to set Unicode values in all glyphs.

>>> layer.autoUnicodes()

Environments will define their own heuristics for automatically determining values.

copyData(source)

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

getCharacterMapping()

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

getReverseComponentMapping()

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.

isCompatible(other)

Evaluate interpolation compatibility with other.

>>> compat, report = self.isCompatible(otherLayer)
>>> compat
False
>>> report
A
-
[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()

Round all approriate data to integers.

>>> layer.round()

This is the equivalent of calling the round method on:

  • all glyphs in the layer

__contains__(name)

Test if the layer contains a glyph with name.

>>> "A" in layer
True

insertGlyph(glyph, name=None)

Insert glyph into the layer.

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

This method is deprecated. BaseFont.__setitem__ instead.

keys()

Get a list of all glyphs in the layer.

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

The order of the glyphs is undefined.

getParent()

setChanged()

update()

setParent(parent)

addGuide(position, angle, name=None)

Deprecated: use appendGuideline(position, angle)

clearGuides()

Deprecated: use clearGuidelines()

removeGuide(guideline)

Deprecated: use removeGuideline(guideline)

Last edited on 18/03/2024