Merge pull request #771 from zilongshanren/fixLabelResizeHeight

Fix label resize height
This commit is contained in:
Jare Guo
2016-06-06 18:41:46 +08:00
2 changed files with 10 additions and 1 deletions
+4 -1
View File
@@ -382,6 +382,9 @@ var Label = cc.Class({
sgNode.setString(this.string);
if (CC_EDITOR && this._useOriginalSize) {
this.node.setContentSize(sgNode.getContentSize());
if (this.font instanceof cc.BitmapFont) {
this.lineHeight = sgNode.getBMFontLineHeight();
}
this._useOriginalSize = false;
} else {
sgNode.setContentSize(this.node.getContentSize());
@@ -393,7 +396,7 @@ var Label = cc.Class({
_updateNodeSize: function () {
var initialized = this._sgNode && this._sgNode.parent;
if (initialized) {
if (this.overflow === Overflow.NONE) {
if (this.overflow === Overflow.NONE || this.overflow === Overflow.RESIZE_HEIGHT) {
this.node.setContentSize(this._sgNode.getContentSize());
}
}
+6
View File
@@ -343,6 +343,12 @@ _ccsg.Label = _ccsg.Node.extend({
return this._lineHeight;
},
getBMFontLineHeight : function() {
if(this._fontAtlas) {
return this._fontAtlas._lineHeight;
}
},
setFontFileOrFamily: function(fontHandle, textureUrl) {
fontHandle = fontHandle || "Arial";
var extName = cc.path.extname(fontHandle);