diff --git a/source/frontend/StarChat.cpp b/source/frontend/StarChat.cpp index 9c38b9b..688bf4a 100644 --- a/source/frontend/StarChat.cpp +++ b/source/frontend/StarChat.cpp @@ -177,7 +177,7 @@ void Chat::addMessages(List const& messages, bool showPane) for (auto const& message : messages) { Maybe wrapWidth; if (message.portrait.empty()) - wrapWidth = m_chatLog->size()[0] - m_chatLogPadding[0]; + wrapWidth = m_chatLog->size()[0] - m_chatLogPadding[0] * 2; guiContext.setFont(m_font); guiContext.setFontSize(m_fontSize); @@ -261,7 +261,7 @@ void Chat::renderImpl() { float messageHeight = 0; float lineHeightMargin = + ((m_chatLineHeight * m_fontSize) - m_fontSize); - unsigned wrapWidth = m_chatLog->size()[0] - m_chatLogPadding[0]; + unsigned wrapWidth = m_chatLog->size()[0] - m_chatLogPadding[0] * 2; if (message.portrait != "") { TextPositioning tp = {Vec2F(chatMin + m_portraitTextOffset), HorizontalAnchor::LeftAnchor, VerticalAnchor::VMidAnchor, (wrapWidth - m_portraitTextOffset[0])}; diff --git a/source/rendering/StarTextPainter.cpp b/source/rendering/StarTextPainter.cpp index 68ab6d3..9891ad6 100644 --- a/source/rendering/StarTextPainter.cpp +++ b/source/rendering/StarTextPainter.cpp @@ -131,12 +131,10 @@ bool TextPainter::processWrapText(StringView text, unsigned* wrapWidth, WrapText unsigned lineCharSize = 0; // how many characters in this line ? auto escIt = end; - - bool splitting = false; // Did we last see a place to split the string ? unsigned splitWidth = 0; // How wide was the string there ? auto lineStartIt = it; // Where does this line start ? - auto splitIt = end; + auto splitIt = end; // != end if we last saw a place to split the string auto slice = [](StringView::const_iterator a, StringView::const_iterator b) -> StringView { const char* aPtr = &*a.base(); @@ -176,29 +174,26 @@ bool TextPainter::processWrapText(StringView text, unsigned* wrapWidth, WrapText ++lineStartIt; // next line starts after the CR with no characters in it and no known splits. lineCharSize = linePixelWidth = 0; - splitting = false; } else { int charWidth = glyphWidth(character); // is it a place where we might want to split the line ? if (character == ' ' || character == '\t') { - splitting = true; - splitWidth = linePixelWidth + charWidth; // the width of the string at splitIt = it; - ++splitIt; + splitWidth = linePixelWidth + charWidth; // the width of the string at // the split point, i.e. after the space. } // would the line be too long if we render this next character ? if (wrapWidth && (linePixelWidth + charWidth) > *wrapWidth) { // did we find somewhere to split the line ? - if (splitting) { + if (splitIt != end) { if (!textFunc(slice(lineStartIt, splitIt), lines++)) return false; unsigned stringWidth = linePixelWidth - splitWidth; linePixelWidth = stringWidth + charWidth; // and is as wide as the bit after the space. - lineStartIt = splitIt; - splitting = false; + lineStartIt = ++splitIt; + splitIt = end; } else { if (!textFunc(slice(lineStartIt, it), lines++)) return false;