Browse Source

Fixed Font:getWidth and Font:getWrap to use kerning information.

Alex Szpakowski 10 years ago
parent
commit
ded2dc39ee
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/modules/graphics/opengl/Font.cpp

+ 5 - 1
src/modules/graphics/opengl/Font.cpp

@@ -636,13 +636,17 @@ int Font::getWidth(const std::string &str)
 		int width = 0;
 		int width = 0;
 		try
 		try
 		{
 		{
+			uint32 prevglyph = 0;
+
 			utf8::iterator<std::string::const_iterator> i(line.begin(), line.begin(), line.end());
 			utf8::iterator<std::string::const_iterator> i(line.begin(), line.begin(), line.end());
 			utf8::iterator<std::string::const_iterator> end(line.end(), line.begin(), line.end());
 			utf8::iterator<std::string::const_iterator> end(line.end(), line.begin(), line.end());
 			while (i != end)
 			while (i != end)
 			{
 			{
 				uint32 c = *i++;
 				uint32 c = *i++;
 				const Glyph &g = findGlyph(c);
 				const Glyph &g = findGlyph(c);
-				width += g.spacing;
+				width += g.spacing + getKerning(prevglyph, c);
+
+				prevglyph = c;
 			}
 			}
 		}
 		}
 		catch(utf8::exception &e)
 		catch(utf8::exception &e)