/word-wrap

html5 canvas word wrap

word-wrap

html5 canvas word wrap

This bit of code takes a string of text, calculates its length using current styling, evaluates the length against a property (i've used the radius of a circle, but the code just treats it as the width of a rectangle - there didn't seem any point writing anything more sophisticated than this at this point), splits the text into lines and then displays the text line by line.

Please feel free to adapt, improve (lots needed!) as you see fit.

Let me know how you get on :)

Cheersphilip.