MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / CalcTextSize

Method CalcTextSize

lib/imgui/imgui.cpp:4207–4227  ·  view source on GitHub ↗

Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. CalcTextSize("") should return ImVec2(0.0f, g.FontSize)

Source from the content-addressed store, hash-verified

4205// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker.
4206// CalcTextSize("") should return ImVec2(0.0f, g.FontSize)
4207ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
4208{
4209 ImGuiContext& g = *GImGui;
4210
4211 const char* text_display_end;
4212 if (hide_text_after_double_hash)
4213 text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
4214 else
4215 text_display_end = text_end;
4216
4217 ImFont* font = g.Font;
4218 const float font_size = g.FontSize;
4219 if (text == text_display_end)
4220 return ImVec2(0.0f, font_size);
4221 ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
4222
4223 // Round
4224 text_size.x = IM_FLOOR(text_size.x + 0.95f);
4225
4226 return text_size;
4227}
4228
4229// Find window given position, search front-to-back
4230// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programatically

Callers

nothing calls this directly

Calls 2

ImVec2Class · 0.85
CalcTextSizeAMethod · 0.80

Tested by

no test coverage detected