From 3482d4eccfc6fe68f1db134829caf908ac9e294e Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 19 Jan 2023 15:59:39 +0100 Subject: [PATCH] Text: Fixed layouting of wrapped-text block skipping successive empty lines. (#5720, #5919) Regression in the bd96f6e fix --- docs/CHANGELOG.txt | 2 ++ imgui.h | 2 +- imgui_draw.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f4636d98..7bafe82d 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -37,6 +37,8 @@ HOW TO UPDATE? All changes: +- Text: Fixed layouting of wrapped-text block skipping successive empty lines, + regression from the fix in 1.89.2. (#5720, #5919) - Text: Fix clipping of single-character "..." ellipsis (U+2026 or U+0085) when font is scaled. Scaling wasn't taken into account, leading to ellipsis character straying slightly out of its expected boundaries. (#2775) diff --git a/imgui.h b/imgui.h index fea41340..ea30c1d1 100644 --- a/imgui.h +++ b/imgui.h @@ -23,7 +23,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') #define IMGUI_VERSION "1.89.3 WIP" -#define IMGUI_VERSION_NUM 18921 +#define IMGUI_VERSION_NUM 18922 #define IMGUI_HAS_TABLE /* diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 657ed702..b942e6e7 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3573,18 +3573,19 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im while (y + line_height < clip_rect.y && s < text_end) { const char* line_end = (const char*)memchr(s, '\n', text_end - s); - const char* line_next = line_end ? line_end + 1 : text_end; + if (!line_end) + line_end = text_end; if (word_wrap_enabled) { // FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPositionA(). // If the specs for CalcWordWrapPositionA() were reworked to optionally return on \n we could combine both. // However it is still better than nothing performing the fast-forward! - s = CalcWordWrapPositionA(scale, s, line_next, wrap_width); + s = CalcWordWrapPositionA(scale, s, line_end, wrap_width); s = CalcWordWrapNextLineStartA(s, text_end); } else { - s = line_next; + s = line_end + 1; } y += line_height; }