1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Text: fixed issue in RenderText() leading to IM_ASSERT_PARANOID() triggering if enabled. (#6132, #5720, #5919)

Amend 3482d4ec, bd96f6e
This commit is contained in:
ocornut 2023-01-31 14:39:45 +01:00
parent d719776460
commit 867bdbecb3
3 changed files with 9 additions and 9 deletions

View File

@ -23,7 +23,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') // (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 "1.89.3 WIP"
#define IMGUI_VERSION_NUM 18924 #define IMGUI_VERSION_NUM 18925
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
/* /*

View File

@ -3573,19 +3573,17 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
while (y + line_height < clip_rect.y && s < text_end) 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_end = (const char*)memchr(s, '\n', text_end - s);
if (!line_end)
line_end = text_end;
if (word_wrap_enabled) if (word_wrap_enabled)
{ {
// FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPositionA(). // 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. // 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! // However it is still better than nothing performing the fast-forward!
s = CalcWordWrapPositionA(scale, s, line_end, wrap_width); s = CalcWordWrapPositionA(scale, s, line_end ? line_end : text_end, wrap_width);
s = CalcWordWrapNextLineStartA(s, text_end); s = CalcWordWrapNextLineStartA(s, text_end);
} }
else else
{ {
s = line_end + 1; s = line_end ? line_end + 1 : text_end;
} }
y += line_height; y += line_height;
} }

View File

@ -1,10 +1,12 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3 WIP
// (internal structures/api) // (internal structures/api)
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! // You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
// Set: // To implement maths operators for ImVec2 (disabled by default to not conflict with using IM_VEC2_CLASS_EXTRA with your own math types+operators), use:
// #define IMGUI_DEFINE_MATH_OPERATORS /*
// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators) #define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui_internal.h"
*/
/* /*