@@ -100,12 +100,22 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
100100 }
101101 } ,
102102
103- _createTitleRendererIfNeeded : function ( ) {
103+ _createTitleRendererIfNeeded : function ( fntFile ) {
104104 if ( ! this . _titleRenderer ) {
105- this . _titleRenderer = new cc . LabelTTF ( "" ) ;
106- this . _titleRenderer . setAnchorPoint ( 0.5 , 0.5 ) ;
105+ if ( fntFile != null )
106+ {
107+ this . _titleRenderer = new cc . LabelBMFont ( "" , fntFile ) ;
108+ this . _titleRenderer . setAlignment ( cc . TEXT_ALIGNMENT_CENTER ) ;
109+ }
110+ else
111+ {
112+ this . _titleRenderer = new cc . LabelTTF ( "" ) ;
113+ this . _titleRenderer . setVerticalAlignment ( cc . VERTICAL_TEXT_ALIGNMENT_CENTER ) ;
114+ }
115+
116+ this . _titleRenderer . setAnchorPoint ( 0.5 , 0.4 ) ;
107117 this . _titleColor = cc . color . WHITE ;
108- this . _titleRenderer . setVerticalAlignment ( cc . VERTICAL_TEXT_ALIGNMENT_CENTER ) ;
118+
109119 this . addProtectedChild ( this . _titleRenderer , ccui . Button . TITLE_RENDERER_ZORDER , - 1 ) ;
110120 }
111121 } ,
@@ -657,7 +667,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
657667 setTitleFontSize : function ( size ) {
658668 this . _createTitleRendererIfNeeded ( ) ;
659669
660- this . _titleRenderer . setFontSize ( size ) ;
670+ if ( this . _titleRenderer . setFontSize )
671+ this . _titleRenderer . setFontSize ( size ) ;
672+ else
673+ this . _titleRenderer . setBoundingWidth ( size ) ;
674+
661675 this . _fontSize = size ;
662676 } ,
663677
@@ -705,9 +719,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
705719 * @param {String } fontName
706720 */
707721 setTitleFontName : function ( fontName ) {
708- this . _createTitleRendererIfNeeded ( ) ;
722+ this . _createTitleRendererIfNeeded ( fontName ) ;
709723
710- this . _titleRenderer . setFontName ( fontName ) ;
724+ this . _titleRenderer . setFontName && this . _titleRenderer . setFontName ( fontName ) ;
711725 this . _fontName = fontName ;
712726 } ,
713727
0 commit comments