Class TextHandler

java.lang.Object
net.minecraft.client.font.TextHandler

@Environment(CLIENT)
public class TextHandler
extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • getWidth

      public float getWidth​(@Nullable String text)
      Returns the width of a string.
    • getWidth

      public float getWidth​(StringVisitable text)
      Returns the width of a text.
    • getWidth

      public float getWidth​(OrderedText text)
    • getTrimmedLength

      public int getTrimmedLength​(String text, int maxWidth, Style style)
      Returns the length of a string when it is trimmed to be at most maxWidth wide.
      Parameters:
      text - the string to trim
      maxWidth - the max width of the trimmed string
      style - the style of the trimmed string
    • trimToWidth

      public String trimToWidth​(String text, int maxWidth, Style style)
      Trim a string to be at most maxWidth wide.
      Parameters:
      text - the string to trim
      maxWidth - the max width of the trimmed string
      style - the style of the trimmed string
      Returns:
      the trimmed string
    • trimToWidthBackwards

      public String trimToWidthBackwards​(String text, int maxWidth, Style style)
      Trim a string from right to left to be at most maxWidth wide.
      Parameters:
      text - the string to trim
      maxWidth - the max width of the trimmed string
      style - the style of the trimmed string
      Returns:
      the trimmed string
    • getStyleAt

      @Nullable public Style getStyleAt​(StringVisitable text, int x)
      Gets the style at the x position in a text.
      Parameters:
      x - the position in the text
      Returns:
      a style
    • getStyleAt

      @Nullable public Style getStyleAt​(OrderedText text, int x)
      Gets the style at the x position in a text.
      Parameters:
      x - the position in the text
      Returns:
      a style
    • trimToWidth

      public StringVisitable trimToWidth​(StringVisitable text, int width, Style style)
    • 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

      public List<StringVisitable> wrapLines​(String text, int maxWidth, Style style)
    • wrapLines

      public List<StringVisitable> wrapLines​(StringVisitable stringVisitable, int maxWidth, Style style)
    • method_29971

      public void method_29971​(StringVisitable stringVisitable, int int2, Style style, BiConsumer<StringVisitable,​Boolean> biConsumer)