mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #1613 from zilongshanren/add-font-family-support
add system font fontFamily support
This commit is contained in:
@@ -289,6 +289,21 @@ var Label = cc.Class({
|
||||
tooltip: CC_DEV && 'i18n:COMPONENT.label.font_size',
|
||||
},
|
||||
|
||||
/**
|
||||
* !#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',
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user