Class TextRenderer
java.lang.Object
lol.trq.helios.text.TextRenderer
Lays out and draws single lines of left-to-right text with kerning, through a
ShapeBatch, so text and
shapes share draw calls and stay in order.
With formatting on, § followed by a code changes the look of what follows: 0-9 and
a-f set a colour (keeping the style's alpha) and clear the formats, l bold, o
italic, n underline, m strikethrough, k obfuscated, r reset. Codes are not drawn and
take no space. Positions are the top left of the line box; the baseline is ascent * size below it and is
snapped to the pixel grid.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatdraw(ShapeBatch batch, CharSequence text, float x, float y, TextStyle style) Draws a line of text into a batch that has begun.static Stringstrip(CharSequence text) Removes formatting codes.floatwidth(CharSequence text, TextStyle style) Measures a line of text.
-
Field Details
-
PALETTE
public static final int[] PALETTEThe 16 colours of the§0-§fcodes.
-
-
Constructor Details
-
TextRenderer
Creates a renderer.- Parameters:
gl- the backend, for uploading font atlases
-
-
Method Details
-
draw
Draws a line of text into a batch that has begun.- Parameters:
batch- the batchtext- the textx- lefty- top of the line boxstyle- the style- Returns:
- the advance width of the text in drawing units
-
width
Measures a line of text.- Parameters:
text- the textstyle- the style- Returns:
- the advance width in drawing units
-
strip
Removes formatting codes.- Parameters:
text- text with§codes- Returns:
- the text without them
-