@@ -48,7 +48,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
48
48
this . _status = [ ] ;
49
49
this . _renderingIndex = 0 ;
50
50
51
- this . _texRect = cc . rect ( ) ;
52
51
this . _canUseDirtyRegion = true ;
53
52
} ;
54
53
var proto = cc . LabelTTF . RenderCmd . prototype ;
@@ -104,8 +103,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
104
103
105
104
proto . _updateTTF = function ( ) {
106
105
var node = this . _node ;
107
- var pixelRatio = cc . view . getDevicePixelRatio ( ) ;
108
- var locDimensionsWidth = node . _dimensions . width * pixelRatio , i , strLength ;
106
+ var locDimensionsWidth = node . _dimensions . width , i , strLength ;
109
107
var locLineWidth = this . _lineWidths ;
110
108
locLineWidth . length = 0 ;
111
109
@@ -137,6 +135,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
137
135
locStrokeShadowOffsetY += Math . abs ( locOffsetSize . y ) * 2 ;
138
136
}
139
137
138
+ var pixelRatio = cc . view . getDevicePixelRatio ( ) ;
140
139
//get offset for stroke and shadow
141
140
if ( locDimensionsWidth === 0 ) {
142
141
if ( this . _isMultiLine )
@@ -167,16 +166,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
167
166
if ( node . _getFontStyle ( ) !== "normal" ) { //add width for 'italic' and 'oblique'
168
167
locSize . width = Math . ceil ( locSize . width + node . _fontSize * 0.3 ) ;
169
168
}
170
- if ( this . _strings . length === 0 ) {
171
- this . _texRect . width = 1 ;
172
- this . _texRect . height = locSize . height || 1 ;
173
- }
174
- else {
175
- this . _texRect . width = locSize . width ;
176
- this . _texRect . height = locSize . height ;
177
- }
178
- var nodeW = locSize . width / pixelRatio , nodeH = locSize . height / pixelRatio ;
179
- node . setContentSize ( nodeW , nodeH ) ;
169
+ node . setContentSize ( locSize ) ;
180
170
node . _strokeShadowOffsetX = locStrokeShadowOffsetX ;
181
171
node . _strokeShadowOffsetY = locStrokeShadowOffsetY ;
182
172
@@ -188,14 +178,13 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
188
178
189
179
proto . _saveStatus = function ( ) {
190
180
var node = this . _node ;
191
- var scale = cc . view . getDevicePixelRatio ( ) ;
192
181
var locStrokeShadowOffsetX = node . _strokeShadowOffsetX , locStrokeShadowOffsetY = node . _strokeShadowOffsetY ;
193
- var locContentSizeHeight = node . _contentSize . height * scale - locStrokeShadowOffsetY , locVAlignment = node . _vAlignment ,
182
+ var locContentSizeHeight = node . _contentSize . height - locStrokeShadowOffsetY , locVAlignment = node . _vAlignment ,
194
183
locHAlignment = node . _hAlignment ;
195
184
var dx = locStrokeShadowOffsetX * 0.5 ,
196
185
dy = locContentSizeHeight + locStrokeShadowOffsetY * 0.5 ;
197
186
var xOffset = 0 , yOffset = 0 , OffsetYArray = [ ] ;
198
- var locContentWidth = node . _contentSize . width * scale - locStrokeShadowOffsetX ;
187
+ var locContentWidth = node . _contentSize . width - locStrokeShadowOffsetX ;
199
188
200
189
//lineHeight
201
190
var lineHeight = node . getLineHeight ( ) * scale ;
@@ -322,6 +311,11 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
322
311
proto . updateStatus = function ( ) {
323
312
var flags = cc . Node . _dirtyFlags , locFlag = this . _dirtyFlag ;
324
313
314
+ < << << << HEAD
315
+ = === ===
316
+ cc . Node . RenderCmd . prototype . updateStatus . call ( this ) ;
317
+
318
+ > >>> >>> 45 cdfaa ... Revert "Fix UIText issue and Label getContentSize value wrong in retina mode"
325
319
if ( locFlag & flags . textDirty )
326
320
this . _updateTexture ( ) ;
327
321
@@ -335,7 +329,13 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
335
329
336
330
proto . _syncStatus = function ( parentCmd ) {
337
331
var flags = cc . Node . _dirtyFlags , locFlag = this . _dirtyFlag ;
332
+ < << << << HEAD
338
333
334
+ = === ===
335
+
336
+ cc . Node . RenderCmd . prototype . _syncStatus . call ( this , parentCmd ) ;
337
+
338
+ > >>> >>> 45 cdfaa ... Revert "Fix UIText issue and Label getContentSize value wrong in retina mode"
339
339
if ( locFlag & flags . textDirty )
340
340
this . _updateTexture ( ) ;
341
341
@@ -393,7 +393,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
393
393
locCanvas . width = 1 ;
394
394
locCanvas . height = 1 ;
395
395
this . _labelContext = locCanvas . getContext ( "2d" ) ;
396
- this . _texRect = cc . rect ( ) ;
397
396
} ;
398
397
399
398
cc . LabelTTF . CacheRenderCmd . prototype = Object . create ( cc . LabelTTF . RenderCmd . prototype ) ;
@@ -405,8 +404,9 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
405
404
proto . _updateTexture = function ( ) {
406
405
this . _dirtyFlag = this . _dirtyFlag & cc . Node . _dirtyFlags . textDirty ^ this . _dirtyFlag ;
407
406
var node = this . _node ;
407
+ var locContentSize = node . _contentSize ;
408
408
this . _updateTTF ( ) ;
409
- var width = this . _texRect . width , height = this . _texRect . height ;
409
+ var width = locContentSize . width , height = locContentSize . height ;
410
410
411
411
var locContext = this . _labelContext , locLabelCanvas = this . _labelCanvas ;
412
412
@@ -417,24 +417,24 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
417
417
}
418
418
419
419
if ( node . _string . length === 0 ) {
420
- locLabelCanvas . width = width ;
421
- locLabelCanvas . height = height ;
420
+ locLabelCanvas . width = 1 ;
421
+ locLabelCanvas . height = locContentSize . height || 1 ;
422
422
node . _texture && node . _texture . handleLoadedTexture ( ) ;
423
- node . setTextureRect ( this . _texRect ) ;
423
+ node . setTextureRect ( cc . rect ( 0 , 0 , 1 , locContentSize . height ) ) ;
424
424
return true ;
425
425
}
426
426
427
427
//set size for labelCanvas
428
428
locContext . font = this . _fontStyleStr ;
429
429
430
430
var flag = locLabelCanvas . width === width && locLabelCanvas . height === height ;
431
- locLabelCanvas . width = this . _texRect . width ;
432
- locLabelCanvas . height = this . _texRect . height ;
431
+ locLabelCanvas . width = width ;
432
+ locLabelCanvas . height = height ;
433
433
if ( flag ) locContext . clearRect ( 0 , 0 , width , height ) ;
434
434
this . _saveStatus ( ) ;
435
435
this . _drawTTFInCanvas ( locContext ) ;
436
436
node . _texture && node . _texture . handleLoadedTexture ( ) ;
437
- node . setTextureRect ( this . _texRect ) ;
437
+ node . setTextureRect ( cc . rect ( 0 , 0 , width , height ) ) ;
438
438
return true ;
439
439
} ;
440
440
@@ -482,14 +482,15 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
482
482
proto . _updateTexture = function ( ) {
483
483
this . _dirtyFlag = this . _dirtyFlag & cc . Node . _dirtyFlags . textDirty ^ this . _dirtyFlag ;
484
484
var node = this . _node ;
485
- var scale = cc . view . getDevicePixelRatio ( ) ;
485
+ var locContentSize = node . _contentSize ;
486
486
this . _updateTTF ( ) ;
487
+ var width = locContentSize . width , height = locContentSize . height ;
487
488
if ( node . _string . length === 0 ) {
488
- node . setTextureRect ( this . _texRect ) ;
489
+ node . setTextureRect ( cc . rect ( 0 , 0 , 1 , locContentSize . height ) ) ;
489
490
return true ;
490
491
}
491
492
this . _saveStatus ( ) ;
492
- node . setTextureRect ( this . _texRect ) ;
493
+ node . setTextureRect ( cc . rect ( 0 , 0 , width , height ) ) ;
493
494
return true ;
494
495
} ;
495
496
0 commit comments