类名 Font

# new Font(options)

字体样式,参考示例:[字体样式]

参数:

名称 类型 默认值 描述
options Object

构造参数

family String '微软雅黑'

字体名,推荐设置黑体、宋体、楷体、微软雅黑、Arial、Calibri、Times New Roman等。

size Number 9

字体大小,单位像素

style String 'normal'

字体样式, 可选"normal"|"italic"|"oblique"

weight String 'normal'

字体粗细, 可选"normal"|"bold"|"bolder"|"lighter"

decoration String 'none'

文字装饰元素,默认为"none"。设置"underline"显示文字下划线,设置"line-through"显示文字删除线

支持如下方法:
[1、转换为json对象]
[2、克隆并返回一个新的LabelClass对象]
[3、将JSON里的数据导入,并返回一个新的LabelClass对象]

示例

创建字体样式

const font = new zondy.symbol.Font({
  // 字体
  family: "微软雅黑",
  // 文字大小,单位像素
  size: 30,
  // 文字是否为斜体,正常模式
  style: "normal",
  // 文字粗细
  weight: "normal"
})

成员变量

String

# decoration

文字装饰元素,默认为"none"。设置"underline"显示文字下划线,设置"line-through"显示文字删除线

Default Value:
  • 'none'
String

# family

字体名

Default Value:
  • 微软雅黑
Number

# size

字体大小

Default Value:
  • 12
String

# style

字体样式

Default Value:
  • normal
String

# weight

字体粗细

Default Value:
  • normal

方法

# static fromJSON(jsonopt)

将JSON里的数据导入,并返回一个新的Font对象

参数:

名称 类型 描述
json Object

新的Font对象

新的Font对象

Font

# clone()

克隆并返回一个新的Font对象

Font对象

Font

# toJSON()

转换为json对象

Font对象

Font
构造函数
成员变量
方法
事件