@@ -96,6 +96,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
96
96
97
97
_lineHeight : 0 ,
98
98
99
+ //for web
100
+ _fontStyle : "normal" ,
101
+ _fontWeight : "normal" ,
102
+
99
103
/**
100
104
* Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself,
101
105
* you should pass the correct arguments in constructor to initialize the label.
@@ -126,7 +130,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
126
130
this . _vAlignment = vAlignment ;
127
131
128
132
this . _fontSize = fontSize ;
129
- this . _renderCmd . _setFontStyle ( this . _fontName , fontSize ) ;
133
+ this . _renderCmd . _setFontStyle ( this . _fontName , fontSize , this . _fontStyle , this . _fontWeight ) ;
130
134
this . string = strInfo ;
131
135
this . _renderCmd . _setColorsString ( ) ;
132
136
this . _renderCmd . _updateTexture ( ) ;
@@ -500,7 +504,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
500
504
501
505
this . _fontName = textDefinition . fontName ;
502
506
this . _fontSize = textDefinition . fontSize || 12 ;
503
- this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize )
507
+ this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize , this . _fontStyle , this . _fontWeight ) ;
504
508
505
509
// shadow
506
510
if ( textDefinition . shadowEnabled )
@@ -666,7 +670,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
666
670
setFontSize : function ( fontSize ) {
667
671
if ( this . _fontSize !== fontSize ) {
668
672
this . _fontSize = fontSize ;
669
- this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize ) ;
673
+ this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize , this . _fontStyle , this . _fontWeight ) ;
670
674
// Force update
671
675
this . _setUpdateTextureDirty ( ) ;
672
676
}
@@ -679,7 +683,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
679
683
setFontName : function ( fontName ) {
680
684
if ( this . _fontName && this . _fontName != fontName ) {
681
685
this . _fontName = fontName ;
682
- this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize ) ;
686
+ this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize , this . _fontStyle , this . _fontWeight ) ;
683
687
// Force update
684
688
this . _setUpdateTextureDirty ( ) ;
685
689
}
@@ -693,7 +697,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
693
697
if ( res ) {
694
698
this . _fontSize = parseInt ( res [ 1 ] ) ;
695
699
this . _fontName = res [ 2 ] ;
696
- this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize ) ;
700
+ this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize , this . _fontStyle , this . _fontWeight ) ;
697
701
698
702
// Force update
699
703
this . _setUpdateTextureDirty ( ) ;
@@ -731,6 +735,31 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
731
735
return new cc . LabelTTF . CanvasRenderCmd ( this ) ;
732
736
else
733
737
return new cc . LabelTTF . WebGLRenderCmd ( this ) ;
738
+ } ,
739
+
740
+ //For web only
741
+ _setFontStyle : function ( fontStyle ) {
742
+ if ( this . _fontStyle != fontStyle ) {
743
+ this . _fontStyle = fontStyle ;
744
+ this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize , this . _fontStyle , this . _fontWeight ) ;
745
+ this . _setUpdateTextureDirty ( ) ;
746
+ }
747
+ } ,
748
+
749
+ _getFontStyle : function ( ) {
750
+ return this . _fontStyle ;
751
+ } ,
752
+
753
+ _setFontWeight : function ( fontWeight ) {
754
+ if ( this . _fontWeight != fontWeight ) {
755
+ this . _fontWeight = fontWeight ;
756
+ this . _renderCmd . _setFontStyle ( this . _fontName , this . _fontSize , this . _fontStyle , this . _fontWeight ) ;
757
+ this . _setUpdateTextureDirty ( ) ;
758
+ }
759
+ } ,
760
+
761
+ _getFontWeight : function ( ) {
762
+ return this . _fontWeight ;
734
763
}
735
764
} ) ;
736
765
0 commit comments