RLayer
class RLayer()
This class exists to provide common glyph interaction code to BaseFont and BaseLayer. It should not be directly subclassed.
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.
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
orall
addObserver(observer, methodName, notification)
Add an observer object. that will receive notification for the given methodName.
destroyRepresentation(name, **kwargs)
Destroy the stored representation for name and optionally kwargs.
getRepresentation(name, **kwargs)
Get a representation by name.
Optionally arguments could be provided if the representation factory requires arguments.
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()
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
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
insertGlyph(glyph, name=None)
Insert glyph into the layer.
glyph = layer.insertGlyph(otherGlyph, name="A")
This method is deprecated. BaseFont.__setitem__
instead.