diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 91436fae..7517c907 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -63,6 +63,10 @@ Other Changes: - Window: Fixed initial width of collapsed windows not taking account of contents width (broken in 1.67). (#2336, #176) - ListBox: Better optimized when clipped / non-visible. - InputTextMultiline: Better optimized when clipped / non-visible. +- Font: Fixed high-level ImGui::CalcTextSize() used by most widgets from erroneously subtracting 1.0f*scale to + calculated text width. Among noticeable side-effects, it would make sequences of repeated Text/SameLine calls + not align the same as a single call, and create mismatch between high-level size calculation and those performed + with the lower-level ImDrawList api. (#792) [@SlNPacifist] - ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle" with a small number of segments (e.g. an hexagon). (#2287) [@baktery] - ImGuiTextBuffer: Added append() function (unformatted). diff --git a/imgui.cpp b/imgui.cpp index e2ddba18..3ca42628 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3909,11 +3909,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex return ImVec2(0.0f, font_size); ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); - // Cancel out character spacing for the last character of a line (it is baked into glyph->AdvanceX field) - const float font_scale = font_size / font->FontSize; - const float character_spacing_x = 1.0f * font_scale; - if (text_size.x > 0.0f) - text_size.x -= character_spacing_x; + // Round text_size.x = (float)(int)(text_size.x + 0.95f); return text_size;