Creates a FontRenderer with a given 2D canvas context, and an optional scale factor for displaying text.
The rendering context that the text will be rendered onto.
The scale factor (like Minecraft's GUI scale setting) for text. Defaults to 2x.
The scale factor (like Minecraft's GUI scale setting) for text. Defaults to 2x.
Draws a string component at the given position with a given FontStyle. It is recommended to use drawStringFormatted or drawStringFormattedShadow instead.
Draws a string (parsed for formatting codes) at a given position. Takes an optional shadow argument to display with darker colors, although drawStringFormattedShadow handles adding the shadow for you.
Draws a string (parsed for formatting codes) at a given position, with a shadow added behind it.
Draws a string in the style used for tooltips
Get the width that a single character (not bolded) will take up on the canvas.
Get the width that a formatted string will take up on the canvas.
Get the width that a string component will take up on the canvas. Do not use this for formatted text.
Gets the height of a string in the style used for tooltips
Gets the width of a string in the style used for tooltips
Loads the ascii.png image into the internal font canvas. Takes an optional src parameter to change the location of ascii.png.
Generated using TypeDoc
FontRenderer renders Minecraft Font text onto the given 2D canvas context.
You must call loadFontImage to load the font onto the internal canvas. Example:
let renderer = new FontRenderer(ctx); renderer.loadFontImage().then(() => { renderer.drawStringFormatted("Hello!"); });