Layer¶
Note
This section needs to contain the following:
description of what this is
sub-object with basic usage
glyph interaction with basic usage
Overview¶
Copy¶
Copy the layer into a new layer that does not belong to a font. ::. |
Parents¶
The layer's parent |
Attributes¶
The name of the layer. ::. |
|
The layer's color. ::. |
Sub-Objects¶
The layer's |
|
|
The layer's |
Glyphs¶
An |
|
Get a list of all glyphs in the layer. ::. |
|
Iterate through the |
|
Test if the layer contains a glyph with name. ::. |
|
Get the |
|
Make a new glyph with name in the layer. ::. |
|
Insert glyph into the layer. ::. |
|
Remove the glyph with name from the layer. ::. |
Interpolation¶
Evaluate interpolation compatibility with other. ::. |
|
Interpolate all possible data in the layer. ::. |
Normalization¶
Round all approriate data to integers. ::. |
|
Use heuristics to set Unicode values in all glyphs. ::. |
Environment¶
Return the environment's native object that has been wrapped by this object. |
|
Tell the environment that something has changed in the object. |
Reference¶
Copy¶
Parents¶
Attributes¶
- BaseLayer.name¶
The name of the layer.
>>> layer.name "foreground" >>> layer.name = "top"
- BaseLayer.color¶
The layer’s color.
>>> layer.color None >>> layer.color = (1, 0, 0, 0.5)
Sub-Objects¶
Glyphs¶
- BaseLayer.__len__()¶
An
int
representing number of glyphs in the layer.>>> len(layer) 256
- BaseLayer.keys()¶
Get a list of all glyphs in the layer.
>>> layer.keys() ["B", "C", "A"]
The order of the glyphs is undefined.
- BaseLayer.__iter__()¶
Iterate through the
BaseGlyph
objects in the layer.>>> for glyph in layer: ... glyph.name "A" "B" "C"
- BaseLayer.__contains__(name)¶
Test if the layer contains a glyph with name.
>>> "A" in layer True
- BaseLayer.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.
- BaseLayer.insertGlyph(glyph, name=None)¶
Insert glyph into the layer.
>>> glyph = layer.insertGlyph(otherGlyph, name="A")
This method is deprecated.
BaseFont.__setitem__
instead.
- BaseLayer.removeGlyph(name)¶
Remove the glyph with name from the layer.
>>> layer.removeGlyph("A")
This method is deprecated.
BaseFont.__delitem__
instead.
Interpolation¶
- BaseLayer.isCompatible(other)[source]¶
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.
- BaseLayer.interpolate(factor, minLayer, maxLayer, round=True, suppressError=True)[source]¶
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.
Normalization¶
Environment¶
- BaseLayer.naked()¶
Return the environment’s native object that has been wrapped by this object.
>>> loweLevelObj = obj.naked()
- BaseLayer.changed(*args, **kwargs)¶
Tell the environment that something has changed in the object. The behavior of this method will vary from environment to environment.
>>> obj.changed()