Reputation: 273
How can I get the textarea content as it is; i.e, How can i get text content with auto line breaking? I have to place the text as it is on the canvas.
Upvotes: 2
Views: 1058
Reputation: 5905
Unfortunately one issue with < canvas > tag is the lack of text-metrics support which ends to not supporting line breaking!
To simulate word-wrapping you need to loop through the singular words in your text (text.split(“ “)), and measuring each word individually until the edge of the bounding-box is hit, at which point a break is inserted, and the process continues.
For more detail information and also implementation guide, please take a look at this article:
I hope this helps :-)
Upvotes: 2