@@ -334,6 +334,7 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
334334 this . _fontName = textDefinition . fontName ;
335335 this . _fontSize = textDefinition . fontSize ;
336336 this . _fontStyleStr = this . _fontSize + "px '" + this . _fontName + "'" ;
337+ this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( this . _fontName , this . _fontSize ) ;
337338
338339 // shadow
339340 if ( textDefinition . shadowEnabled )
@@ -537,9 +538,8 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
537538 /**
538539 * renders the label
539540 * @param {CanvasRenderingContext2D|Null } ctx
540- * @param {Number } renderType
541541 */
542- draw :function ( ctx , renderType ) {
542+ draw :function ( ctx ) {
543543 var context = ctx || cc . renderContext ;
544544 if ( this . _flipX )
545545 context . scale ( - 1 , 1 ) ;
@@ -553,8 +553,9 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
553553 context . font = this . _fontStyleStr ;
554554
555555 //stroke style setup
556- if ( this . _strokeEnabled ) {
557- context . lineWidth = this . _strokeSize ;
556+ var locStrokeEnabled = this . _strokeEnabled ;
557+ if ( locStrokeEnabled ) {
558+ context . lineWidth = this . _strokeSize * 2 ;
558559 context . strokeStyle = this . _strokeColorStr ;
559560 }
560561
@@ -579,29 +580,34 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
579580 else if ( locHAlignment === cc . TEXT_ALIGNMENT_CENTER )
580581 xoffset = locContentSizeWidth / 2 ;
581582 if ( this . _isMultiLine ) {
583+ var locStrings = this . _strings ;
582584 var yOffset = 0 , strLen = this . _strings . length ;
583585 if ( locVAlignment === cc . VERTICAL_TEXT_ALIGNMENT_BOTTOM )
584586 yOffset = locFontHeight + locContentSizeHeight - locFontHeight * strLen ;
585587 else if ( locVAlignment === cc . VERTICAL_TEXT_ALIGNMENT_CENTER )
586588 yOffset = locFontHeight / 2 + ( locContentSizeHeight - locFontHeight * strLen ) / 2 ;
587589
590+ var tmpLineStr = null , tmpYOffset = null ;
588591 for ( var i = 0 ; i < strLen ; i ++ ) {
589- var line = this . _strings [ i ] ;
590- context . fillText ( line , xoffset , - locContentSizeHeight + ( locFontHeight * i ) + yOffset ) ;
592+ tmpLineStr = locStrings [ i ] ;
593+ tmpYOffset = - locContentSizeHeight + ( locFontHeight * i ) + yOffset ;
594+ if ( locStrokeEnabled )
595+ context . strokeText ( tmpLineStr , xoffset , tmpYOffset ) ;
596+ context . fillText ( tmpLineStr , xoffset , tmpYOffset ) ;
591597 }
592598 } else {
593599 if ( locVAlignment === cc . VERTICAL_TEXT_ALIGNMENT_BOTTOM ) {
594- context . fillText ( this . _string , xoffset , 0 ) ;
595- if ( this . _strokeEnabled )
600+ if ( locStrokeEnabled )
596601 context . strokeText ( this . _string , xoffset , 0 ) ;
602+ context . fillText ( this . _string , xoffset , 0 ) ;
597603 } else if ( locVAlignment === cc . VERTICAL_TEXT_ALIGNMENT_TOP ) {
598- context . fillText ( this . _string , xoffset , - locContentSizeHeight ) ;
599- if ( this . _strokeEnabled )
604+ if ( locStrokeEnabled )
600605 context . strokeText ( this . _string , xoffset , - locContentSizeHeight ) ;
606+ context . fillText ( this . _string , xoffset , - locContentSizeHeight ) ;
601607 } else {
602- context . fillText ( this . _string , xoffset , - locContentSizeHeight / 2 ) ;
603- if ( this . _strokeEnabled )
608+ if ( locStrokeEnabled )
604609 context . strokeText ( this . _string , xoffset , - locContentSizeHeight / 2 ) ;
610+ context . fillText ( this . _string , xoffset , - locContentSizeHeight / 2 ) ;
605611 }
606612 }
607613
@@ -1107,7 +1113,8 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
11071113 context . fillStyle = this . _fillColorStr ;
11081114
11091115 //stroke style setup
1110- if ( this . _strokeEnabled ) {
1116+ var locStrokeEnabled = this . _strokeEnabled ;
1117+ if ( locStrokeEnabled ) {
11111118 context . lineWidth = this . _strokeSize ;
11121119 context . strokeStyle = this . _strokeColorStr ;
11131120 }
@@ -1156,26 +1163,26 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
11561163 for ( var i = 0 ; i < locStrLen ; i ++ ) {
11571164 var line = this . _strings [ i ] ;
11581165 var tmpOffsetY = - locContentSizeHeight + ( locFontHeight * i ) + yOffset ;
1159- context . fillText ( line , xOffset , tmpOffsetY ) ;
1160- if ( this . _strokeEnabled )
1166+ if ( locStrokeEnabled )
11611167 context . strokeText ( line , xOffset , tmpOffsetY ) ;
1168+ context . fillText ( line , xOffset , tmpOffsetY ) ;
11621169 }
11631170 } else {
11641171 if ( locVAlignment === cc . VERTICAL_TEXT_ALIGNMENT_BOTTOM ) {
11651172 yOffset = isNegForOffsetY ? - locStrokeShadowOffsetY : 0 ;
1166- context . fillText ( this . _string , xOffset , yOffset ) ;
1167- if ( this . _strokeEnabled )
1173+ if ( locStrokeEnabled )
11681174 context . strokeText ( this . _string , xOffset , yOffset ) ;
1175+ context . fillText ( this . _string , xOffset , yOffset ) ;
11691176 } else if ( locVAlignment === cc . VERTICAL_TEXT_ALIGNMENT_TOP ) {
11701177 yOffset = isNegForOffsetY ? - locStrokeShadowOffsetY / 2 - locContentSizeHeight : - locContentSizeHeight + locStrokeShadowOffsetY / 2 ;
1171- context . fillText ( this . _string , xOffset , yOffset ) ;
1172- if ( this . _strokeEnabled )
1178+ if ( locStrokeEnabled )
11731179 context . strokeText ( this . _string , xOffset , yOffset ) ;
1180+ context . fillText ( this . _string , xOffset , yOffset ) ;
11741181 } else {
11751182 yOffset = isNegForOffsetY ? - locStrokeShadowOffsetY - locContentSizeHeight / 2 : - locContentSizeHeight / 2 ;
1176- context . fillText ( this . _string , xOffset , yOffset ) ;
1177- if ( this . _strokeEnabled )
1183+ if ( locStrokeEnabled )
11781184 context . strokeText ( this . _string , xOffset , yOffset ) ;
1185+ context . fillText ( this . _string , xOffset , yOffset ) ;
11791186 }
11801187 }
11811188 } ,
0 commit comments