Class GuiMeasureContext

java.lang.Object
com.render.api.gui.GuiMeasureContext

public final class GuiMeasureContext extends Object
Public, read-only measurement surface for custom retained components.

All lengths use the host's design pixels. Text measurement follows the host's font policy and the same shaping and wrapping routes as painting. The host reuses this context; it is valid only during a measurement callback and must not be retained. Measurement callbacks should return sizes without modifying the component tree.

  • Method Details

    • viewportWidth

      public float viewportWidth()
      Returns:
      host viewport width in design pixels
    • viewportHeight

      public float viewportHeight()
      Returns:
      host viewport height in design pixels
    • deviceScale

      public float deviceScale()
      Returns:
      physical pixels per design pixel
    • timeSeconds

      public double timeSeconds()
      Returns:
      the host's current controlled animation sample
    • measureTextWidth

      public float measureTextWidth(String text, GuiPaintContext.TextOptions options)
      Measures a literal string using the public paint options, including their wrapping width.
    • measureTextWidth

      public float measureTextWidth(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options)
      Measures a styled Minecraft text value using the same options as custom paint.
    • measureTextHeight

      public float measureTextHeight(String text, GuiPaintContext.TextOptions options)
      Measures a literal string's height, including wrapped lines when a maximum width is supplied.
    • measureTextHeight

      public float measureTextHeight(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options)
      Measures a styled Minecraft text value's height.
    • layoutText

      public GuiTextLayout layoutText(GuiRichText text, GuiTextConstraints constraints)
      Shapes rich text and returns immutable metrics and caret/selection geometry.