Package net.minecraft.client.font
Class TextHandler
java.lang.Object
net.minecraft.client.font.TextHandler
@Environment(CLIENT) public class TextHandler extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
TextHandler.LineBreakingVisitor
(package private) static class
TextHandler.LineWrappingCollector
static interface
TextHandler.LineWrappingConsumer
A consumer of the line-breaking information.(package private) static class
TextHandler.StyledString
(package private) class
TextHandler.WidthLimitingVisitor
static interface
TextHandler.WidthRetriever
A retriever of character width. -
Field Summary
Fields Modifier and Type Field Description private TextHandler.WidthRetriever
widthRetriever
-
Constructor Summary
Constructors Constructor Description TextHandler(TextHandler.WidthRetriever widthRetriever)
-
Method Summary
Modifier and Type Method Description Style
getStyleAt(OrderedText text, int x)
Gets the style at thex
position in a text.Style
getStyleAt(StringVisitable text, int x)
Gets the style at thex
position in a text.int
getTrimmedLength(String text, int maxWidth, Style style)
Returns the length of a string when it is trimmed to be at mostmaxWidth
wide.float
getWidth(String text)
Returns the width of a string.float
getWidth(OrderedText text)
float
getWidth(StringVisitable text)
Returns the width of a text.void
method_29971(StringVisitable stringVisitable, int int2, Style style, BiConsumer<StringVisitable,Boolean> biConsumer)
static int
moveCursorByWords(String text, int offset, int cursor, boolean consumeSpaceOrBreak)
String
trimToWidth(String text, int maxWidth, Style style)
Trim a string to be at mostmaxWidth
wide.StringVisitable
trimToWidth(StringVisitable text, int width, Style style)
String
trimToWidthBackwards(String text, int maxWidth, Style style)
Trim a string from right to left to be at mostmaxWidth
wide.List<StringVisitable>
wrapLines(String text, int maxWidth, Style style)
void
wrapLines(String text, int maxWidth, Style style, boolean retainTrailingWordSplit, TextHandler.LineWrappingConsumer consumer)
List<StringVisitable>
wrapLines(StringVisitable stringVisitable, int maxWidth, Style style)
-
Field Details
-
widthRetriever
-
-
Constructor Details
-
TextHandler
-
-
Method Details
-
getWidth
Returns the width of a string. -
getWidth
Returns the width of a text. -
getWidth
-
getTrimmedLength
Returns the length of a string when it is trimmed to be at mostmaxWidth
wide.- Parameters:
text
- the string to trimmaxWidth
- the max width of the trimmed stringstyle
- the style of the trimmed string
-
trimToWidth
Trim a string to be at mostmaxWidth
wide.- Parameters:
text
- the string to trimmaxWidth
- the max width of the trimmed stringstyle
- the style of the trimmed string- Returns:
- the trimmed string
-
trimToWidthBackwards
Trim a string from right to left to be at mostmaxWidth
wide.- Parameters:
text
- the string to trimmaxWidth
- the max width of the trimmed stringstyle
- the style of the trimmed string- Returns:
- the trimmed string
-
getStyleAt
Gets the style at thex
position in a text.- Parameters:
x
- the position in the text- Returns:
- a style
-
getStyleAt
Gets the style at thex
position in a text.- Parameters:
x
- the position in the text- Returns:
- a style
-
trimToWidth
-
moveCursorByWords
public static int moveCursorByWords(String text, int offset, int cursor, boolean consumeSpaceOrBreak) -
wrapLines
public void wrapLines(String text, int maxWidth, Style style, boolean retainTrailingWordSplit, TextHandler.LineWrappingConsumer consumer) -
wrapLines
-
wrapLines
-
method_29971
public void method_29971(StringVisitable stringVisitable, int int2, Style style, BiConsumer<StringVisitable,Boolean> biConsumer)
-