Browse Source

Mostly fixed the center and right wrap alignments for love.graphics.printf.

Alex Szpakowski 9 years ago
parent
commit
396b0f0956
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/modules/graphics/opengl/Font.cpp

+ 6 - 0
src/modules/graphics/opengl/Font.cpp

@@ -698,6 +698,7 @@ void Font::getWrap(const std::string &text, float wraplimit, std::vector<Codepoi
 	while (std::getline(iss, line, '\n'))
 	while (std::getline(iss, line, '\n'))
 	{
 	{
 		float width = 0.0f;
 		float width = 0.0f;
+		float widthatlastspace = 0.0f;
 		uint32 prevglyph = 0;
 		uint32 prevglyph = 0;
 
 
 		wline.clear();
 		wline.clear();
@@ -732,6 +733,8 @@ void Font::getWrap(const std::string &text, float wraplimit, std::vector<Codepoi
 						while (!wline.empty() && wline.back() != ' ')
 						while (!wline.empty() && wline.back() != ' ')
 							wline.pop_back();
 							wline.pop_back();
 
 
+						width = widthatlastspace;
+
 						i = lastspaceit;
 						i = lastspaceit;
 						++i; // Start the next line after the space.
 						++i; // Start the next line after the space.
 					}
 					}
@@ -756,7 +759,10 @@ void Font::getWrap(const std::string &text, float wraplimit, std::vector<Codepoi
 				// Keep track of the last seen space, so we can "rewind" to it
 				// Keep track of the last seen space, so we can "rewind" to it
 				// when wrapping.
 				// when wrapping.
 				if (c == ' ')
 				if (c == ' ')
+				{
+					widthatlastspace = width;
 					lastspaceit = i;
 					lastspaceit = i;
+				}
 
 
 				++i;
 				++i;
 			}
 			}