in packages/core/src/text/paragraph.ts [162:184]
paint(canvas: Canvas, offset: Point, maxLineWidth: number) {
const { textAlign } = this.computedStyle
const shift: Mut<Point> = Point.clone(Point.zero)
for (const line of this.lines) {
if (textAlign === 'left') {
line.paint(canvas, offset)
if (DebugFlags.paintTextLineBounds) {
line.debugPaintBounds(canvas, offset)
}
} else {
if (textAlign === 'center') {
shift.x = (maxLineWidth - line.width) * 0.5
} else if (textAlign === 'right') {
shift.x = maxLineWidth - line.width
}
const shiftedOffset = Point.add(shift, offset)
line.paint(canvas, shiftedOffset)
if (DebugFlags.paintTextLineBounds) {
line.debugPaintBounds(canvas, shiftedOffset)
}
}
}
}