Browse Source

fix chat line wrapping

pull/2862/head
qndel 5 years ago committed by Anders Jenbo
parent
commit
1f61b683a6
  1. 3
      Source/engine/render/text_render.cpp

3
Source/engine/render/text_render.cpp

@ -171,6 +171,7 @@ uint32_t DrawString(const Surface &out, string_view text, const Rectangle &rect,
else if (HasAnyOf(flags, UiFlags::AlignRight))
characterPosition.x += rect.size.width - lineWidth;
int rightMargin = rect.position.x + rect.size.width;
int bottomMargin = rect.size.height != 0 ? rect.position.y + rect.size.height : out.h();
if (lineHeight == -1)
@ -195,7 +196,7 @@ uint32_t DrawString(const Surface &out, string_view text, const Rectangle &rect,
uint32_t i = 0;
for (; i < text.length(); i++) {
uint8_t frame = text[i] & 0xFF;
if (text[i] == '\n') {
if (text[i] == '\n' || characterPosition.x > rightMargin) {
if (characterPosition.y + lineHeight >= bottomMargin)
break;
characterPosition.y += lineHeight;

Loading…
Cancel
Save