Closed Joncom closed 5 years ago
// Pre-patch: ig.game.font.widthForString('HELLO'); // 22
// Post-patch: ig.game.font.widthForString('HELLO'); // 21
diff --git a/lib/impact/font.js b/lib/impact/font.js index 638e91b..5d085c0 100644 --- a/lib/impact/font.js +++ b/lib/impact/font.js @@ -42,7 +42,10 @@ ig.Font = ig.Image.extend({ _widthForLine: function( text ) { var width = 0; for( var i = 0; i < text.length; i++ ) { - width += this.widthMap[text.charCodeAt(i) - this.firstChar] + this.letterSpacing; + width += this.widthMap[text.charCodeAt(i) - this.firstChar]; + } + if( text.length > 0 ) { + width += this.letterSpacing * (text.length - 1); } return width; },