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.

getDisplayOption()

Return the display options.

removeGlyph(name)

Remove the glyph with name from the layer. :

layer.removeGlyph("A")

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.

option
must be 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.

getRepresentation(name, **kwargs)

Get a representation by name.

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

performUndo()

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

prepareUndo(undoTitle='')

Save the current state of the object.

removeObserver(observer, notification)

Remove an observer object for a notification.

changed()

Notifiy the object has 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"

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

keys()

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.

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 15/05/2018