mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-12 07:49:55 +02:00
Merge branch 'master' into viewport
# Conflicts: # examples/imgui_impl_vulkan.h # imgui.cpp
This commit is contained in:
@ -2632,11 +2632,32 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
const bool word_wrap_enabled = (wrap_width > 0.0f);
|
||||
const char* word_wrap_eol = NULL;
|
||||
|
||||
// Skip non-visible lines
|
||||
// Fast-forward to first visible line
|
||||
const char* s = text_begin;
|
||||
if (!word_wrap_enabled && y + line_height < clip_rect.y)
|
||||
while (s < text_end && *s != '\n') // Fast-forward to next line
|
||||
s++;
|
||||
if (y + line_height < clip_rect.y && !word_wrap_enabled)
|
||||
while (y + line_height < clip_rect.y)
|
||||
{
|
||||
while (s < text_end)
|
||||
if (*s++ == '\n')
|
||||
break;
|
||||
y += line_height;
|
||||
}
|
||||
|
||||
// For large text, scan for the last visible line in order to avoid over-reserving in the call to PrimReserve()
|
||||
// Note that very large horizontal line will still be affected by the issue (e.g. a one megabyte string buffer without a newline will likely crash atm)
|
||||
if (text_end - s > 10000 && !word_wrap_enabled)
|
||||
{
|
||||
const char* s_end = s;
|
||||
float y_end = y;
|
||||
while (y_end < clip_rect.w)
|
||||
{
|
||||
while (s_end < text_end)
|
||||
if (*s_end++ == '\n')
|
||||
break;
|
||||
y_end += line_height;
|
||||
}
|
||||
text_end = s_end;
|
||||
}
|
||||
|
||||
// Reserve vertices for remaining worse case (over-reserving is useful and easily amortized)
|
||||
const int vtx_count_max = (int)(text_end - s) * 4;
|
||||
@ -2695,12 +2716,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
{
|
||||
x = pos.x;
|
||||
y += line_height;
|
||||
|
||||
if (y > clip_rect.w)
|
||||
break;
|
||||
if (!word_wrap_enabled && y + line_height < clip_rect.y)
|
||||
while (s < text_end && *s != '\n') // Fast-forward to next line
|
||||
s++;
|
||||
break; // break out of main loop
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
|
Reference in New Issue
Block a user