Index: source/gui/CGUIText.cpp =================================================================== --- source/gui/CGUIText.cpp +++ source/gui/CGUIText.cpp @@ -68,6 +68,7 @@ CStrIntern font(fontW.ToUTF8()); float y = bufferZone; // drawing pointer + float lineWidth = 0.f; int from = 0; bool firstLine = true; // Necessary because text in the first line is shorter @@ -97,12 +98,17 @@ posLastImage = std::max(posLastImage, i); + lineWidth += feedback.m_Size.Width; + prelimLineHeight = std::max(prelimLineHeight, feedback.m_Size.Height); // If width is 0, then there's no word-wrapping, disable NewLine. - if (((width != 0 && (feedback.m_Size.Width + 2 * bufferZone > width || feedback.m_NewLine)) || i == static_cast(string.m_Words.size()) - 2) && - ProcessLine(pGUI, string, font, pObject, images, align, prelimLineHeight, width, bufferZone, firstLine, y, i, from)) - return; + if (((width != 0 && from != i && (lineWidth + 2 * bufferZone > width || feedback.m_NewLine)) || i == static_cast(string.m_Words.size()) - 2)) + { + if (ProcessLine(pGUI, string, font, pObject, images, align, prelimLineHeight, width, bufferZone, firstLine, y, i, from)) + return; + lineWidth = 0.f; + } } } @@ -386,12 +392,12 @@ } break; } - else if (x > widthRangeTo && j == tempFrom) + else if (x + dx > widthRangeTo && j == tempFrom) { from = j+1; // do not break, since we want it to be added to m_TextCalls } - else if (x > widthRangeTo) + else if (x + dx > widthRangeTo) { from = j; break;