Skip to content
导航

Text ​

绘制文本。

关键属性 ​

width: number ​

Optional 宽度。

height: number ​

Optional 高度。

content: string ​

文本内容。

ts
import { Leafer, Rect } from 'leafer-ui'

const leafer = new Leafer({ view: window })

const text = new Text({
  fill: 'rgb(50,205,121)',
  content: 'Welcome to LeaferJS',
})

leafer.add(text)

fontFamily?: string ​

字体

fontSize?: number ​

文字大小

fontWeight?: IFontWeight ​

文字粗细

ts
type IFontWeight = IFontWeightNumerical | IFontWeightString

type IFontWeightNumerical = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

type IFontWeightString =
  | 'thin'
  | 'extra-light'
  | 'light'
  | 'normal'
  | 'medium'
  | 'semi-bold'
  | 'bold'
  | 'extra-bold'
  | 'black'

italic?: boolean ​

是否倾斜。

textCase?: ITextCase ​

文本大小写格式。

ts
type ITextCase =
  | 'upper'
  | 'lower'
  | 'title'
  | 'original'
  | 'small-caps'
  | 'small-caps-forced'

textDecoration?: ITextDecoration ​

文本下划线或删除线。

ts
type ITextDecoration = 'none' | 'strikethrough' | 'underline'

letterSpacing?: number | IPercent ​

字间距。

lineHeight?: number | IPercent ​

行间距。

paragraphIndent?: number ​

段落缩进字符数。

paragraphSpacing?: number ​

段落间距。

textAlign?: ITextAlign ​

文本对齐, 当设置了文本 width 时才有效。

ts
type ITextAlign = 'left' | 'center' | 'right' | 'justify'

verticalAlign?: IVerticalAlign ​

文本垂直对齐,当设置了文本 height 时才有效。

ts
type IVerticalAlign = 'top' | 'middle' | 'bottom'

继承 ​

UI ​

API ​

Text ​

Released under the MIT License.