Package net.minecraft.client.font
Class TextRenderer
java.lang.Object
net.minecraft.client.font.TextRenderer
@Environment(CLIENT) public class TextRenderer extends Object
Manages the rendering of text.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
TextRenderer.Drawer
-
Field Summary
Fields Modifier and Type Field Description int
fontHeight
The font height of the text that is rendered by the text renderer.private Function<Identifier,FontStorage>
fontStorageAccessor
private static Vec3f
FORWARD_SHIFT
private TextHandler
handler
Random
random
-
Constructor Summary
Constructors Constructor Description TextRenderer(Function<Identifier,FontStorage> fontStorageAccessor)
-
Method Summary
Modifier and Type Method Description int
draw(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light)
int
draw(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light, boolean rightToLeft)
private int
draw(String text, float x, float y, int color, Matrix4f matrix, boolean shadow, boolean mirror)
int
draw(MatrixStack matrices, String text, float x, float y, int color)
int
draw(MatrixStack matrices, OrderedText text, float x, float y, int color)
int
draw(MatrixStack matrices, Text text, float x, float y, int color)
int
draw(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light)
private int
draw(OrderedText text, float x, float y, int color, Matrix4f matrix, boolean shadow)
int
draw(Text text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light)
private void
drawGlyph(GlyphRenderer glyphRenderer, boolean bold, boolean italic, float weight, float x, float y, Matrix4f matrix, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int light)
private int
drawInternal(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light, boolean mirror)
private int
drawInternal(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumerProvider, boolean seeThrough, int backgroundColor, int light)
private float
drawLayer(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumerProvider, boolean seeThrough, int underlineColor, int light)
private float
drawLayer(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumerProvider, boolean seeThrough, int underlineColor, int light)
void
drawTrimmed(StringVisitable text, int x, int y, int maxWidth, int color)
int
drawWithShadow(MatrixStack matrices, String text, float x, float y, int color)
int
drawWithShadow(MatrixStack matrices, String text, float x, float y, int color, boolean rightToLeft)
int
drawWithShadow(MatrixStack matrices, OrderedText text, float x, float y, int color)
int
drawWithShadow(MatrixStack matrices, Text text, float x, float y, int color)
private FontStorage
getFontStorage(Identifier id)
TextHandler
getTextHandler()
int
getWidth(String text)
Gets the width of some text when rendered.int
getWidth(OrderedText text)
Gets the width of some text when rendered.int
getWidth(StringVisitable text)
Gets the width of some text when rendered.int
getWrappedLinesHeight(String text, int maxWidth)
Gets the height of the text when it has been wrapped.boolean
isRightToLeft()
Checks if the currently set language uses right to left writing.String
mirror(String text)
String
trimToWidth(String text, int maxWidth)
Trims a string to be at mostmaxWidth
wide.String
trimToWidth(String text, int maxWidth, boolean backwards)
Trims a string to be at mostmaxWidth
wide.StringVisitable
trimToWidth(StringVisitable text, int width)
Trims a string to be at mostmaxWidth
wide.private static int
tweakTransparency(int argb)
List<OrderedText>
wrapLines(StringVisitable text, int width)
Wraps text when the rendered width of text exceeds thewidth
.
-
Field Details
-
FORWARD_SHIFT
-
fontHeight
public final int fontHeightThe font height of the text that is rendered by the text renderer.- See Also:
- Constant Field Values
-
random
-
fontStorageAccessor
-
handler
-
-
Constructor Details
-
TextRenderer
-
-
Method Details
-
getFontStorage
-
drawWithShadow
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
drawWithShadow
public int drawWithShadow(MatrixStack matrices, String text, float x, float y, int color, boolean rightToLeft)- Parameters:
color
- the text color in the 0xAARRGGBB format
-
draw
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
drawWithShadow
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
drawWithShadow
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
draw
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
draw
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
mirror
-
draw
-
draw
-
draw
public int draw(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light)- Parameters:
color
- the text color in the 0xAARRGGBB format
-
draw
public int draw(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light, boolean rightToLeft)- Parameters:
color
- the text color in the 0xAARRGGBB format
-
draw
public int draw(Text text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light)- Parameters:
color
- the text color in the 0xAARRGGBB format
-
draw
public int draw(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light)- Parameters:
color
- the text color in the 0xAARRGGBB format
-
tweakTransparency
private static int tweakTransparency(int argb) -
drawInternal
private int drawInternal(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, boolean seeThrough, int backgroundColor, int light, boolean mirror) -
drawInternal
private int drawInternal(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumerProvider, boolean seeThrough, int backgroundColor, int light) -
drawLayer
private float drawLayer(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumerProvider, boolean seeThrough, int underlineColor, int light) -
drawLayer
private float drawLayer(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumerProvider, boolean seeThrough, int underlineColor, int light) -
drawGlyph
private void drawGlyph(GlyphRenderer glyphRenderer, boolean bold, boolean italic, float weight, float x, float y, Matrix4f matrix, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int light) -
getWidth
Gets the width of some text when rendered.- Parameters:
text
- the text
-
getWidth
Gets the width of some text when rendered.- Parameters:
text
- the text
-
getWidth
Gets the width of some text when rendered. -
trimToWidth
Trims a string to be at mostmaxWidth
wide.- Returns:
- the trimmed string
-
trimToWidth
Trims a string to be at mostmaxWidth
wide.- Returns:
- the trimmed string
- See Also:
TextHandler.trimToWidth(String, int, Style)
-
trimToWidth
Trims a string to be at mostmaxWidth
wide.- Returns:
- the text
- See Also:
TextHandler.trimToWidth(StringVisitable, int, Style)
-
drawTrimmed
- Parameters:
color
- the text color in the 0xAARRGGBB format
-
getWrappedLinesHeight
Gets the height of the text when it has been wrapped.- Returns:
- the height of the wrapped text
- See Also:
wrapLines(StringVisitable, int)
-
wrapLines
Wraps text when the rendered width of text exceeds thewidth
.- Returns:
- a list of ordered text which has been wrapped
-
isRightToLeft
public boolean isRightToLeft()Checks if the currently set language uses right to left writing. -
getTextHandler
-