diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index 978707b317..3fd82358e2 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -144,8 +144,7 @@ var Label = cc.Class({ notify: function () { var sgNode = this._sgNode; if (sgNode) { - //FIXME change this hack if _ccsg.Label.Overflow.NONE is implemented - sgNode.setOverflow( (this.overflow === _ccsg.Label.Overflow.NONE) ? _ccsg.Label.Overflow.CLAMP : this.overflow); + sgNode.setOverflow(this.overflow); } } }, diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js index 404afae8be..684c8705a7 100644 --- a/cocos2d/core/label/CCSGLabel.js +++ b/cocos2d/core/label/CCSGLabel.js @@ -1098,7 +1098,6 @@ _ccsg.Label.Type = cc.Enum({ SystemFont: 2 }); _ccsg.Label.Overflow = cc.Enum({ - //TODO: NONE is not implemented yet NONE: 0, CLAMP: 1, SHRINK: 2, diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js index 346bb295fc..2a889f1c2c 100644 --- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js @@ -250,6 +250,14 @@ fontDesc = this._drawFontsize.toString() + "px " + fontFamily; this._splitedStrings = paragraphedStrings; } + } else if(_ccsg.Label.Overflow.NONE == node._overFlow) { + this._splitedStrings = paragraphedStrings; + for (var i = 0; i < paragraphedStrings.length; ++i) { + var paraLength = ctx.measureText(paragraphedStrings[i]).width; + canvasSizeX = canvasSizeX > paraLength ? canvasSizeX : paraLength; + } + canvasSizeY = this._splitedStrings.length * this._getLineHeight(); + node.setContentSize(cc.size(canvasSizeX, canvasSizeY)); } else { //others treat it as clamp if (node._isWrapText) {