# CanvasContext.setTextAlign(string align)

Start from base library version 1.1.0. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support

Set text alignment

# parameter

# string align

Alignment of text

align Legal value

value Introductions Minimum version
left to left justify
center centered alignment
right to right justify

# sample code

const ctx = wx.createCanvasContext('myCanvas')

ctx.setStrokeStyle('red')
ctx.moveTo(150, 20)
ctx.lineTo(150, 170)
ctx.stroke()

ctx.setFontSize(15)
ctx.setTextAlign('left')
ctx.fillText('textAlign=left', 150, 60)

ctx.setTextAlign('center')
ctx.fillText('textAlign=center', 150, 80)

ctx.setTextAlign('right')
ctx.fillText('textAlign=right', 150, 100)

ctx.draw()