Browse Source

Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText() calls with single strings larger than 10k. Text/TextUnformatted() calls were not affected, but e.g. InputText() was.

omar 6 years ago
parent
commit
84238240d6
3 changed files with 5 additions and 1 deletions
  1. 2 0
      docs/CHANGELOG.txt
  2. 2 0
      imgui_demo.cpp
  3. 1 1
      imgui_draw.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -37,6 +37,8 @@ Breaking Changes:
 
 
 Other Changes:
 Other Changes:
 
 
+- Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText()
+  calls with single strings larger than 10k. Text/TextUnformatted() calls were not affected, but e.g. InputText() was. [@pdoane]
 - When the focused window become inactive don't restore focus to a window with the ImGuiWindowFlags_NoInputs flag. (#2213) [@zzzyap]
 - When the focused window become inactive don't restore focus to a window with the ImGuiWindowFlags_NoInputs flag. (#2213) [@zzzyap]
 - Separator: Fixed Separator() outputting an extraneous empty line when captured into clipboard/text/file. 
 - Separator: Fixed Separator() outputting an extraneous empty line when captured into clipboard/text/file. 
 - Demo: Added ShowAboutWindow() call, previously was only accessible from the demo window.
 - Demo: Added ShowAboutWindow() call, previously was only accessible from the demo window.

+ 2 - 0
imgui_demo.cpp

@@ -902,6 +902,8 @@ static void ShowDemoWindowWidgets()
 
 
     if (ImGui::TreeNode("Multi-line Text Input"))
     if (ImGui::TreeNode("Multi-line Text Input"))
     {
     {
+        // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize 
+        // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
         static bool read_only = false;
         static bool read_only = false;
         static char text[1024*16] =
         static char text[1024*16] =
             "/*\n"
             "/*\n"

+ 1 - 1
imgui_draw.cpp

@@ -2662,7 +2662,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
         while (y_end < clip_rect.w && s_end < text_end)
         while (y_end < clip_rect.w && s_end < text_end)
         {
         {
             s_end = (const char*)memchr(s_end, '\n', text_end - s_end);
             s_end = (const char*)memchr(s_end, '\n', text_end - s_end);
-            s = s ? s + 1 : text_end;
+            s_end = s_end ? s_end + 1 : text_end;
             y_end += line_height;
             y_end += line_height;
         }
         }
         text_end = s_end;
         text_end = s_end;