@@ -728,34 +728,40 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
728728 return this . _labelContext ;
729729 } ,
730730
731- _updateTTF :function ( ) {
731+ _updateTTF : function ( ) {
732732 var locDimensionsWidth = this . _dimensions . width ;
733733 this . _lineWidths = [ ] ;
734734
735735 this . _isMultiLine = false ;
736- if ( locDimensionsWidth !== 0 ) {
736+ if ( locDimensionsWidth !== 0 ) {
737737 // Content processing
738738 this . _measureConfig ( ) ;
739739 var text = this . _string ;
740740
741741 this . _strings = [ ] ;
742- for ( var i = 0 , length = this . _string . length ; i < length ; ) {
742+ for ( var i = 0 , length = this . _string . length ; i < length ; ) {
743743 // Find the index of next line
744744 var next = this . _checkNextline ( text . substr ( i ) , locDimensionsWidth ) ;
745745 var append = text . substr ( i , next ) ;
746746
747- this . _lineWidths . push ( this . _measure ( append ) ) ;
748747 this . _strings . push ( append ) ;
749748 i += next ;
750749 }
751- if ( this . _strings . length > 0 )
752- this . _isMultiLine = true ;
750+ }
751+ else {
752+ this . _strings = this . _string . split ( '\n' ) ;
753+ for ( var i = 0 , length = this . _strings . length ; i < length ; i ++ ) {
754+ this . _lineWidths . push ( this . _measure ( this . _strings [ i ] ) ) ;
755+ }
753756 }
754757
758+ if ( this . _strings . length > 0 )
759+ this . _isMultiLine = true ;
760+
755761 var locSize , locStrokeShadowOffsetX = 0 , locStrokeShadowOffsetY = 0 ;
756- if ( this . _strokeEnabled )
762+ if ( this . _strokeEnabled )
757763 locStrokeShadowOffsetX = locStrokeShadowOffsetY = this . _strokeSize * 2 ;
758- if ( this . _shadowEnabled ) {
764+ if ( this . _shadowEnabled ) {
759765 var locOffsetSize = this . _shadowOffset ;
760766 locStrokeShadowOffsetX += Math . abs ( locOffsetSize . width ) * 2 ;
761767 locStrokeShadowOffsetY += Math . abs ( locOffsetSize . height ) * 2 ;
@@ -769,7 +775,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
769775 else
770776 locSize = cc . size ( 0 | ( this . _measure ( this . _string ) + locStrokeShadowOffsetX ) , 0 | ( this . _fontClientHeight + locStrokeShadowOffsetY ) ) ;
771777 } else {
772- if ( this . _dimensions . height === 0 ) {
778+ if ( this . _dimensions . height === 0 ) {
773779 if ( this . _isMultiLine )
774780 locSize = cc . size ( 0 | ( locDimensionsWidth + locStrokeShadowOffsetX ) , 0 | ( ( this . _fontClientHeight * this . _strings . length ) + locStrokeShadowOffsetY ) ) ;
775781 else
0 commit comments