Text on multiple lines in Pure Data

For my set for From Digbeth With Hammers at BOYD 8 I was required to display their logo on screen. This sounds like it should be a relatively easy task, but their logo consisting of four lines of text presented some interest problems.

From Digbeth With Hammers

In Pure Data there’s three objects you can use to display text on-screen: [text2d], [text3d] and [textextruded]. They have different ways of receiving text input, which I’ll get onto later, but one of the common methods that I often utilise in this scenario is by using a symbol box. In addition to receiving symbols Symbol boxes can be used to input text by just clicking on the box and typing text. Hitting Enter sends that text to its outlet. This presented a slight problem.

If you follow conventions from word-processing programs usually Enter is used to start a new line (carriage return). So, with Enter being used to send the text I had to find another solution to display text on multiple lines. Due to time contstraints I had to resort to the very messy solution of using multiple [text3d] objects.

Very messy!

This solution worked except for two things:

  • It isn’t scaleable. If I wanted to change the text by adding or removing lines I’d have to adjust the amount of text3d objects, change the spacing between each object and ensure that the size of the text still fitted on-screen. All of this is nearly impossible to do in a live setup unless you have a patient and forgiving audience!
  • It occasionally crashes. Occasionally when I would change the [depth( setting or move the whole text using [translateXYZ] the whole of Pure Data would crash. My suspicion is that the extra processing power needed to render and alter the text caused it to crash. Luckily this didn’t happen during my performance but it did result in me avoiding text manipulation.

So, what I needed was a way to insert carriage returns in Pure Data. I consulted the Pure Data mailing list and they informed me that [text3d] and [textextruded] accept ascii text as well. In ascii everything you see on-screen, from blank spaces to foreign characters and, most importantly, carriage returns, have a numerical value (10 is a carriage return). I was promptly provided a solution to my problem by typing out the band’s logo in ascii.

This worked except that, for every situation I wanted to have text, I would have to type out the text in ascii beforehand. I had no way to dynamically type out ascii. Even a suggested “asciifyer” abstraction suffered the same problem of not recognising Enter as a carriage return.

Awhile later Jonathan Wilkes showed me a solution that utilised [makefilename] to insert the carriage return! After a bit of modifying I finally had a patch that could have text on multiple lines using only one [text3d] object.

Click to download

And a video of it in action:

There still is, to my knowledge, no way of inserting a carriage return in Pure Data using only the keyboard. Also, this solution requires you to type of your text on three different symbol object boxes. Also, a space is added each time you add a new line, which is probably the result of using [add2 $1(. With that said, this solution is a step in the right direction!

Now if only I could go back in time and use it when I needed it…