Using custom ceilf inline impl in ImGui::CalcTextSize().

Amend 7b0bf230, 4622fa4b6, 12b7977. (#791)
This commit is contained in:
ocornut
2026-05-29 15:59:44 +02:00
parent 12b7977555
commit 75f985998b
3 changed files with 5 additions and 5 deletions

View File

@@ -6199,10 +6199,9 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
// Round
// FIXME: This has been here since Dec 2015 (7b0bf230 then 4622fa4b6) but down the line we want this out. See #791.
// Investigate using ceilf or e.g. https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c, https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html
// The problem is that ceilf() has a measurable cost. Not high, but measurable!
text_size.x = IM_TRUNC(text_size.x + 0.999f);
// (see 7b0bf230, 4622fa4b6, #791 for details about this.)
// FIXME: Add a way to disable this.
text_size.x = ImCeilFast(text_size.x);
return text_size;
}