mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Merge pull request #1901 from knoxHuang/Fix_Label
Repair set ttf type font causes the outline to be lost for fireball/i…
This commit is contained in:
+26
-12
@@ -60,7 +60,7 @@ jsbLabel.prototype.getOverflow = function() {
|
||||
|
||||
jsbLabel.prototype._enableBold = jsbLabel.prototype.enableBold;
|
||||
jsbLabel.prototype.enableBold = function(enabled) {
|
||||
if(enabled) {
|
||||
if (enabled) {
|
||||
this._enableBold();
|
||||
} else {
|
||||
this.disableEffect(5);
|
||||
@@ -69,7 +69,7 @@ jsbLabel.prototype.enableBold = function(enabled) {
|
||||
|
||||
jsbLabel.prototype._enableItalics = jsbLabel.prototype.enableItalics;
|
||||
jsbLabel.prototype.enableItalics = function(enabled) {
|
||||
if(enabled) {
|
||||
if (enabled) {
|
||||
this._enableItalics();
|
||||
} else {
|
||||
this.disableEffect(4);
|
||||
@@ -78,7 +78,7 @@ jsbLabel.prototype.enableItalics = function(enabled) {
|
||||
|
||||
jsbLabel.prototype._enableUnderline = jsbLabel.prototype.enableUnderline;
|
||||
jsbLabel.prototype.enableUnderline = function(enabled) {
|
||||
if(enabled) {
|
||||
if (enabled) {
|
||||
this._enableUnderline();
|
||||
} else {
|
||||
this.disableEffect(6);
|
||||
@@ -117,7 +117,7 @@ jsbLabel.prototype.setLineHeight = function (height) {
|
||||
jsbLabel.prototype._setColor = jsbLabel.prototype.setColor;
|
||||
|
||||
jsbLabel.prototype.setColor = function(color) {
|
||||
if(this._labelType === _ccsg.Label.Type.BMFont) {
|
||||
if (this._labelType === _ccsg.Label.Type.BMFont) {
|
||||
this._setColor(color);
|
||||
} else {
|
||||
this.setTextColor(color);
|
||||
@@ -141,7 +141,7 @@ jsbLabel.prototype.setContentSize = function (size, height) {
|
||||
var newWidth = (typeof size.width === 'number') ? size.width : size;
|
||||
var newHeight = (typeof size.height === 'number') ? size.height : height;
|
||||
|
||||
if(this.getOverflow() === cc.Label.Overflow.NONE) {
|
||||
if (this.getOverflow() === cc.Label.Overflow.NONE) {
|
||||
newWidth = 0;
|
||||
newHeight = 0;
|
||||
} else {
|
||||
@@ -161,18 +161,22 @@ jsbLabel.prototype.setFontAsset = function (fontAsset) {
|
||||
var extName = cc.path.extname(fontHandle);
|
||||
|
||||
if (extName === '.ttf') {
|
||||
if(!this._ttfConfig) {
|
||||
var outlineWidth = this.isOutlined() ? this.getOutlineWidth() : 0;
|
||||
if (!this._ttfConfig) {
|
||||
this._ttfConfig = {
|
||||
fontFilePath: fontHandle,
|
||||
fontSize: this._fontSize,
|
||||
outlineSize: 0,
|
||||
outlineSize: outlineWidth,
|
||||
glyphs: 0,
|
||||
customGlyphs: "",
|
||||
distanceFieldEnable: false
|
||||
};
|
||||
}
|
||||
else {
|
||||
this._ttfConfig.outlineSize = outlineWidth;
|
||||
this._ttfConfig.fontFilePath = fontHandle;
|
||||
}
|
||||
this._labelType = _ccsg.Label.Type.TTF;
|
||||
this._ttfConfig.fontFilePath = fontHandle;
|
||||
this.setTTFConfig(this._ttfConfig);
|
||||
} else if (fontAsset.spriteFrame) {
|
||||
this._labelType = _ccsg.Label.Type.BMFont;
|
||||
@@ -194,7 +198,7 @@ jsbLabel.prototype.setFontFamily = function (fontFamily) {
|
||||
|
||||
jsbLabel.prototype.setOutlined = function(value) {
|
||||
this._outlined = !!value;
|
||||
if(this._outlined) {
|
||||
if (this._outlined) {
|
||||
this.enableOutline(this.getOutlineColor(), this.getOutlineWidth());
|
||||
} else {
|
||||
//1 equals cpp outline effect
|
||||
@@ -204,14 +208,24 @@ jsbLabel.prototype.setOutlined = function(value) {
|
||||
|
||||
jsbLabel.prototype.setOutlineWidth = function(value) {
|
||||
this._outlineWidth = value;
|
||||
if(this._outlined) {
|
||||
this.enableOutline(this.getOutlineColor(), this.getOutlineWidth());
|
||||
if (this._outlined) {
|
||||
var outlineWidth = this.getOutlineWidth();
|
||||
if (this._labelType === _ccsg.Label.Type.TTF) {
|
||||
var ttfConfig = this.getTTFConfig();
|
||||
if (ttfConfig.outlineSize !== outlineWidth) {
|
||||
ttfConfig.outlineSize = outlineWidth;
|
||||
this.setTTFConfig(ttfConfig);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.enableOutline(this.getOutlineColor(), outlineWidth);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jsbLabel.prototype.setOutlineColor = function(value) {
|
||||
this._outlineColor = cc.color(value);
|
||||
if(this._outlined) {
|
||||
if (this._outlined) {
|
||||
this.enableOutline(this.getOutlineColor(), this.getOutlineWidth());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user