diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index ba0d95d01..ce76d5426 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -734,6 +734,7 @@ namespace opengl // put words back together until a wrap occurs float width = 0.0f; + float oldwidth = 0.0f; ostringstream string_builder; vector::const_iterator word_iter; for (word_iter = words.begin(); word_iter != words.end(); ++word_iter) { @@ -741,13 +742,14 @@ namespace opengl width += currentFont->getWidth( word ); // on wordwrap, push line to line buffer and clear string builder - if (width >= wrap) { + if (width >= wrap && oldwidth > 0) { lines_to_draw.push_back( string_builder.str() ); string_builder.str( "" ); width = static_cast(currentFont->getWidth( word )); } string_builder << word << " "; width += width_space; + oldwidth = width; } // push last line lines_to_draw.push_back( string_builder.str() );