MinecraftBoundedFontBackend

Optional backend capability that inspects image dimensions before allocating native or JVM pixels. Ownership and owner-thread confinement follow MinecraftFontBackend; existing backends keep their original callbacks.

Functions

Link copied to clipboard
abstract override fun close()

Releases backend-owned native resources on the owner thread.

Link copied to clipboard
abstract fun decodePng(bytes: ByteArray, limits: MinecraftFontLoadLimits): DrawImage

Decodes one image under the snapshot's encoded-byte, dimension, and pixel-payload ceilings. Implementations must inspect dimensions before native allocation and release partial resources after any failure. Callers independently check the returned size before retaining or copying image data.

abstract fun decodePng(bytes: ByteArray): DrawImage

Decodes PNG bytes into a detached straight-ARGB image.

Link copied to clipboard

Opens one owner-thread TrueType face under immutable encoded-byte and glyph-image ceilings. The default validates the encoded byte count before delegating to the existing face callback. Native backends override this method to pin the selected limits to the face and check measured glyph dimensions before allocating raster pixels. An oversized native-atlas marker allocates no pixels and is not itself subject to the image-allocation ceilings. Callers independently validate returned images before retaining them, including images from legacy implementations.

Opens one owner-thread TrueType face for the supplied settings. A failed open must release every partially allocated face resource before propagating the failure.

Link copied to clipboard
open fun visualGlyphs(text: String, rightToLeft: Boolean): List<MinecraftVisualGlyph>

Orders and shapes a complete logical line while preserving original UTF-16 scalar positions for font lookup. Shaping spans the whole line, including font boundaries, and contractions belong to their first contributing scalar. Original positions deliberately correct the native style lookup drift after Arabic contractions without changing the shaped glyphs. The default supplies identity order and replaces unmatched UTF-16 surrogates with the replacement scalar. Backends providing native bidirectional processing must override this operation alongside visualOrder.

Link copied to clipboard
open fun visualOrder(text: String, rightToLeft: Boolean): String

Applies the selected release's native-compatible bidirectional ordering and shaping. The default preserves text for backends whose caller supplies visual-order text.