Text Formatting

visualaddicted's icon

Hello,

I'm trying to build an application that displays text from twitter over some footage. I need the text to be formatted in such a way that it is displayed over 5 sentences of the same size- character more character less.

I tried zl.slice, zl.group and an infinite series of methods but I always seems to fail. Now I have a pretty solid patch that split the text every 5 words to go to next line . The problem is that those 5 words could be very short or very long making the whole text looking weird.

Is anyone able to help me with this?
Thanks

visualaddicted's icon
Max Patch
Copy patch and select New From Clipboard in Max.
Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Rather than count words, it probably will work out better to count characters, and break the line at the index of the last white space character that is less than or equal to the maximum line length you want to allow. Download the attached JavaScript file and save it in the Max file search path, then try it out with this test patch.

LineBreakerCD.js
js
visualaddicted's icon

Hello Chris,

thanks for the quick reply..
that is something I tried to do as well (attachment) but after the second line there is interference in the slice object and everything gets messed up..

I'll try your method, the only thing is that I cannot download the JavaScript file- it opens the file in an external page but can't actually download it. Do you know how can I resolve this?

Thanks for your help.

Max Patch
Copy patch and select New From Clipboard in Max.

`

Christopher Dobrian's icon

>> I cannot download the JavaScript file- it opens the file in an external page but can’t actually download it. Do you know how can I resolve this?

Either a) open the link, then Save Page As..., or simply b) Right-Click (or Control-Click) on the link and choose Save Link As....

visualaddicted's icon

Ah !
Ok super cool, and I can also change the max number of character per line- currently 80 but I'll need it smaller. One last question then I'll leave to more important stuff :)

Do you have any idea on how to implement it with the jit.gltext3d object?
If I try to connect the one in my original patch at the start of this conversation nothing happen?
Not very familiar with JavaScript yet..sorry

thanks!!

Christopher Dobrian's icon

The writeslice() function (at the bottom) sends out messages that are designed to go to jit.lcd. You should just modify those to the appropriate messages to go to jit.gl.text3D instead.

visualaddicted's icon

No sure this is within my technical abilities yet. I tried to research a bit but without success.
Jit.text receives messages starting with "set blablablab" but I'm not sure how to implement that in the java script.
I also tried to adapt the patch to the LCD object but it doesn't really work either.

Do you have any more specific tips on how to modify the writeslice () to fit jit.gltext3d?

Thanks.