Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. CalcTextSize("") should return ImVec2(0.0f, g.FontSize)
| 5591 | // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. |
| 5592 | // CalcTextSize("") should return ImVec2(0.0f, g.FontSize) |
| 5593 | ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) |
| 5594 | { |
| 5595 | ImGuiContext& g = *GImGui; |
| 5596 | |
| 5597 | const char* text_display_end; |
| 5598 | if (hide_text_after_double_hash) |
| 5599 | text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string |
| 5600 | else |
| 5601 | text_display_end = text_end; |
| 5602 | |
| 5603 | ImFont* font = g.Font; |
| 5604 | const float font_size = g.FontSize; |
| 5605 | if (text == text_display_end) |
| 5606 | return ImVec2(0.0f, font_size); |
| 5607 | ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); |
| 5608 | |
| 5609 | // Round |
| 5610 | // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. |
| 5611 | // FIXME: Investigate using ceilf or e.g. |
| 5612 | // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c |
| 5613 | // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html |
| 5614 | text_size.x = IM_FLOOR(text_size.x + 0.99999f); |
| 5615 | |
| 5616 | return text_size; |
| 5617 | } |
| 5618 | |
| 5619 | // Find window given position, search front-to-back |
| 5620 | // 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