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.
Asked
Active
Viewed 1,047 times
3
-
Does this help: http://stackoverflow.com/questions/4719777/finding-line-breaks-in-textarea-that-is-word-wrapping-arabic-text – Sudhir Bastakoti Jan 09 '12 at 05:25
1 Answers
2
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 :-)

Qorbani
- 5,825
- 2
- 39
- 47