Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. CalcTextSize("") should return ImVec2(0.0f, g.FontSize)
| 5128 | // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. |
| 5129 | // CalcTextSize("") should return ImVec2(0.0f, g.FontSize) |
| 5130 | ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) |
| 5131 | { |
| 5132 | ImGuiContext& g = *GImGui; |
| 5133 | |
| 5134 | const char* text_display_end; |
| 5135 | if (hide_text_after_double_hash) |
| 5136 | text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string |
| 5137 | else |
| 5138 | text_display_end = text_end; |
| 5139 | |
| 5140 | ImFont* font = g.Font; |
| 5141 | const float font_size = g.FontSize; |
| 5142 | if (text == text_display_end) |
| 5143 | return ImVec2(0.0f, font_size); |
| 5144 | ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); |
| 5145 | |
| 5146 | // Round |
| 5147 | // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. |
| 5148 | // FIXME: Investigate using ceilf or e.g. |
| 5149 | // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c |
| 5150 | // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html |
| 5151 | text_size.x = IM_FLOOR(text_size.x + 0.99999f); |
| 5152 | |
| 5153 | return text_size; |
| 5154 | } |
| 5155 | |
| 5156 | // Find window given position, search front-to-back |
| 5157 | // FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programmatically |
nothing calls this directly
no test coverage detected