Font¶
Must Override¶
- BaseFont._close(**kwargs: Any) None[source]¶
Close the native font.
This is the environment implementation of
BaseFont.close.- Parameters:
**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._generate(format: str, path: str | None, environmentOptions: dict, **kwargs: object) None[source]¶
Generate the native font in another format.
This is the environment implementation of
BaseFont.generate. Refer to theBaseFont.generateFormatToExtensiondocumentation for the standard format identifiers.- Parameters:
format – The output format identifier. If the value given for format is not supported by the environment, the environment must raise
FontPartsError.path – The location where the generated file should be saved. The value will have been normalized with
normalizers.normalizeFilePath.environmentOptions – A dictionary of environment-specific options. These options are validated with
BaseFont._isValidGenerateEnvironmentOptionand the given values. These values are not passed through any normalization functions.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._getGuideline(index: int, **kwargs: Any) BaseGuideline[source]¶
Return the guideline at the given index.
- Parameters:
index – The index of the guideline.
**kwargs – Additional keyword arguments.
- Returns:
An instance of a
BaseGuidelinesubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_defaultLayer() BaseLayer[source]¶
Get the native font’s default layer.
This is the environment implementation of the
BaseFont.defaultLayerproperty getter.- Returns:
The default
BaseLayersubclass instance. The value will be normalized withnormalizers.normalizeLayer.
Important
Subclasses must override this method.
- BaseFont._get_defaultLayerName() str[source]¶
Get the name of the native font’s default layer.
This is the environment implementation of
BaseFont.defaultLayerNameproperty getter. :return: The name of the current default :class`BaseLayer`subclass instance. The value will be normalized with
normalizers.normalizeDefaultLayerName.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_features() BaseFeatures[source]¶
Get the native font’s features object.
This is the environment implementation of
BaseFont.features.- Returns:
An instance of a
BaseFeaturessubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_glyphOrder() tuple[str, ...][source]¶
Get the order of the glyphs in the native font.
This is the environment implementation of the
BaseFont.glyphrOrderproperty getter.- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
A
tupleof layer names in their defined order. The value will be normalized withnormalizers.normalizeGlyphOrder.- Raises:
NotImplementedError – If the method has not beenoverridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_groups() BaseGroups[source]¶
Get the native font’s groups object.
This is the environment implementation of
BaseFont.groups.- Returns:
an instance of a
BaseGroupssubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_info() BaseInfo[source]¶
Get the native font’s info object.
This is the environment implementation of
BaseFont.info.- Returns:
An instance of a
BaseInfosubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_kerning() BaseKerning[source]¶
Get the native font’s kerning object.
This is the environment implementation of
BaseFont.kerning.- Returns:
An instance of a
BaseKerningsubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_layerOrder(**kwargs: Any) tuple[str, ...][source]¶
Get the order of the layers in the native font.
This is the environment implementation of the
BaseFont.layerOrderproperty getter.- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
A
listof layer names in their defined order. The value will be normalized withnormalizers.normalizeLayerOrder.- Raises:
NotImplementedError – If the method has not beenoverridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_layers(**kwargs: Any) tuple[BaseLayer, ...][source]¶
Get the native font’s layer objects.
This is the environment implementation of
BaseFont.layers.- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
A
tuplecontaining instances of theBaseLayersubclass. The items should be in the order defined byBaseFont.layerOrder.
Important
Subclasses must override this method.
- BaseFont._get_lib() BaseLib[source]¶
Get the native font’s lib object.
This is the environment implementation of
BaseFont.lib.- Returns:
An instance of a
BaseLibsubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_tempLib() BaseLib[source]¶
Get the native font’s temporary lib object.
This is the environment implementation of
BaseFont.tempLib.- Returns:
A temporary instance of a
BaseLibsubclass.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_path(**kwargs: Any) str | None[source]¶
Get the path to the native font file.
This method is the environment implementation of
BaseFont.path.- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
A
strdefining the location of the file orNoneto indicate that the font does not have a file representation. If the value is notNoneit will be normalized withnormalizers.normalizeFilePath.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._get_selected() bool¶
Get or the object’s selection state.
This is the environment implementation of
BaseObject.selectedproperty getter.- Returns:
Trueif the object is selected,Falseotherwise. The value will be normalized withnormalizers.normalizeBoolean.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method if they implement object selection.
- BaseFont._init(pathOrObject: str | BaseFont | None, showInterface: bool, **kwargs: Any) None[source]¶
Initialize the native font object.
This method is the environment implementation of
BaseFont.__init__. It will wrap a native font object based on the value type of the pathOrObject parameter.- Parameters:
pathOrObject –
The source for initializing the font. Options are:
Type
Description
Create a new font. Open the font file located at the given location. Wrap the given object.
showInterface – Whether to display the graphical interface.
**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._lenGuidelines(**kwargs: Any) int[source]¶
Return the number of font-level guidelines in the native font.
- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
An
intindicating the number of font-levelBaseGuidelinesubclass instances in the font.
Important
Subclasses must override this method.
- BaseFont._newLayer(name: str, color: RGBALike | None, **kwargs: Any) BaseLayer[source]¶
Create a new layer in the native font.
This is the environment implementation of
BaseFont.newLayer.- Parameters:
name – The name of the new layer to create. The value must be unique to the font and will have been normalized with
normalizers.normalizeLayerName.color – The color value to assign to the new layer. If the value is not
None, it will have been normalized withnormalizers.normalizeColor.**kwargs – Additional keyword arguments.
- Returns:
A newly created
BaseLayersubclass instance.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._removeGuideline(index: int, **kwargs: Any) None[source]¶
Remove the guideline at the specified index.
This is the environment implementation of
BaseFont.removeGuideline.- Parameters:
index – The index of the guideline to remove.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._removeLayer(name: str, **kwargs: Any) None[source]¶
Remove the specified layer from the native font.
This is the environment implementation of
BaseFont.removeLayer.- Parameters:
name – The name of the layer to remove. The value 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.
- BaseFont._save(path: str | None, showProgress: bool, formatVersion: int | None, fileStructure: str | None, **kwargs: Any) None[source]¶
Save the native font to the specified path.
This is the environment implementation of
BaseFont.save.- Parameters:
path – The file path to save the data to. If not
None, the value will have been normalized withnormalizers.normalizeFilePath.showProgress – Whether to display a progress bar during the operation. Environments are not required to display a progress bar even if value is
True.formatVersion – The file format version to write the data into. If not
None, the value will have been normalized withnormalizers.normalizeFileFormatVersion.fileStructure – The file structure to use.
**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._set_defaultLayer(value: BaseLayer) None[source]¶
Set the native font’s default layer.
This is the environment implementation of the
BaseFont.defaultLayerproperty setter.- Parameters:
value – The desired default
BaseLayersubclass instance. The value will have been normalized withnormalizers.normalizeLayer.
Important
Subclasses must override this method.
- BaseFont._set_defaultLayerName(value: str, **kwargs: Any) None[source]¶
Set the name of the native font’s default layer.
This is the environment implementation of
BaseFont.defaultLayerNameproperty setter. :param value: The name of the desired default :class`BaseLayer`subclass instance. The name will have been normalized with
normalizers.normalizeDefaultLayerName.- Parameters:
**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._set_glyphOrder(value: list[str] | tuple[str, ...]) None[source]¶
Set the order of the glyphs in the native font.
This is the environment implementation of the
BaseFont.glyphrOrderproperty setter.- Parameters:
value – A
listof glyph names reflecting the desired order of the font’sBaseGlyphobjects. The value will have been normalized withnormalizers.normalizeGlyphOrder.**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._set_layerOrder(value: list[str] | tuple[str, ...], **kwargs: Any) None[source]¶
Set the order of the layers in the native font.
This is the environment implementation of the
BaseFont.layerOrderproperty setter.- Parameters:
value – A
listortupleof layer names reflecting the desired order of the font’sBaseLayerobjects. The value will have been normalized withnormalizers.normalizeLayerOrder.**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method.
- BaseFont._set_selected(value: bool) None¶
Set the object’s selection state.
This is the environment implementation of the
SelectionMixin.selectedproperty setter.- Parameters:
value – Whether the object is selected. The value will have been normalized with
normalizers.normalizeBoolean.- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Important
Subclasses must override this method if they implement object selection.
May Override¶
- BaseFont._appendGuideline(position: CoordinateLike, angle: float | None, name: str | None, color: RGBALike | None, **kwargs: Any) BaseGuideline[source]¶
Append a new guideline to the native font.
This is the environment implementation of
BaseFont.appendGuideline.- Parameters:
position – The position for the guideline as a Coordinate.
angle – The angle for the guideline as a
float.name – The name for the guideline as a
str.color – The color for the guideline as a Color.
**kwargs – Additional keyword arguments.
- Returns:
The newly appended instance of the
BaseGuidelinesubclass.
Note
Subclasses may override this method.
- BaseFont._autoUnicodes() None[source]¶
Use heuristics to set Unicode values in all native font glyphs.
This is the environment implementation of
BaseFont.autoUnicodes.Note
Subclasses may override this method.
- BaseFont._clearGuidelines() None[source]¶
Clear all guidelines in the native font.
This is the environment implementation of
BaseFont.clearGuidelines.Note
Subclasses may override this method.
- BaseFont._contains(name: str, **kwargs: Any) bool¶
Test if the native layer contains the specified glyph.
This is the environment implementation of
BaseLayer.__contains__andBaseFont.__contains__.- Parameters:
name – The name of the glyph to check. The value will have been normalized with
normalizers.normalizeGlyphName.**kwargs – Additional keyword arguments.
- Returns:
Note
Subclasses may override this method.
- BaseFont._duplicateLayer(layerName: str, newLayerName: str) BaseLayer[source]¶
Duplicate the specified layer in the native font.
This is the environment implementation of
BaseFont.duplicateLayer.- Parameters:
layerName – The name of the layer to duplicate. The value will have been normalized with
normalizers.normalizeLayerNameand tested to make sure that it already exists in the font.newLayerName – The new name to assign to the duplicated layer. The value will have been normalized with
normalizers.normalizeLayerNameand tested to make sure that it does not already exist in the font.
- Returns:
The newly duplicated
BaseLayersubclass instance.
Note
Subclasses may override this method.
- BaseFont._getCharacterMapping() dict[int, tuple[str, ...]][source]¶
Get the native font’s character mapping.
This is the environment implementation of
BaseFont.getCharacterMapping.- Returns:
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Note
Subclasses may override this method.
- BaseFont._getFlatKerning() dict[tuple[str, str], tuple[str, str]][source]¶
Get the native font’s kerning as a flat dictionary.
This is the environment implementation of
BaseFont.getFlatKerning.- Returns:
A
dictof the font’sBaseKerningsubclass keys mapped to their respective values.
Note
Subclasses may override this method.
- BaseFont._getItem(name: str, **kwargs: Any) BaseGlyph[source]¶
Get the specified glyph from the native default layer.
This is the environment implementation of
BaseFont.__getitem__.- Parameters:
name – The name of the glyph to retrieve from the default layer. The value will have been normalized with
normalizers.normalizeGlyphName.**kwargs – Additional keyword arguments.
- Returns:
- the specified instance of a
BaseGlyph subclass.
Note
Subclasses may override this method.
- the specified instance of a
- BaseFont._getLayer(name: str, **kwargs: Any) BaseLayer[source]¶
Get the named layer from the native font.
This is the environment implementation of
BaseFont.getLayer.- Parameters:
name – The name of the
BaseLayersubclass instance to retrieve.**kwargs – Additional keyword arguments.
- Returns:
The specified
BaseLayersubclass instance. The value will have been normalized withnormalizers.normalizeLayerNameand verified as an existing layer.- Raises:
ValueError – If no layer with the given name exists in the font.
Note
Subclasses may override this method.
- BaseFont._getReverseComponentMapping() dict[str, tuple[str, ...]][source]¶
Get a reversed map of all component references in the font.
This is the environment implementation of
BaseFont.getReverseComponentMapping.Note
Subclasses may override this method.
- BaseFont._get_selectedGlyphs() tuple[BaseGlyph, ...]¶
Get the selected glyphs in the native layer.
This is the environment implementation of the
BaseLayer.selectedGlyphsproperty getter.- Returns:
An unordered
tupleof selectedBaseGlyphsubclass instances. Each value item will be normalized withnormalizers.normalizeGlyph.
Note
Subclasses may override this method.
- BaseFont._get_selectedGlyphNames() tuple[str, ...]¶
Get the selected glyph names in the layer.
This is the environment implementation of the
BaseLayer.selectedGlyphNamesproperty getter.- Returns:
An unordered
tupleof glyph names representing the currently selectedBaseGlyphsubclass instances. Each value item will be normalized withnormalizers.normalizeGlyphName.
Note
Subclasses may override this method.
- BaseFont._get_selectedGuidelines() tuple[BaseGuideline, ...][source]¶
Get the selected guidelines in the native font.
This is the environment implementation of the
BaseFont.selectedGuidelinesproperty getter.- Returns:
A
tupleof currently selectedBaseGuidelineinstances. Each value item will be normalized withnormalizers.normalizeGuideline.
Note
Subclasses may override this method.
- BaseFont._get_selectedLayers() tuple[BaseLayer, ...][source]¶
Get the selected glyph layers in the native default font layer.
This is the environment implementation of the
BaseFont.selectedLayersproperty getter.- Returns:
A
tupleof currently selectedBaseLayerinstances. Each value item will be normalized withnormalizers.normalizeLayer.
Note
Subclasses may override this method.
- BaseFont._get_selectedLayerNames() tuple[str, ...][source]¶
Get the selected glyph layer names in the native font layer.
This is the environment implementation of the
BaseFont.selectedLayerNamesproperty getter.- Returns:
A
tupleof layer names representing the currently selectedBaseLayerinstances. Each value item will be normalized withnormalizers.normalizeLayerName.
Note
Subclasses may override this method.
- BaseFont._get_guidelines() tuple[BaseGuideline, ...][source]¶
Get the native font-level guideline objects.
This is the environment implementation of
BaseFont.guidelines.- Returns:
A
tuplecontaining instances of theBaseGuidelinesubclass.
Note
Subclasses may override this method.
- BaseFont._insertGlyph(glyph: BaseGlyph, name: str, **kwargs: Any) BaseGlyph¶
Insert a specified glyph into the native layer.
This is the environment implementation of
BaseLayer.__setitem__andBaseFont.__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.copyname – The name to assign to the new glyph after insertion. The value will have been normalized with
normalizers.normalizeGlyphNameand tested to make sure that it is unique to the layer.**kwargs – Additional keyword arguments.
- Returns:
The newly inserted
BaseLayersubclass instance.
Note
Subclasses may override this method.
- BaseFont._insertLayer(layer: BaseLayer, name: str, **kwargs: Any) BaseLayer[source]¶
Insert a specified layer into the native font.
This is the environment implementation of
BaseFont.insertLayer.An environment must not insert layer directly, but rather copy it’s data to a new layer.
- Parameters:
layer – A layer object with the attributes necessary for copying as defined in
BaseLayer.copy.name – The name to assign to the new layer after insertion. The value will have been normalized with
normalizers.normalizeLayerNameand tested to make sure that it is unique to the font.**kwargs – Additional keyword arguments.
- Returns:
The newly inserted
BaseLayersubclass instance.
Note
Subclasses may override this method.
- BaseFont._interpolate(factor: list[int | float] | tuple[float, float], minFont: BaseFont, maxFont: BaseFont, round: bool, suppressError: bool) None[source]¶
Interpolate all possible data in the native font.
This is the environment implementation of
BaseFont.interpolate.- Parameters:
factor – The interpolation value as a single
intorfloator atupleof twointorfloatvalues representing the factors(x, y).minFont – The
BaseFontsubclass instance corresponding to the 0.0 position in the interpolation.maxFont – The
BaseFontsubclass instance corresponding to the 1.0 position in the interpolation.round – A boolean indicating whether the result should be rounded to integers.
suppressError – A boolean indicating whether to ignore incompatible data or raise an error when such incompatibilities are found.
- Raises:
TypeError – If minFont or maxFont are not instances of
BaseFont.
Note
Subclasses may override this method.
- BaseFont._isCompatible(other: BaseFont, reporter: FontCompatibilityReporter) None[source]¶
Evaluate interpolation compatibility with another native font.
This is the environment implementation of
BaseFont.isCompatible.- Parameters:
other – The other
BaseFontsubclass instance to check compatibility with.reporter – An object used to report compatibility issues.
Note
Subclasses may override this method.
- static BaseFont._isValidGenerateEnvironmentOption(name: str) bool[source]¶
Validate if the environment option is supported.
Any unknown keyword arguments given to
BaseFont.generateare passed to this method. name is the name used for the argument. Environments may evaluate if name is a supported option.- Parameters:
name – The name of the environment option to validate.
- Returns:
Trueif the environment option is supported, otherwiseFalse.
Note
Subclasses may override this method.
- BaseFont._iter(**kwargs: Any) Iterator[BaseGlyph]¶
Iterate through the glyphs in the native layer.
This is the environment implementation of
BaseLayer.__iter__andBaseFont.__iter__.- Returns:
An iterator over instances of a
BaseGlyphsubclass.
Note
Subclasses may override this method.
- BaseFont._keys(**kwargs: Any) tuple[str, ...][source]¶
Get a list of all glyph names in the native default layer.
This is the environment implementation of
BaseFont.keys.Note
Subclasses may override this method.
- BaseFont._len(**kwargs: Any) int¶
Return the number of glyphs in the native layer.
This is the environment implementation of
BaseLayer.__len__andBaseFont.__len__- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
The number of
BaseGlyphsubclass instances in the layer as anint.
Note
Subclasses may override this method.
- BaseFont._newGlyph(name: str, **kwargs: Any) BaseGlyph[source]¶
Create a new glyph in the native default layer.
This is the environment implementation of :meth:`BaseFont.newGlyph.
- Parameters:
name – The name to assign to the new glyph. The value will have been normalized with
normalizers.normalizeGlyphNameand verified as unique within the default layer.**kwargs – Additional keyword arguments.
- Returns:
An instance of a
BaseGlyphsubclass representing the new glyph.
Note
Subclasses may override this method.
- BaseFont._removeGlyph(name: str, **kwargs: Any) None[source]¶
Remove the specified glyph from the default layer.
This is the environment implementation of
BaseFont.removeGlyph.- Parameters:
name – The name of the glyph to remove. The value will be normalized with
normalizers.normalizeGlyphName.**kwargs – Additional keyword arguments.
Note
Subclasses may override this method.
- BaseFont._round() None[source]¶
Round all appropriate native font data to integers.
This is the environment implementation of
BaseFont.round.Note
Subclasses may override this method.
- BaseFont._set_selectedGuidelines(value: list[BaseGuideline | int]) None[source]¶
Set the selected guidelines in the native font.
This is the environment implementation of the
BaseFont.selectedGuidelinesproperty setter.- Parameters:
value – The
listofBaseGuidelineinstances to select. Each value item will have been normalized withnormalizers.normalizeGuideline.
Note
Subclasses may override this method.
- BaseFont._set_selectedLayerNames(value: list[str]) None[source]¶
Set the selected glyph layer names in the native font layer.
This is the environment implementation of the
BaseFont.selectedLayerNamesproperty setter.- Parameters:
value – The
listof layer names representing theBaseLayerinstances to select. Each value item will have been normalized withnormalizers.normalizeLayerName.
Note
Subclasses may override this method.
- BaseFont._set_selectedLayers(value: list[BaseLayer]) None[source]¶
Set the selected glyph layers in the native default font layer.
This is the environment implementation of the
BaseFont.selectedLayersproperty setter.- Parameters:
value – The
listofBaseLayerinstances to select. Each value item will have been normalized withnormalizers.normalizeLayer.
Note
Subclasses may override this method.