Layer

Must Override

BaseLayer._getItem(name: str, **kwargs: Any) BaseGlyph

Get the specified glyph from the native layer.

This is the environment implementation of BaseLayer.__getitem__ and BaseFont.__getitem__.

Parameters:
  • name – The name representing the glyph to get. The value will have been normalized with normalizers.normalizeGlyphName.

  • **kwargs – Additional keyword arguments.

Returns:

an instance of a BaseGlyph subclass with the specified name.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._get_color() tuple[float, float, float, float] | None[source]

Get the color of the layer.

This is the environment implementation of the BaseLayer.color property getter.

Returns:

The Color assigned to the layer, or None to indicate that the layer does not have an assigned color. The value will be normalized with normalizers.normalizeColor.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._get_lib() BaseLib[source]

Get the native layer’s BaseLib object.

This is the environment implementation of the BaseLayer.lib property getter.

Returns:

An instance of a BaseLib subclass.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

BaseLayer._get_name() str | None[source]

Get the name of the native layer.

This is the environment implementation of the BaseLayer.name

property getter.

:return A str defining the name of the current layer

or None to indicate that the layer is the default. The value will be normalized with normalizers.normalizeLayerName.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._keys(**kwargs: Any) tuple[str, ...]

Get the names of all glyphs in the native layer.

This is the environment implementation of BaseLayer.keys and BaseFont.keys.

Parameters:

**kwargs – Additional keyword arguments.

Returns:

An unordered tuple of glyph names representing the glyphs in the current or default BaseLayer instance.

Raises:

NotImplementedError

If the method has not been

overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._newGlyph(name: str, **kwargs: Any) BaseGlyph

Create a new glyph in the native layer.

This is the environment implementation of BaseLayer.newGlyph and BaseFont.newGlyph.

Parameters:
  • name – The name of the glyph to create. The value will have been normalized with normalizers.normalizeGlyphName and tested to make sure that it is unique to the layer.

  • **kwargs – Additional keyword arguments.

Returns:

An instance of a BaseGlyph subclass.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._removeGlyph(name: str, **kwargs: Any) None

Remove the specified glyph from the native layer.

This is the environment implementation of BaseLayer.removeGlyph and BaseFont.removeGlyph.

Parameters:
  • name – The name of the glyph to remove. The value will have been normalized with normalizers.normalizeGlyphName.

  • **kwargs – Additional keyword arguments.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._set_color(value: list[int | float] | tuple[float, float, float, float] | None, **kwargs: Any) None[source]

Get or set the color of the layer.

This is the environment implementation of the BaseLayer.color property setter.

Parameters:
  • value – A Color or None defining the color to assign to the layer. The value will have been normalized with normalizers.normalizeColor.

  • **kwargs – Additional keyword arguments.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

BaseLayer._set_name(value: str, **kwargs: Any) None[source]

Set the name of the native layer.

This is the environment implementation of the BaseLayer.name

property setter.

Parameters:
  • value – The name to assign to the layer. The value must be unique to the font and will have been normalized with normalizers.normalizeLayerName

  • **kwargs – Additional keyword arguments.

Raises:

NotImplementedError – If the method has not been overridden by a subclass.

Important

Subclasses must override this method.

May Override

BaseLayer._autoUnicodes() None[source]

Use heuristics to set Unicode values in all native font glyphs.

This is the environment implementation of BaseLayer.autoUnicodes.

Note

Subclasses may override this method.

BaseLayer._contains(name: str, **kwargs: Any) bool

Test if the native layer contains the specified glyph.

This is the environment implementation of BaseLayer.__contains__ and BaseFont.__contains__.

Parameters:
  • name – The name of the glyph to check. The value will have been normalized with normalizers.normalizeGlyphName.

  • **kwargs – Additional keyword arguments.

Returns:

True if the glyph exists in the layer, False otherwise.

Note

Subclasses may override this method.

BaseLayer._init(*args: Any, **kwargs: Any) None

Initialize the native object.

This is the environment implementation of BaseObject.__init__.

Parameters:
  • *args – Any positional arguments.

  • **kwargs – Any keyword arguments.

Note

Subclasses may override this method.

BaseLayer._insertGlyph(glyph: BaseGlyph, name: str, **kwargs: Any) BaseGlyph

Insert a specified glyph into the native layer.

This is the environment implementation of BaseLayer.__setitem__ and BaseFont.__setitem__.

An environment must not insert glyph directly, but rather copy it’s data to a new layer.

Parameters:
  • glyph – A glyph object with the attributes necessary for copying as defined in BaseGlyph.copy

  • name – The name to assign to the new glyph after insertion. The value will have been normalized with normalizers.normalizeGlyphName and tested to make sure that it is unique to the layer.

  • **kwargs – Additional keyword arguments.

Returns:

The newly inserted BaseLayer subclass instance.

Note

Subclasses may override this method.

BaseLayer._interpolate(factor: list[int | float] | tuple[float, float], minLayer: BaseLayer, maxLayer: BaseLayer, round: bool, suppressError: bool) None[source]

Interpolate all possible data in the native layer.

This is the environment implementation of BaseLayer.interpolate.

Parameters:
  • factor – The interpolation value as a single int or float or a tuple of two int or float values representing the factors (x, y).

  • minLayer – The BaseLayer subclass instance corresponding to the 0.0 position in the interpolation.

  • maxLayer – The BaseLayer subclass instance corresponding to the 1.0 position in the interpolation.

  • round – A bool indicating whether the result should be rounded to integers.

  • suppressError – A bool indicating whether to ignore incompatible data or raise an error when such incompatibilities are found.

Raises:

FontPartsError – If suppressError=False and the interpolation data is incompatible.

Note

Subclasses may override this method.

BaseLayer._isCompatible(other: BaseLayer, reporter: LayerCompatibilityReporter) None[source]

Evaluate interpolation compatibility with another native layer.

This is the environment implementation of BaseFont.isCompatible.

Parameters:
  • other – The other BaseLayer subclass instance to check compatibility with.

  • reporter – An object used to report compatibility issues.

Note

Subclasses may override this method.

BaseLayer._iter(**kwargs: Any) Iterator[BaseGlyph]

Iterate through the glyphs in the native layer.

This is the environment implementation of BaseLayer.__iter__ and BaseFont.__iter__.

Returns:

An iterator over instances of a BaseGlyph subclass.

Note

Subclasses may override this method.

BaseLayer._len(**kwargs: Any) int

Return the number of glyphs in the native layer.

This is the environment implementation of BaseLayer.__len__ and BaseFont.__len__

Parameters:

**kwargs – Additional keyword arguments.

Returns:

The number of BaseGlyph subclass instances in the layer as an int.

Note

Subclasses may override this method.

BaseLayer._round() None[source]

Round all approriate native layer data to integers.

This is the environment implementation of BaseLayer.round.

Note

Subclasses may override this method.