You need to split the line and split each fragment separately with increasing y based on the font height.
For instance:
var lines = text.split("\n"),
x = 100, y = 100, fHeight = 16, // get x, y and proper font or line height here
i = 0, line;
while(line = lines[i++]) {
canvas.drawText(line, x, y, imgPaint);
y += fHeight;
}
source
share