text wrapping

demers's icon

demers

10月 24 2010 | 5:38 午後

Dear all,

Is there an efficient way to enable text wrapping in either jit.lcd or jit.gl.text2d? At the moment, any text entered remains on a single line. The jit.gl.text2d example patch shows a jit.noise object generating random values within defined dimensions, but I'm not sure how to carry that over into a straight text situation.

Also, for 'write [text]' and 'text [text]' messages, are there any symbols for paragraph marks, etc.?

Thanks for reading,

efe's icon

efe

10月 24 2010 | 7:30 午後

I am having the issue of lacking multiple lines with text2d, any idea what can be a solution?

demers's icon

demers

11月 28 2010 | 3:08 午前

Hello all,

No answer has been given on this. Is it a tough one to solve, or is the answer too obvious? Either way, if anyone has thoughts, I'm all ears - and still looking for a solution.

Samuel Freeman's icon

Samuel Freeman

11月 28 2010 | 10:59 午後

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

some moves towards a possible solution:

semiaddict's icon

semiaddict

2月 01 2012 | 9:43 午後

Hi,

I know this is an old post, but I'm wondering if anyone has gone further on this issue.

Thank you.

Wetterberg's icon

Wetterberg

2月 02 2012 | 8:02 午前

I hope this'll help - look at nov. 30th:

semiaddict's icon

semiaddict

2月 02 2012 | 3:22 午後

Thank you @Wetterberg.

I'm using Max/MSP 5.1.9, and getting the following error: "js: VerySpecialMessage.js: Javascript ReferenceError: select_font_face is not defined, line 86"

Do I need to install a library, or does this only work with Max/MSP 6 ?

Christopher Dobrian's icon

Christopher Dobrian

2月 03 2012 | 9:47 午後

If you want to wrap text to keep lines at or under a certain number of characters, and you want to be sure to break the line at a white space, here's a pretty simple algorithm. As you type (or as you scan through some text you want to display), keep track of the index of the most recent white space character (we'll call that index "lastspace"). When you get to the last character of the line, if the current character is a white space you can simply break there, but if the current character is not a white space then write only characters 0 through lastspace, go to a new line, and start the new line with characters lastspace+1 onward.

I'm attaching a JavaScript object I wrote a while back, and an example patch. It's a little different from just wrapping and displaying text. It simulates typing. I hope it proves to be of some use to you.

3304.scriptthattext.maxpat
Max Patch
11OLSEN's icon

11OLSEN

2月 03 2012 | 10:30 午後

maybe this is also interesting for you https://cycling74.com/forums/textarea-object
there's some text wrapping and even rewrapping going on..

semiaddict's icon

semiaddict

2月 04 2012 | 9:43 午前

Thank you @Dobrian & @11olsen. I'll look into those solutions and see what fits.

Rodrigo's icon

Rodrigo

1月 29 2018 | 9:25 午後

Don't know if it's the newer forum software, but I can't see the .js file in @Christopher's post. Can anyone re-upload it?

11OLSEN's icon

11OLSEN

1月 29 2018 | 10:19 午後

@RODRIGO

https://cycling74-web-assets.s3.amazonaws.com/bb-attachments/3303.LineBreakerCD.js

But I think the "counting chars" method is only useful with a monospace font. Other fonts have varying sizes of characters. (e.g. .......... __________ 10 dots are shorter than 10 underscores)

Rodrigo's icon

Rodrigo

1月 29 2018 | 11:10 午後

Thanks @Olsen!

I'll have a poke at it. I plan on using Helvetica, which isn't monospace, but doesn't vary too wildly.

I'll mainly try to get rid of the 30ms delay between each character though, as I primarily want to use this as a text wrapper that segments in whitespace only.

11OLSEN's icon

11OLSEN

1月 29 2018 | 11:40 午後

When I had to wrap text, i always used a jsui. You don't need to display the text with it. You can print the wrapped lines to an outlet if you want.
[my textarea link from above],
https://cycling74.com/forums/jsui-mgraphics-patch-a-day

Rodrigo's icon

Rodrigo

1月 30 2018 | 12:01 午前

I saw that while searching the forum and will have another look.

My specific use case will be projecting the text, so primarily using jit.gl.text2d

11OLSEN's icon

11OLSEN

1月 30 2018 | 1:01 午前

The line_length attribute of jit.gl.text2d does the wrapping at whitespaces.

Rodrigo's icon

Rodrigo

1月 30 2018 | 9:21 午前

Hah, well that makes my life much easier!

Thanks!!