@@ -200,7 +200,7 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
200
200
this . _fontName = fontName ;
201
201
this . _hAlignment = hAlignment ;
202
202
this . _vAlignment = vAlignment ;
203
- this . _fontSize = fontSize * cc . CONTENT_SCALE_FACTOR ( ) ;
203
+ this . _fontSize = fontSize ;
204
204
this . _fontStyleStr = this . _fontSize + "px '" + this . _fontName + "'" ;
205
205
this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( this . _fontName , this . _fontSize ) ;
206
206
this . setString ( strInfo ) ;
@@ -333,6 +333,7 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
333
333
this . _fontSize = textDefinition . fontSize ;
334
334
this . _fontStyleStr = this . _fontSize + "px '" + this . _fontName + "'" ;
335
335
336
+
336
337
// shadow
337
338
if ( textDefinition . shadowEnabled )
338
339
this . enableShadow ( textDefinition . shadowOffset , textDefinition . shadowOpacity , textDefinition . shadowBlur , false ) ;
@@ -566,8 +567,9 @@ cc.LabelTTFCanvas = cc.Sprite.extend(/** @lends cc.LabelTTFCanvas# */{
566
567
}
567
568
568
569
var locVAlignment = this . _vAlignment , locHAlignment = this . _hAlignment ,
569
- locContentSizeWidth = this . _contentSize . width , locContentSizeHeight = this . _contentSize . height ;
570
- var locFontHeight = this . _fontClientHeight ;
570
+ locContentSizeWidth = this . _contentSize . width * cc . CONTENT_SCALE_FACTOR ( ) ,
571
+ locContentSizeHeight = this . _contentSize . height * cc . CONTENT_SCALE_FACTOR ( ) ;
572
+ var locFontHeight = this . _fontClientHeight * cc . CONTENT_SCALE_FACTOR ( ) ;
571
573
572
574
context . textBaseline = cc . LabelTTF . _textBaseline [ locVAlignment ] ;
573
575
context . textAlign = cc . LabelTTF . _textAlign [ locHAlignment ] ;
@@ -670,6 +672,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
670
672
_string :"" ,
671
673
_isMultiLine :false ,
672
674
_fontStyleStr :null ,
675
+ _scaledFontStyleStr :null ,
673
676
_colorStyleStr :null ,
674
677
675
678
// font shadow
@@ -702,6 +705,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
702
705
this . _vAlignment = cc . VERTICAL_TEXT_ALIGNMENT_TOP ;
703
706
this . _opacityModifyRGB = false ;
704
707
this . _fontStyleStr = "" ;
708
+ this . _scaledFontStyleStr = "" ;
705
709
this . _colorStyleStr = "" ;
706
710
this . _fontName = "Arial" ;
707
711
this . _opacity = 255 ;
@@ -836,8 +840,9 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
836
840
this . _fontName = fontName ;
837
841
this . _hAlignment = hAlignment ;
838
842
this . _vAlignment = vAlignment ;
839
- this . _fontSize = fontSize * cc . CONTENT_SCALE_FACTOR ( ) ;
843
+ this . _fontSize = fontSize ;
840
844
this . _fontStyleStr = this . _fontSize + "px '" + this . _fontName + "'" ;
845
+ this . _scaledFontStyleStr = this . _fontSize * cc . CONTENT_SCALE_FACTOR ( ) + "px '" + this . _fontName + "'" ;
841
846
this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( this . _fontName , this . _fontSize ) ;
842
847
this . setString ( strInfo ) ;
843
848
this . _updateTexture ( ) ;
@@ -986,6 +991,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
986
991
this . _fontName = textDefinition . fontName ;
987
992
this . _fontSize = textDefinition . fontSize || 12 ;
988
993
this . _fontStyleStr = this . _fontSize + "px '" + this . _fontName + "'" ;
994
+ this . _scaledFontStyleStr = this . _fontSize * cc . CONTENT_SCALE_FACTOR ( ) + "px '" + this . _fontName + "'" ;
989
995
this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( this . _fontName , this . _fontSize ) ;
990
996
991
997
// shadow
@@ -1006,6 +1012,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
1006
1012
_prepareTextDefinition :function ( adjustForResolution ) {
1007
1013
var texDef = new cc . FontDefinition ( ) ;
1008
1014
1015
+ //Do these reference to CONTENT_SCALE_FACTOR need to be removed ?
1009
1016
if ( adjustForResolution ) {
1010
1017
texDef . fontSize = this . _fontSize * cc . CONTENT_SCALE_FACTOR ( ) ;
1011
1018
texDef . fontDimensions = cc . SIZE_POINTS_TO_PIXELS ( this . _dimensions ) ;
@@ -1107,6 +1114,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
1107
1114
if ( this . _fontSize != fontSize ) {
1108
1115
this . _fontSize = fontSize ;
1109
1116
this . _fontStyleStr = fontSize + "px '" + this . _fontName + "'" ;
1117
+ this . _scaledFontStyleStr = this . _fontSize * cc . CONTENT_SCALE_FACTOR ( ) + "px '" + this . _fontName + "'" ;
1110
1118
this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( this . _fontName , fontSize ) ;
1111
1119
// Force update
1112
1120
this . _needUpdateTexture = true ;
@@ -1121,6 +1129,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
1121
1129
if ( this . _fontName && this . _fontName != fontName ) {
1122
1130
this . _fontName = fontName ;
1123
1131
this . _fontStyleStr = this . _fontSize + "px '" + fontName + "'" ;
1132
+ this . _scaledFontStyleStr = this . _fontSize * cc . CONTENT_SCALE_FACTOR ( ) + "px '" + this . _fontName + "'" ;
1124
1133
this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( fontName , this . _fontSize ) ;
1125
1134
// Force update
1126
1135
this . _needUpdateTexture = true ;
@@ -1136,8 +1145,8 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
1136
1145
1137
1146
context . setTransform ( 1 , 0 , 0 , 1 , 0 , locContentSizeHeight ) ;
1138
1147
//this is fillText for canvas
1139
- if ( context . font != this . _fontStyleStr )
1140
- context . font = this . _fontStyleStr ;
1148
+ if ( context . font != this . _scaledFontStyleStr )
1149
+ context . font = this . _scaledFontStyleStr ;
1141
1150
context . fillStyle = this . _fillColorStr ;
1142
1151
1143
1152
//stroke style setup
@@ -1335,8 +1344,8 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
1335
1344
this . _labelContext . font = this . _fontStyleStr ;
1336
1345
this . _updateTTF ( ) ;
1337
1346
var width = this . _contentSize . width , height = this . _contentSize . height ;
1338
- this . _labelCanvas . width = width ;
1339
- this . _labelCanvas . height = height ;
1347
+ this . _labelCanvas . width = width * cc . CONTENT_SCALE_FACTOR ( ) ;
1348
+ this . _labelCanvas . height = height * cc . CONTENT_SCALE_FACTOR ( ) ; ;
1340
1349
1341
1350
//draw text to labelCanvas
1342
1351
this . _drawTTFInCanvasForWebGL ( this . _labelContext ) ;
0 commit comments