mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 04:17:00 +00:00
ImFont: ignoring \r
This commit is contained in:
parent
d31cf1af5d
commit
20088303e9
23
imgui.cpp
23
imgui.cpp
@ -9714,6 +9714,8 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
line_width = word_width = blank_width = 0.0f;
|
||||
@ -9721,6 +9723,12 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
s = next_s;
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
{
|
||||
s = next_s;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
||||
if (ImCharIsSpace(c))
|
||||
@ -9825,6 +9833,8 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||
break;
|
||||
}
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
text_size.x = ImMax(text_size.x, line_width);
|
||||
@ -9832,6 +9842,9 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||
line_width = 0.0f;
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
continue;
|
||||
}
|
||||
|
||||
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
||||
if (line_width + char_width >= max_width)
|
||||
@ -9872,6 +9885,8 @@ ImVec2 ImFont::CalcTextSizeW(float size, float max_width, const ImWchar* text_be
|
||||
{
|
||||
const unsigned int c = (unsigned int)(*s++);
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
text_size.x = ImMax(text_size.x, line_width);
|
||||
@ -9879,6 +9894,9 @@ ImVec2 ImFont::CalcTextSizeW(float size, float max_width, const ImWchar* text_be
|
||||
line_width = 0.0f;
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
continue;
|
||||
}
|
||||
|
||||
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
||||
if (line_width + char_width >= max_width)
|
||||
@ -9971,12 +9989,17 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
|
||||
break;
|
||||
}
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
x = pos.x;
|
||||
y += line_height;
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
continue;
|
||||
}
|
||||
|
||||
float char_width = 0.0f;
|
||||
if (const Glyph* glyph = FindGlyph((unsigned short)c))
|
||||
|
Loading…
Reference in New Issue
Block a user