mcfonts.provider.space¶
A space provider, defining simple widths for characters.
Module Contents¶
- class SpaceProvider(*, advances: collections.abc.Mapping[str, int])¶
Bases:
mcfonts.provider.Provider[mcfonts.glyph.space.SpaceGlyph],mcfonts.provider.HasPriority,mcfonts.serde.minecraft.MinecraftLoader[SpaceProvider],mcfonts.serde.minecraft.MinecraftSaver,mcfonts.serde.opentype.OpenTypeSaver,mcfonts.serde.yaff.YaffSaver,mcfonts.render.RenderableThe
spaceprovider defines only the width of a character.The keys of the
"advances"field are the characters as 1-length strings, and the values are integer widths.Initialize.
- Parameters:¶
- advances : collections.abc.Mapping[str, int]¶
Advances dictionary of character to width.
-
__deepcopy__(memodict: collections.abc.Mapping[Any, Any] | None =
None) SpaceProvider¶ Return a deep copy of this provider.
In order:
Initialization, field copy
Filter copy
Glyph copy
- __setitem__(key: str, value: mcfonts.glyph.space.SpaceGlyph)¶
- Parameters:¶
- key : str¶
- value : mcfonts.glyph.space.SpaceGlyph¶
- Return type:¶
None
- classmethod get_glyph_type() type[mcfonts.glyph.space.SpaceGlyph]¶
Return the type of Glyph this provider uses.
- classmethod get_pack_versions() tuple[int, None]¶
Return a tuple of the minimum and maximum pack versions for which this provider is used.
The tuple contains 2 optional integers - the start and end pack versions, both inclusive. None items indicate no bound:
(None, 4)means from any up to 4.(4, None)means from 4 up to any.
- classmethod get_priority() int¶
Return the priority of this type of provider.
- classmethod minecraft_load(root: mcfonts.path.PackRoot, resource_location: str, contents: collections.abc.Mapping[str, Any]) SpaceProvider¶
Return an instance of a provider, given the contents of the provider and where it is.
- minecraft_save(root: mcfonts.path.PackRoot, resource_location: str) None¶
Save a provider back to a location.
If the target file already exists, this provider will be appended to it.
Warning
This will overwrite files.
- Parameters:¶
- root : mcfonts.path.PackRoot¶
Resource pack root.
- resource_location : str¶
Resource location of font JSON.
- Return type:¶
None
- opentype_save(tables: mcfonts.serde.opentype.OpenTypeTables) None¶
Save provider into an OpenType font by modifying its tables.
- Parameters:¶
- tables : mcfonts.serde.opentype.OpenTypeTables¶
Table storage.
- Return type:¶
None
- render(character: str, metrics: mcfonts.render.RenderMetrics) mcfonts.render.RenderResult | None¶
Draw a character contained in this provider.
- Parameters:¶
- character : str¶
The character to render.
- metrics : mcfonts.render.RenderMetrics¶
Current rendering metrics.
- Returns:¶
RenderResult, or
Noneif character cannot be rendered by this provider.- Return type:¶
mcfonts.render.RenderResult | None
- yaff_save(data: mcfonts.serde.yaff.YaffData) None¶
Save provider into data.
- Parameters:¶
- data : mcfonts.serde.yaff.YaffData¶
Current whole YAFF font data.
- Return type:¶
None
-
priority : ClassVar[int] =
4¶
-
to_glyph_sizes(advances: collections.abc.Mapping[str, int], *, default_width: tuple[int, int] =
(0, 14)) bytearray¶ Create a
glyph_sizes.binbytearray from a template of characters and their starting and ending positions.>>> to_glyph_sizes({"\0": 15}, (0, 0)) bytearray(b'\x0e\x00\x00\x00...')