FontRenderer

class FontRenderer(val font: FontFace, val glyphManager: FontGlyphPageManager, val size: Float = DEFAULT_FONT_SIZE) : AbstractFontRenderer

Constructors

Link copied to clipboard
constructor(font: FontFace, glyphManager: FontGlyphPageManager, size: Float = DEFAULT_FONT_SIZE)

Properties

Link copied to clipboard

Glyph pages for the style of the font. If an element is null, fall back to [0]

Link copied to clipboard
Link copied to clipboard
open override val height: Float
Link copied to clipboard

Scales this renderer's text metrics to vanilla's 9px GUI font line height.

Link copied to clipboard
open override val size: Float

Functions

Link copied to clipboard
context(ctx: WorldRenderEnvironment)
inline fun draw(text: Component, parameters: AbstractFontRenderer.DrawParameters.() -> Unit = {}): Float

context(ctx: WorldRenderEnvironment)
inline fun draw(text: FormattedCharSequence, parameters: AbstractFontRenderer.DrawParameters.() -> Unit = {}): Float
context(ctx: GuiGraphicsExtractor)
inline fun draw(text: FormattedCharSequence, parameters: AbstractFontRenderer.DrawParameters.() -> Unit = {}): Float

Draws text as it is - unlike the Component overloads, it is not sanitized.

context(ctx: GuiGraphicsExtractor)
inline fun draw(text: Component, parameters: AbstractFontRenderer.DrawParameters.() -> Unit = {}): Float

Draws a Component, degenerating its legacy formatting and applying sanitizeForeignInput first. Pass a FormattedCharSequence when the text is already prepared.

fun draw(ctx: GuiGraphicsExtractor, text: Component, x: Float, y: Float, color: Color4b = Color4b.WHITE, shadow: Boolean = false, scale: Float = scaleToVanillaFont, horizontalAnchor: HorizontalAnchor? = null, verticalAnchor: VerticalAnchor? = null): Float

Draws text on the GUI at x/y in GUI pixels; scale 1 is this font's own size, the default matches vanilla's. For Kotlin the context overloads with DrawParameters do the same.

context(ctx: WorldRenderEnvironment)
open override fun draw(text: FormattedCharSequence, parameters: AbstractFontRenderer.DrawParameters): Float

Draws text with minecraft font markup on GUI with WorldRenderEnvironment.

context(ctx: GuiGraphicsExtractor)
open override fun draw(text: FormattedCharSequence, parameters: AbstractFontRenderer.DrawParameters): Float

Draws text with minecraft font markup on GUI with GuiGraphicsExtractor.

Link copied to clipboard
fun getStringWidth(text: Component, scale: Float = scaleToVanillaFont, shadow: Boolean = false): Float

Width of text in GUI pixels at scale, the default being vanilla's size.

open override fun getStringWidth(text: FormattedCharSequence, shadow: Boolean = false): Float

Approximates the width of a text. Accurate except for obfuscated (§k) formatting