Text: Fixed layouting of wrapped-text block when the last source line is above the clipping region. Regression added in 1.89. (#5720, #5919)

+ Update version marker
This commit is contained in:
ocornut
2022-11-28 14:59:13 +01:00
parent 6af38b1a43
commit bd96f6eac4
8 changed files with 26 additions and 11 deletions

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.1
// dear imgui, v1.89.2 WIP
// (drawing and font code)
/*
@ -3565,17 +3565,18 @@ 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 (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_end, wrap_width);
s = CalcWordWrapPositionA(scale, s, line_next, wrap_width);
s = CalcWordWrapNextLineStartA(s, text_end);
}
else
{
s = line_end ? line_end + 1 : text_end;
s = line_next;
}
y += line_height;
}