Skip to content

textmode.js / TextmodeFont

Class: TextmodeFont

Manages the textmode font used for rendering characters.

This class coordinates font loading, character extraction, texture atlas creation, and provides character color information. It acts as a facade for the font system.

Accessors

characters

Get Signature

ts
get characters(): TextmodeCharacter[];

Returns the array of TextmodeCharacter objects in the font.

Returns

TextmodeCharacter[]


fontSize

Get Signature

ts
get fontSize(): number;

Returns the font size used for rendering.

Returns

number


maxGlyphDimensions

Get Signature

ts
get maxGlyphDimensions(): object;

Returns the maximum dimensions of a glyph in the font.

Returns

object

height
ts
height: number;
width
ts
width: number;

textureColumns

Get Signature

ts
get textureColumns(): number;

Returns the number of columns in the texture atlas.

Returns

number


textureRows

Get Signature

ts
get textureRows(): number;

Returns the number of rows in the texture atlas.

Returns

number

Methods

getCharacterColor()

ts
getCharacterColor(character): [number, number, number];

Get the color associated with a character.

Parameters

character

string

The character to get the color for.

Returns

[number, number, number]

The RGB color as an array [r, g, b].


getCharacterColors()

ts
getCharacterColors(characters): [number, number, number][];

Get the colors associated with a string of characters.

Parameters

characters

string

The string of characters to get colors for.

Returns

[number, number, number][]

An array of RGB colors for each character in the string. Each color is represented as an array [r, g, b].


hasAllCharacters()

ts
hasAllCharacters(str): boolean;

Checks if all characters in the given string exist in the font.

Parameters

str

string

The string to check.

Returns

boolean

true if all characters exist in the font, false otherwise.