Forums > MaxMSP

Text Formatting

July 2, 2014 | 9:38 am

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


July 2, 2014 | 9:40 am
– Pasted Max Patch, click to expand. –

July 2, 2014 | 1:05 pm

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.

– Pasted Max Patch, click to expand. –
Attachments:
  1. LineBreakerCD.js

July 2, 2014 | 3:30 pm

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.

`

– Pasted Max Patch, click to expand. –

July 2, 2014 | 3:46 pm

>> 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….


July 2, 2014 | 4:17 pm

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!!


July 4, 2014 | 10:45 am

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.


July 4, 2014 | 12:16 pm

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.


Viewing 8 posts - 1 through 8 (of 8 total)