mcfonts.provider.notdef¶
A notdef provider; special handling for the normally hard-coded .notdef glyph.
Module Contents¶
- class NotdefProvider(*, ascent: int, height: int | None, file: str, notdef: mcfonts.glyph.bitmap.BitmapGlyph)¶
Bases:
mcfonts.provider.Provider[mcfonts.glyph.bitmap.BitmapGlyph],mcfonts.provider.HasPriority,mcfonts.serde.minecraft.MinecraftLoader[NotdefProvider],mcfonts.serde.minecraft.MinecraftSaver,mcfonts.serde.opentype.OpenTypeSaver,mcfonts.serde.yaff.YaffSaver,mcfonts.render.RenderableThe notdef provider allows changing the default "missing" glyph.
It stores only one bitmap glyph, which is accessible through the character "notdef". All other characters will not exist.
Initialize. Similar to
BitmapProvider..- Parameters:¶
- ascent : int¶
Vertical shift.
- height : int | None¶
Scale of glyph.
- file : str¶
Resource location to one PNG.
- notdef : mcfonts.glyph.bitmap.BitmapGlyph¶
Bitmap notdef glyph.
-
__deepcopy__(memodict: collections.abc.Mapping[Any, Any] | None =
None) NotdefProvider¶ Return a deep copy of this provider.
In order:
Initialization, field copy
Filter copy
Glyph copy
- __setitem__(key: str, value: mcfonts.glyph.bitmap.BitmapGlyph)¶
- Parameters:¶
- key : str¶
- value : mcfonts.glyph.bitmap.BitmapGlyph¶
- Return type:¶
None
- get_ascent() int¶
Get the ascent field.
The ascent is always less than the height.
- classmethod get_glyph_type() type[mcfonts.glyph.bitmap.BitmapGlyph]¶
Return the type of Glyph this provider uses.
- get_notdef() mcfonts.glyph.bitmap.BitmapGlyph¶
- Return type:¶
- classmethod get_pack_versions() tuple[None, 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.
- get_should_save() bool¶
Whether this provider should explicitly be saved.
Most of the time, this is not desireable and is only needed if this is a custom (not default) instance.
- classmethod minecraft_load(root: mcfonts.path.PackRoot, resource_location: str, contents: collections.abc.Mapping[str, Any]) NotdefProvider¶
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
- set_file(value: str) None¶
Set the file field.
Warning
Setting the file field does not change the glyph already created for this provider. To get a new glyph under a new image, create another provider.
- set_notdef(glyph: mcfonts.glyph.bitmap.BitmapGlyph) None¶
- set_should_save(*, should_save: bool) None¶
Set whether this provider should explicitly be saved.
- 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
-
default_height : ClassVar[int] =
8¶
-
priority : ClassVar[int] =
5¶