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.Renderable

The 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:

  1. Initialization, field copy

  2. Filter copy

  3. Glyph copy

Returns:

A provider copy that is equal but not identical.

Parameters:
memodict : collections.abc.Mapping[Any, Any] | None

Return type:

NotdefProvider

__delitem__(key: str) None
Parameters:
key : str

Return type:

None

__getitem__(item: str) mcfonts.glyph.bitmap.BitmapGlyph
Parameters:
item : str

Return type:

mcfonts.glyph.bitmap.BitmapGlyph

__iter__() collections.abc.Generator[str]
Return type:

collections.abc.Generator[str]

__len__() int
Return type:

int

__repr__() str

Return NotdefProvider(ascent x, height x, file x).

Return type:

str

__setitem__(key: str, value: mcfonts.glyph.bitmap.BitmapGlyph)
Parameters:
key : str

value : mcfonts.glyph.bitmap.BitmapGlyph

Return type:

None

as_dict() collections.abc.Mapping[str, Any]
Return type:

collections.abc.Mapping[str, Any]

get_ascent() int

Get the ascent field.

The ascent is always less than the height.

Returns:

Value of ascent field.

Return type:

int

get_file() str

Get the file field.

Returns:

Value of file field.

Return type:

str

classmethod get_glyph_type() type[mcfonts.glyph.bitmap.BitmapGlyph]

Return the type of Glyph this provider uses.

Returns:

Type of Glyph.

Return type:

type[mcfonts.glyph.bitmap.BitmapGlyph]

get_height() int

Get the height field.

Returns:

Value of height field.

Return type:

int

get_notdef() mcfonts.glyph.bitmap.BitmapGlyph
Return type:

mcfonts.glyph.bitmap.BitmapGlyph

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.

Returns:

A 2-element tuple of the minimum and maximum valid pack versions.

Return type:

tuple[None, None]

classmethod get_priority() int

Return the priority of this type of provider.

Returns:

Priority.

Return type:

int

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.

Returns:

If this provider should be saved.

Return type:

bool

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.

Parameters:
root : mcfonts.path.PackRoot

Resource pack root.

resource_location : str

Resource location of font JSON.

contents : collections.abc.Mapping[str, Any]

Font JSON.

Returns:

A provider.

Return type:

NotdefProvider

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 None if character cannot be rendered by this provider.

Return type:

mcfonts.render.RenderResult | None

set_ascent(value: int) None

Set the ascent field.

Parameters:
value : int

New value.

Raises:

ValueError -- If value is not less than height.

Return type:

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.

Parameters:
value : str

New value.

Return type:

None

set_height(value: int | None) None

Set the height field.

Parameters:
value : int | None

New height, or None to unset.

Return type:

None

set_notdef(glyph: mcfonts.glyph.bitmap.BitmapGlyph) None
Parameters:
glyph : mcfonts.glyph.bitmap.BitmapGlyph

Return type:

None

classmethod set_priority(priority: int) None

Set the priority of this type of provider.

Parameters:
priority : int

New priority.

Return type:

None

set_should_save(*, should_save: bool) None

Set whether this provider should explicitly be saved.

Parameters:
should_save : bool

New value.

Return type:

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

default_height : ClassVar[int] = 8
priority : ClassVar[int] = 5