浏览代码

Fix edge case where text breaking might result in too long string if
exactly 1 last symbol generated too long string

Ivan Savenko 5 月之前
父节点
当前提交
f82b40c8b2
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      client/windows/CMessage.cpp

+ 1 - 1
client/windows/CMessage.cpp

@@ -124,7 +124,7 @@ std::vector<std::string> CMessage::breakText(std::string text, size_t maxLineWid
 
 		// not all line has been processed - it turned out to be too long, so erase everything after last word break
 		// if string consists from a single word (or this is Chinese/Korean) - erase only last symbol to bring line back to allowed length
-		if(currPos < text.length() && (text[currPos] != 0x0a))
+		if(fontPtr->getStringWidth(printableString) > maxLineWidth && (text[currPos] != 0x0a))
 		{
 			if(wordBreak != ui32(-1))
 			{