Fonts: fixed RenderText() asserting when crossing VtxOffset change boundaries. (#8720, #8465)

This commit is contained in:
ocornut
2025-06-24 12:21:07 +02:00
parent a49ddaac89
commit 608dd96de6

View File

@@ -5581,7 +5581,6 @@ begin:
return; return;
// Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized)
const int cmd_count = draw_list->CmdBuffer.Size;
const int vtx_count_max = (int)(text_end - s) * 4; const int vtx_count_max = (int)(text_end - s) * 4;
const int idx_count_max = (int)(text_end - s) * 6; const int idx_count_max = (int)(text_end - s) * 6;
const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max; const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max;
@@ -5589,6 +5588,7 @@ begin:
ImDrawVert* vtx_write = draw_list->_VtxWritePtr; ImDrawVert* vtx_write = draw_list->_VtxWritePtr;
ImDrawIdx* idx_write = draw_list->_IdxWritePtr; ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
unsigned int vtx_index = draw_list->_VtxCurrentIdx; unsigned int vtx_index = draw_list->_VtxCurrentIdx;
const int cmd_count = draw_list->CmdBuffer.Size;
const ImU32 col_untinted = col | ~IM_COL32_A_MASK; const ImU32 col_untinted = col | ~IM_COL32_A_MASK;
const char* word_wrap_eol = NULL; const char* word_wrap_eol = NULL;
@@ -5711,6 +5711,8 @@ begin:
draw_list->CmdBuffer.pop_back(); draw_list->CmdBuffer.pop_back();
draw_list->PrimUnreserve(idx_count_max, vtx_count_max); draw_list->PrimUnreserve(idx_count_max, vtx_count_max);
draw_list->AddDrawCmd(); draw_list->AddDrawCmd();
//IMGUI_DEBUG_LOG("RenderText: cancel and retry to missing glyphs.\n"); // [DEBUG]
//draw_list->AddRectFilled(pos, pos + ImVec2(10, 10), IM_COL32(255, 0, 0, 255)); // [DEBUG]
goto begin; goto begin;
//RenderText(draw_list, size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip); // FIXME-OPT: Would a 'goto begin' be better for code-gen? //RenderText(draw_list, size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip); // FIXME-OPT: Would a 'goto begin' be better for code-gen?
//return; //return;