Skip to content

文本

PropertyDescriptionTypeRequiredDefault
width宽度numbertrue0
height高度numbertrue0
fill文字颜色stringfalse-
texttext contentstringtrue''
fontFamilyfont familystringfalsesystem-ui
fontWeightfont weightstringfalsenormal
fontSizefont sizenumberfalse12
underlineTODObooleanfalsefalse
overlineTODObooleanfalsefalse
linethroughTODObooleanfalsefalse
fontStylefont stylenormal | italic | obliquefalsenormal
lineHeightline height for the textnumberfalse14
charSpacingcharacter spacing for textnumberfalse0
directiontext directionltr | rtlfalseltr
lineClampmaximum number of lines to display, if overflow and value is Greater than zero, ellipsis will be displayednumberfalse0
textAligntext aligncenter | end | left | right | startfalseleft
textBaselinetext baselinealphabetic | bottom | hanging | ideographic | middle | topfalsetop

示例

Source Code
js
const rubbing = new Rubbing({
  selector: '#canvas',
  background: '#fff',
  width: 300,
  height: 100,
})
await rubbing.init()
rubbing.loadFrom({
  objects: [
    {
      type: 'text',
      text: '🎉 Rubbing!',
      left: 0,
      top: 50,
      fontSize: 16,
      fill: '#7c3aed',
      width: 300,
      textAlign: 'center',
    },
  ],
})