remove useSystemFont from CCGLabel

This commit is contained in:
ViusualSJ
2016-05-20 15:28:51 +08:00
parent 4e555017a1
commit 306a61707a
3 changed files with 9 additions and 32 deletions
+9 -6
View File
@@ -245,7 +245,7 @@ var Label = cc.Class({
set: function (value) {
this._N$file = value;
this._bmFontOriginalSize = -1;
if (this._sgNode) {
if (this._sgNode && !this._isSystemFontUsed) {
if ( typeof value === 'string' ) {
cc.warn('Sorry, the cc.Font has been modified from Raw Asset to Asset.' +
@@ -276,18 +276,21 @@ var Label = cc.Class({
*/
useSystemFont: {
get: function(){
if (this._sgNode) {
this._isSystemFontUsed = this._sgNode.isSystemFontUsed();
}
return this._isSystemFontUsed;
},
set: function(value){
this._isSystemFontUsed = value;
this._isSystemFontUsed = !!value;
if (value) {
this.font = null;
if (this._sgNode) {
this._sgNode.setSystemFontUsed(value);
this._sgNode.setFontFileOrFamily('Arial');
}
} else {
value = this._N$file;
var isAsset = value instanceof cc.Font;
var fntRawUrl = isAsset ? value.rawUrl : '';
var textureUrl = isAsset ? value.texture : '';
this._sgNode.setFontFileOrFamily(fntRawUrl, textureUrl);
}
},
-14
View File
@@ -115,7 +115,6 @@ _ccsg.Label = _ccsg.Node.extend({
_spacingX: 0,
_blendFunc: null,
_isUseSystemFont: true,
_labelType: 0, //0 is ttf, 1 is bmfont.
_fontHandle: "", //a ttf font name or a bmfont file path.
_lineSpacing: 0,
@@ -176,18 +175,7 @@ _ccsg.Label = _ccsg.Node.extend({
this._spriteBatchNode = null;
}
},
isSystemFontUsed: function() {
return this._isUseSystemFont;
},
setSystemFontUsed: function(value) {
if (this._isUseSystemFont === value) return;
if (value) {
this.setFontFileOrFamily("Arial");
}
this._isUseSystemFont = value;
},
setHorizontalAlign: function(align) {
if (this._hAlign === align) return;
this._hAlign = align;
@@ -359,12 +347,10 @@ _ccsg.Label = _ccsg.Node.extend({
this._fontHandle = fontHandle;
this._labelType = _ccsg.Label.Type.SystemFont;
this._notifyLabelSkinDirty();
this._isUseSystemFont = true;
this.emit('load');
return;
}
this._isUseSystemFont = false;
if (extName === ".ttf") {
this._labelType = _ccsg.Label.Type.TTF;
this._fontHandle = this._loadTTFFont(fontHandle);
-12
View File
@@ -58,18 +58,6 @@ jsbLabel.prototype.getOverflow = function() {
return this._overFlow;
};
if (!jsbLabel.prototype.isSystemFontUsed) {
jsbLabel.prototype.isSystemFontUsed = function() {
return this._isSystemFontUsed;
};
jsbLabel.prototype.setSystemFontUsed = function(value) {
this._isSystemFontUsed = value;
this.setSystemFontName("Arial");
this.setSystemFontSize(this.getFontSize());
}
}
jsbLabel.prototype.setFontSize = function (size) {
this._fontSize = size;
if (this._labelType === _ccsg.Label.Type.SystemFont) {