浏览代码

Fix text alignment in GUI

David Catuhe 8 年之前
父节点
当前提交
1971dd8ac8

+ 2 - 2
dist/preview release/gui/babylon.gui.js

@@ -2468,12 +2468,12 @@ var BABYLON;
                     var width = this._currentMeasure.width;
                     var lineWidth = 0;
                     for (var n = 0; n < words.length; n++) {
-                        var testLine = line + words[n] + ' ';
+                        var testLine = n > 0 ? line + " " + words[n] : words[0];
                         var metrics = context.measureText(testLine);
                         var testWidth = metrics.width;
                         if (testWidth > width && n > 0) {
                             this._lines.push({ text: line, width: lineWidth });
-                            line = words[n] + ' ';
+                            line = words[n];
                             lineWidth = context.measureText(line).width;
                         }
                         else {

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


+ 2 - 2
gui/src/controls/textBlock.ts

@@ -108,12 +108,12 @@ module BABYLON.GUI {
                 var lineWidth = 0;
 
                 for(var n = 0; n < words.length; n++) {
-                    var testLine = line + words[n] + ' ';
+                    var testLine = n > 0 ? line + " " + words[n] : words[0];
                     var metrics = context.measureText(testLine);
                     var testWidth = metrics.width;
                     if (testWidth > width && n > 0) {
                         this._lines.push({text: line, width: lineWidth});
-                        line = words[n] + ' ';
+                        line = words[n];
                         lineWidth = context.measureText(line).width;
                     }
                     else {