jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.27k stars 454 forks source link

Handling text wrapping in Two.Text #687

Closed joex92 closed 1 year ago

joex92 commented 1 year ago

Hi, I'm showing text on a SVG canvas, everything is fine, the only issue I'm having is when the text showing is too long. How do I handle that? I tried with a .wrap class, but that doesn't work:

tText.className = '.wrap';
.wrap {
  overflow-wrap: break-word; 
    width: 100vw;
    height: 100vh;
}

how can I wrap text?

it looks like this: image (just using example texts)

jonobr1 commented 1 year ago

This isn't supported out of the box in Two.js. But there is a great third-party library that allows you to do this: https://www.npmjs.com/package/twojs-multiline-text

joex92 commented 1 year ago

oh nice! I didn't know about that... thanks!