user1070642
user1070642

Reputation: 273

How to detect the auto line breaking in textarea

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

Answers (1)

Qorbani
Qorbani

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

Related Questions