Legacy Unicode Provider#

The legacy_unicode provider is similar to the Bitmap Provider, in that it loads glyphs from textures.

It uses a system of templates to create and add massive amounts of "fallback" characters. Each glyph is 16x16 pixels wide, so each page is 256x256 (16 characters on each line, 16 lines, 16 length for each glyph).

Warning

This provider is deprecated and should not be used when possible.

Important

Characters above the BMP are not handled.

Structure#

{
    "type": "legacy_unicode",
    "sizes": "minecraft:font/glyph_sizes.bin",
    "template": "minecraft:font/unicode_page_%s.png"
}

Sizes#

The sizes field references a binary file that contains the widths of each glyph. Most often, this file is called glyph_sizes.bin; this is what the Vanilla game names it.

Each character width is one byte large; the higher nibble records the starting position while the lower records the ending position in the 16×16 glyph grid.

A specific character's width is determined by finding its codepoint's byte. The character 'A' has a codepoint of 0x41, so the 0x41 (65 in decimal) byte would be addressed.

A square character occupying the entire grid (pixel width #1 [0; 0x0] through #16 [15; 0xF]) would have a byte of 0x0F.

Widths cannot extend past 16 pixels, and characters whose codepoints are greater than 0xFFFF (65535) are undefined (unhandled).

Template#

The template field defines where Minecraft will search for each texture. Sheets of characters are stored in "pages", and organized according to the high 2 digits in their 4-digit codepoint.

For example, the character 'A' (codepoint 0x41) has a "page" of 00. Although the codepoint is 0x**41**, the highest codepoint accepted is 0xFFFF, which is 2 bytes wide (4 digits here). Therefore, the codepoints are padded to 4 digits, filled with`0. So, the "seen" codepoint for 'A' is 0x*00***41**. Keep in mind that the page for codepoint 0x436A is 43, and the page for codepoint 0xFE4 is 0F.

Characters with codepoints above 0xFFFF, page FF (such as most emojis) are not handled.

Surrogates#

Some codepoints are invalid on their own. These are the surrogate pairs, used to encode codepoints higher than U+FFFF in UTF-16.

This means that these template pages are invalid and can not/will not be used:

  • D8

  • D9

  • DA

  • DB

  • DC

  • DD

  • DE

  • DF

To advances#

Legacy Unicode glyph sizes can be converted to a Space Provider advances with mcfonts.providers.LegacyUnicodeProvider.to_advances():

import mcfonts.providers
mcfonts.providers.LegacyUnicodeProvider.to_advances(
    b"A bunch of bytes..."
)

Conversely, advances can be converted into space advances with mcfonts.providers.SpaceProvider.to_glyph_sizes().