Hmm. I had experimented with adding anchor to the canvas.text calls but it didn't seem to have any effect, so I took this quote as explanation as to why. But it occurred to me now that it's still wrapping the rtext left-wise so maybe I've misunderstood what anchors do here.
Ifxis an rtext table andposis not a rectangle, the anchorais ignored, text is drawn top-left aligned, and lines are not automatically wrapped.
Here's the modified version I made.
EDIT: got it working. Fixed version below.