3

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.

sawa
  • 165,429
  • 45
  • 277
  • 381
user1070642
  • 273
  • 1
  • 5
  • 15

1 Answers1

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