Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. CalcTextSize("") should return ImVec2(0.0f, g.FontSize)
| 4521 | // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. |
| 4522 | // CalcTextSize("") should return ImVec2(0.0f, g.FontSize) |
| 4523 | ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) |
| 4524 | { |
| 4525 | ImGuiContext& g = *GImGui; |
| 4526 | |
| 4527 | const char* text_display_end; |
| 4528 | if (hide_text_after_double_hash) |
| 4529 | text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string |
| 4530 | else |
| 4531 | text_display_end = text_end; |
| 4532 | |
| 4533 | ImFont* font = g.Font; |
| 4534 | const float font_size = g.FontSize; |
| 4535 | if (text == text_display_end) |
| 4536 | return ImVec2(0.0f, font_size); |
| 4537 | ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); |
| 4538 | |
| 4539 | // Round |
| 4540 | // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. |
| 4541 | // FIXME: Investigate using ceilf or e.g. |
| 4542 | // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c |
| 4543 | // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html |
| 4544 | text_size.x = IM_FLOOR(text_size.x + 0.99999f); |
| 4545 | |
| 4546 | return text_size; |
| 4547 | } |
| 4548 | |
| 4549 | // Find window given position, search front-to-back |
| 4550 | // 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