Skip to content

On-screen text ​

UiApi draws clean vector-style text that stays the same size on screen at any GUI scale. It is client only.

Draw text ​

Put your drawing inside overlay. It lays everything out in one fixed frame, so width and height give that frame's size.

java
UiApi.overlay(graphics, () -> {
    int w = UiApi.width(graphics);
    UiApi.centred(graphics, UiApi.Font.DISPLAY, "Hello", w / 2.0F, 120.0F, 0xFFFFFFFF);
    UiApi.text(graphics, UiApi.Font.MONO, "HP 100", 24.0F, 48.0F, 0xFF7FB0FF);
});

y is the text baseline, and colours are ARGB. Both text methods return the drawn width.

Fonts ​

FontUse it for
DISPLAYLarge titles
LABELSmall labels
MONONumbers and figures

More control ​

java
// align: 0 left, 0.5 centre, 1 right
UiApi.text(graphics, UiApi.Font.LABEL, "Right", x, y, 1.0F, 1.5F, 0xFFFFFFFF);

float w = UiApi.measure(graphics, UiApi.Font.LABEL, "Measure me", 1.0F);

UiApi.box(graphics, x, y, w, 2.0F, 0x80FFFFFF);

Minecraft 26.3

On 26.3 these methods take GuiGraphicsExtractor instead of GuiGraphics.