mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 12:27:01 +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)
|
if (c == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (c < 32)
|
||||||
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
line_width = word_width = blank_width = 0.0f;
|
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;
|
s = next_s;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (c == '\r')
|
||||||
|
{
|
||||||
|
s = next_s;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
||||||
if (ImCharIsSpace(c))
|
if (ImCharIsSpace(c))
|
||||||
@ -9825,6 +9833,8 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c < 32)
|
||||||
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
text_size.x = ImMax(text_size.x, line_width);
|
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;
|
line_width = 0.0f;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (c == '\r')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
||||||
if (line_width + char_width >= max_width)
|
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++);
|
const unsigned int c = (unsigned int)(*s++);
|
||||||
|
|
||||||
|
if (c < 32)
|
||||||
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
text_size.x = ImMax(text_size.x, line_width);
|
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;
|
line_width = 0.0f;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (c == '\r')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance;
|
||||||
if (line_width + char_width >= max_width)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c < 32)
|
||||||
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
x = pos.x;
|
x = pos.x;
|
||||||
y += line_height;
|
y += line_height;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (c == '\r')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
float char_width = 0.0f;
|
float char_width = 0.0f;
|
||||||
if (const Glyph* glyph = FindGlyph((unsigned short)c))
|
if (const Glyph* glyph = FindGlyph((unsigned short)c))
|
||||||
|
Loading…
Reference in New Issue
Block a user