From 9f7f1d48f3f1d9c9019e70e4bc6213c366415283 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 24 Apr 2017 16:46:57 +0800 Subject: [PATCH 1/3] add system font fontFamily support --- cocos2d/core/components/CCLabel.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index 1b8d25694f..743bce4d6f 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -289,6 +289,21 @@ var Label = cc.Class({ tooltip: CC_DEV && 'i18n:COMPONENT.label.font_size', }, + /** + * !#en Font family of label. + * !#zh 文本字体名称。 + * @property {String} fontFamily + */ + fontFamily: { + default: "Arial", + tooltip: 'i18n:COMPONENT.label.font_family', + notify: function () { + if (this._sgNode) { + this._sgNode.setFontFileOrFamily(this.fontFamily); + } + } + }, + _lineHeight: 40, /** * !#en Line Height of label. @@ -444,7 +459,7 @@ var Label = cc.Class({ if (value) { this.font = null; if (this._sgNode) { - this._sgNode.setFontFileOrFamily('Arial'); + this._sgNode.setFontFileOrFamily(this.fontFamily); } } @@ -544,6 +559,9 @@ var Label = cc.Class({ sgNode.setHorizontalAlign( this.horizontalAlign ); sgNode.setVerticalAlign( this.verticalAlign ); sgNode.setFontSize( this._fontSize ); + if (this.useSystemFont) { + sgNode.setFontFileOrFamily(this.fontFamily); + } sgNode.setOverflow( this.overflow ); sgNode.enableWrapText( this._enableWrapText ); sgNode.setLineHeight(this._lineHeight); From 6b121a2be5ed24b7f9d4ff80fa43a3f6af118814 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 24 Apr 2017 17:32:15 +0800 Subject: [PATCH 2/3] improve fontFamily property --- cocos2d/core/components/CCLabel.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index 743bce4d6f..a8c6efc91b 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -290,13 +290,16 @@ var Label = cc.Class({ }, /** - * !#en Font family of label. - * !#zh 文本字体名称。 + * !#en Font family of label, only take effect when useSystemFont property is true. + * !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 * @property {String} fontFamily */ fontFamily: { default: "Arial", tooltip: 'i18n:COMPONENT.label.font_family', + visible : function () { + return this.useSystemFont; + }, notify: function () { if (this._sgNode) { this._sgNode.setFontFileOrFamily(this.fontFamily); From 31eee86bcd6ebfb2bd0324a0fff9211f5dc58fee Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 24 Apr 2017 17:43:33 +0800 Subject: [PATCH 3/3] remove visible property --- cocos2d/core/components/CCLabel.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index a8c6efc91b..96aea833e2 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -297,9 +297,6 @@ var Label = cc.Class({ fontFamily: { default: "Arial", tooltip: 'i18n:COMPONENT.label.font_family', - visible : function () { - return this.useSystemFont; - }, notify: function () { if (this._sgNode) { this._sgNode.setFontFileOrFamily(this.fontFamily);