Skip to main content

Text Functions

Functions for displaying text in various styles and formats.

Text

Display formatted text.
const char*
Format string (printf-style)

TextUnformatted

Raw text without formatting. Roughly equivalent to Text("%s", text) but faster with no memory copy, no buffer size limits.
const char*
Text to display
const char*
default:"NULL"
Optional end pointer. If specified, doesn’t require null-terminated string

TextColored

Shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
const ImVec4&
RGBA color (0.0f to 1.0f per component)
const char*
Format string (printf-style)

TextDisabled

Shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
const char*
Format string (printf-style)

TextWrapped

Shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won’t work on an auto-resizing window if there’s no other widgets to extend the window width.
const char*
Format string (printf-style)

LabelText

Display text+label aligned the same way as value+label widgets.
const char*
Label text displayed on the left
const char*
Format string for the value (printf-style)

BulletText

Shortcut for Bullet() + Text().
const char*
Format string (printf-style)

SeparatorText

Currently: formatted text with a horizontal line.
const char*
Text to display in the separator

Helper Functions

Bullet

Draw a small circle and keep the cursor on the same line. Advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses.

CalcTextSize

Calculate text size. Returns size in pixels.
const char*
Text to measure
const char*
default:"NULL"
Optional end pointer
bool
default:"false"
Hide text after ##
float
default:"-1.0f"
Wrap width (-1.0f = no wrapping)
ImVec2
Size of the text in pixels