let name =
`这是需要竖排的文字内容,如果是yingwen的话则会旋转`
let x = this.canvasWidth - 110,
y = 50
let letterSpacing = 2
ctx.setFontSize(12)
for (let i = 0
const str = name.slice(i, i + 1).toString()
console.log(str)
if (y > this.canvasHeight - 60) {
y = 50
x -= 15
}
if (str.match(/[\u4E00-\u9FA5]/)) {
ctx.save()
ctx.textBaseline = 'top'
ctx.fillText(str, x, y)
ctx.restore()
y += ctx.measureText(str).width + letterSpacing
} else {
ctx.save()
ctx.translate(x, y)
ctx.rotate(Math.PI / 180 * 90)
ctx.textBaseline = 'bottom'
ctx.fillText(str, 0, 0)
ctx.restore()
y += ctx.measureText(str).width + letterSpacing
}
}
ctx.draw()