OSDN Git Service

Fix wrapped bounds calculation
authorJustin Shapcott <support@mobidevelop.com>
Mon, 19 Aug 2013 19:33:18 +0000 (12:33 -0700)
committerJustin Shapcott <support@mobidevelop.com>
Mon, 19 Aug 2013 19:33:18 +0000 (12:33 -0700)
gdx/src/com/badlogic/gdx/graphics/g2d/BitmapFont.java

index ad45b64..e9eab6e 100644 (file)
@@ -387,7 +387,7 @@ public class BitmapFont implements Disposable {
                        start = nextStart;\r
                        numLines++;\r
                }\r
-               textBounds.width = maxWidth * data.scaleX;\r
+               textBounds.width = maxWidth;\r
                textBounds.height = data.capHeight + (numLines - 1) * data.lineHeight;\r
                return textBounds;\r
        }\r
@@ -447,29 +447,14 @@ public class BitmapFont implements Disposable {
                Glyph lastGlyph = null;\r
                availableWidth /= data.scaleX;\r
 \r
-               if (data.scaleX == 1) {\r
-                       for (; index < end; index++) {\r
-                               char ch = str.charAt(index);\r
-                               Glyph g = data.getGlyph(ch);\r
-                               if (g != null) {\r
-                                       if (lastGlyph != null) width += lastGlyph.getKerning(ch);\r
-                                       if ((width + g.xadvance) - availableWidth > 0.001f) break;\r
-                                       width += g.xadvance;\r
-                                       lastGlyph = g;\r
-                               }\r
-                       }\r
-               } else {\r
-                       float scaleX = this.data.scaleX;\r
-                       for (; index < end; index++) {\r
-                               char ch = str.charAt(index);\r
-                               Glyph g = data.getGlyph(ch);\r
-                               if (g != null) {\r
-                                       if (lastGlyph != null) width += lastGlyph.getKerning(ch) * scaleX;\r
-                                       float xadvance = g.xadvance * scaleX;\r
-                                       if ((width + xadvance) - availableWidth > 0.001f) break;\r
-                                       width += xadvance;\r
-                                       lastGlyph = g;\r
-                               }\r
+               for (; index < end; index++) {\r
+                       char ch = str.charAt(index);\r
+                       Glyph g = data.getGlyph(ch);\r
+                       if (g != null) {\r
+                               if (lastGlyph != null) width += lastGlyph.getKerning(ch);\r
+                               if ((width + g.xadvance) - availableWidth > 0.001f) break;\r
+                               width += g.xadvance;\r
+                               lastGlyph = g;\r
                        }\r
                }\r
                return index - start;\r