|
|
|
@ -10023,21 +10023,25 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re |
|
|
|
|
if (!text_end) |
|
|
|
|
text_end = text_begin + strlen(text_begin); |
|
|
|
|
|
|
|
|
|
const float scale = size / FontSize; |
|
|
|
|
const float line_height = FontSize * scale; |
|
|
|
|
|
|
|
|
|
// Align to be pixel perfect
|
|
|
|
|
pos.x = (float)(int)pos.x + DisplayOffset.x; |
|
|
|
|
pos.y = (float)(int)pos.y + DisplayOffset.y; |
|
|
|
|
float x = pos.x; |
|
|
|
|
float y = pos.y; |
|
|
|
|
if (y > clip_rect.w) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
const float scale = size / FontSize; |
|
|
|
|
const float line_height = FontSize * scale; |
|
|
|
|
const bool word_wrap_enabled = (wrap_width > 0.0f); |
|
|
|
|
const char* word_wrap_eol = NULL; |
|
|
|
|
|
|
|
|
|
ImDrawVert* out_vertices = draw_list->vtx_write; |
|
|
|
|
|
|
|
|
|
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++; |
|
|
|
|
while (s < text_end) |
|
|
|
|
{ |
|
|
|
|
if (word_wrap_enabled) |
|
|
|
@ -10085,6 +10089,13 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re |
|
|
|
|
{ |
|
|
|
|
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++; |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (c == '\r') |
|
|
|
@ -10095,21 +10106,14 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re |
|
|
|
|
if (const Glyph* glyph = FindGlyph((unsigned short)c)) |
|
|
|
|
{ |
|
|
|
|
char_width = glyph->XAdvance * scale; |
|
|
|
|
|
|
|
|
|
// Clipping on Y is more likely
|
|
|
|
|
if (c != ' ' && c != '\t') |
|
|
|
|
{ |
|
|
|
|
// Clipping on Y is more likely
|
|
|
|
|
// We don't do a second finer clipping test on the Y axis (todo: do some measurement see if it is worth it, probably not)
|
|
|
|
|
float y1 = (float)(y + glyph->YOffset * scale); |
|
|
|
|
if (y1 > clip_rect.w) |
|
|
|
|
break; |
|
|
|
|
float y2 = (float)(y1 + glyph->Height * scale); |
|
|
|
|
if (y2 < clip_rect.y) |
|
|
|
|
{ |
|
|
|
|
// Fast-forward until next line
|
|
|
|
|
char_width = 0.0f; |
|
|
|
|
while (s < text_end && *s != '\n') s++; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
float x1 = (float)(x + glyph->XOffset * scale); |
|
|
|
|
float x2 = (float)(x1 + glyph->Width * scale); |
|
|
|
|
if (x1 <= clip_rect.z && x2 >= clip_rect.x) |
|
|
|
@ -10169,7 +10173,6 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
x += char_width; |
|
|
|
|
} |
|
|
|
|