Skip to main content

Class: P5AsciifyFontManager

Defined in: FontManager.ts:8

Manages the font used for the ASCII rendering pipeline and provides methods for working with the font.

Constructors

Constructor

new P5AsciifyFontManager(_p, _font): P5AsciifyFontManager

Defined in: FontManager.ts:38

Creates a new P5AsciifyFontManager instance.

Parameters

ParameterTypeDescription
_pp5The p5 instance.
_fontFontThe font to use for ASCII rendering.

Returns

P5AsciifyFontManager

Accessors

characters

Get Signature

get characters(): P5AsciifyCharacter[]

Defined in: FontManager.ts:347

An array of supported characters in the set font with additional information like unicode, and RGB color values.

Example
function setupAsciify() {
// Print the supported characters in the font to the console
console.log(p5asciify.asciifier().fontManager.characters);
}
Returns

P5AsciifyCharacter[]


font

Get Signature

get font(): Font

Defined in: FontManager.ts:334

The p5.Font object used for ASCII rendering.

Example
function drawAsciify() {
// Draw an FPS counter, using the font set in p5.asciify, on top of the ASCII rendering.
textFont(p5asciify.asciifier().fontManager.font);
textSize(16);
fill(255);
text(frameRate() + " FPS", 10, 10);
}
Returns

Font


fontSize

Get Signature

get fontSize(): number

Defined in: FontManager.ts:318

Returns the font size used for the texture containing all characters in the font.

Returns

number


maxGlyphDimensions

Get Signature

get maxGlyphDimensions(): object

Defined in: FontManager.ts:298

Returns the maximum width and height found in all the glyphs in the font.

Returns

object

NameTypeDefined in
heightnumberFontManager.ts:298
widthnumberFontManager.ts:298

texture

Get Signature

get texture(): Framebuffer

Defined in: FontManager.ts:303

Returns the texture containing all characters in the font.

Returns

Framebuffer


textureColumns

Get Signature

get textureColumns(): number

Defined in: FontManager.ts:308

Returns the number of columns in the texture containing all characters in the font.

Returns

number


textureRows

Get Signature

get textureRows(): number

Defined in: FontManager.ts:313

Returns the number of rows in the texture containing all characters in the font.

Returns

number

Methods

getUnsupportedCharacters()

getUnsupportedCharacters(characters): string[]

Defined in: FontManager.ts:155

Returns an array of characters that are not supported by the current font.

Parameters

ParameterTypeDescription
charactersstringThe string of characters to check.

Returns

string[]

An array of unsupported characters. List is empty if all characters are supported.

Example

function setupAsciify() {
// Print a list of potentially unsupported characters.
console.log(
p5asciify.asciifier().fontManager.getUnsupportedCharacters(" .,ABC123"),
);
}

glyphColor()

glyphColor(char): [number, number, number]

Defined in: FontManager.ts:127

Gets the color of a character in the font.

Parameters

ParameterTypeDescription
charstringThe character to get the color for.

Returns

[number, number, number]

An array containing the RGB color values for the character, which can be used to set the fill color when drawing to a custom renderers characterFramebuffer to convert those pixels into the selected character.

Throws

P5AsciifyError If the character is not found in the font.

Example

function setupAsciify() {
// Get the RGB color of the character 'A'
const color = p5asciify.asciifier().fontManager.glyphColor("A");
console.log(color);
}

glyphColors()

glyphColors(characters): [number, number, number][]

Defined in: FontManager.ts:189

Gets an array of RGB colors for a given string of characters.

Parameters

ParameterTypeDefault valueDescription
charactersstring | string[]""A string of characters.

Returns

[number, number, number][]

Array of RGB color values.

Throws

P5AsciifyError If a character is not found in the fonts available characters.

Example

function setupAsciify() {
// Get the RGB colors for the characters 'ABC'
const colors = p5asciify.asciifier().fontManager.glyphColors("ABC");
console.log(colors);
}