easy way to make new lines in jit.gl.text2d

DJMATIC's icon

I'm sending a long piece of automatically generated text to jit.gl.text2d, to be displayed in a window.

For the life of me, I cannot figure out how to automatically wrap lines with a carriage return or similar. I'd like to wrap at the 60 or 80 character point.

I've read all the threads, and tried:
- using the text object (I can't seem to automatically insert cr's)
- using jit.textfile- but I can't see how it will help...

any ideas or help is much appreciated!

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

Compressed patch is as follows:

generalh's icon

Hello,
send the message read,bang to jit.textfile and connect it's first outlet to jit.gl.text2d
try several .txt from your own.
Cheers
Hubert

DJMATIC's icon

thanks for your kind reply. the jit.textfile read and bang doesn't do the trick,as I think this solution assumes I already have a text file formatted with CR's.

What I have is just a message box with a long text in it, and I'm trying to adds CR's to make the text display properly as multiple lines in jit.gl.text2d.

jit.textfile looks good, but I cannot figure out how to have it write and read new text twice a second.. and it seems like there might be more elegant way to do it?

I'm not a terrific Max programmer, but I have a pretty good handle on the basics. It strikes me as strange that there is no column limit or modifier to get automatic line feeds from jit.gl.text2d- or is there such a thing?

Thanks

Daniel

DJMATIC's icon

PS the message I am sending to jit.gl.text2d is dynamic- it's changing about twice a second.

llumen's icon

@DJMATIC

did you ever figure this out? I'm trying to do the same (sort of) having blocks of text draw in the render, but can't figure it out either

mattyo's icon

AFAIK, you can't do carriage returns in jit.gl.text2d. the workaround is to either use jit.lcd if that fits into your plan (you can move the pen as needed) or use multiple renders per bang as illustrated below. super-primitive here, but you should get the idea.

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

M

ericsoco's icon

oof. that's kind of a pain...if any cycling folks are here, this would be a great addition! specifically, jit.gl.text2d support for simple whitespace chars like n, t, etc. i'll add it to the bugs db as a feature request...

ericsoco's icon

scratch my last reply. found a solution here:
https://cycling74.com/forums/more-than-one-line-with-jit-gl-text2d

uses [jit.textfile], which stores text in a jitter matrix, and supports multiline. input via [textedit]. still feels a bit awkward, but it's not so bad and gets the job done.

for future reference...