Hi,
this topic seems to come up frequently [1] and I am looking for a vanilla solution of rendering multiline text from a textfile in Gem's [text2d] object.
I can output multiple lines but text2d expects all text to be prefixed with either "text" or as list. Both seem unable to pass on linefeeds correctly, at least in my minimal working example (attached).
Anything I can try next? Thanks for all your ideas! best, Peter
[1] https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/thread/XUS657GKDCQ...
hello,
This patch use fudiformat to convert the text to ascii and various list object to concatenate all line and clean the ; and the end of the lines.
It is then rendered with the string message that allows the linefeeds.
cheers C
Le 28/01/2026 à 11:21, Peter P. a écrit :
Hi,
this topic seems to come up frequently [1] and I am looking for a vanilla solution of rendering multiline text from a textfile in Gem's [text2d] object.
I can output multiple lines but text2d expects all text to be prefixed with either "text" or as list. Both seem unable to pass on linefeeds correctly, at least in my minimal working example (attached).
Anything I can try next? Thanks for all your ideas! best, Peter
[1] https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/thread/XUS657GKDCQ...
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/2YHOGTFYK2...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
Hi Cyrille,
wow-that's impressive! Merci a lot for your patch and the insight!
Does this mean that text2d understands fudi? I can't see any conversion back from fudi.
best, Peter
hello,
This patch use fudiformat to convert the text to ascii and various list object to concatenate all line and clean the ; and the end of the lines.
It is then rendered with the string message that allows the linefeeds.
cheers C
Le 28/01/2026 à 11:21, Peter P. a écrit :
Hi,
this topic seems to come up frequently [1] and I am looking for a vanilla solution of rendering multiline text from a textfile in Gem's [text2d] object.
I can output multiple lines but text2d expects all text to be prefixed with either "text" or as list. Both seem unable to pass on linefeeds correctly, at least in my minimal working example (attached).
Anything I can try next? Thanks for all your ideas! best, Peter
[1] https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/thread/XUS657GKDCQ...
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/2YHOGTFYK2...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
#N canvas 907 166 572 694 12; #X declare -lib Gem; #X obj 37 69 gemhead; #X obj 161 236 textfile; #X obj 37 622 text2d; #X obj 229 13 declare -lib Gem; #X msg 195 53 create , 1; #X obj 195 80 gemwin; #X obj 161 203 until; #X msg 193 175 read multiline.txt cr , rewind; #X obj 161 122 bng 20 250 50 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000; #X obj 161 265 fudiformat; #X obj 161 515 list prepend string; #X obj 161 544 list trim; #X obj 161 449 list prepend; #X msg 382 289 list; #X obj 161 149 t b b b; #X obj 237 483 list; #X obj 161 386 list split 1; #X obj 242 327 list length; #X obj 242 354 - 2; #X obj 161 292 t l l; #X obj 161 416 list append 10; #X connect 0 0 2 0; #X connect 1 0 9 0; #X connect 1 1 6 1; #X connect 4 0 5 0; #X connect 6 0 1 0; #X connect 7 0 1 0; #X connect 8 0 14 0; #X connect 9 0 19 0; #X connect 10 0 11 0; #X connect 11 0 2 0; #X connect 12 0 15 0; #X connect 12 0 10 0; #X connect 13 0 12 1; #X connect 14 0 6 0; #X connect 14 1 7 0; #X connect 14 2 13 0; #X connect 15 0 12 1; #X connect 16 0 20 0; #X connect 17 0 18 0; #X connect 18 0 16 1; #X connect 19 0 16 0; #X connect 19 1 17 0; #X connect 20 0 12 0;
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/3LON4GBP4E...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
fudi is "just" ascii with a ; as the end. If you remove the ";", then you only have ascii...
cheers c
Le 28/01/2026 à 11:50, Peter P. a écrit :
Hi Cyrille,
wow-that's impressive! Merci a lot for your patch and the insight!
Does this mean that text2d understands fudi? I can't see any conversion back from fudi.
best, Peter
- cyrille henry via Pd-list pd-list@lists.iem.at [2026-01-28 11:40]:
hello,
This patch use fudiformat to convert the text to ascii and various list object to concatenate all line and clean the ; and the end of the lines.
It is then rendered with the string message that allows the linefeeds.
cheers C
Le 28/01/2026 à 11:21, Peter P. a écrit :
Hi,
this topic seems to come up frequently [1] and I am looking for a vanilla solution of rendering multiline text from a textfile in Gem's [text2d] object.
I can output multiple lines but text2d expects all text to be prefixed with either "text" or as list. Both seem unable to pass on linefeeds correctly, at least in my minimal working example (attached).
Anything I can try next? Thanks for all your ideas! best, Peter
[1] https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/thread/XUS657GKDCQ...
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/2YHOGTFYK2...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
#N canvas 907 166 572 694 12; #X declare -lib Gem; #X obj 37 69 gemhead; #X obj 161 236 textfile; #X obj 37 622 text2d; #X obj 229 13 declare -lib Gem; #X msg 195 53 create , 1; #X obj 195 80 gemwin; #X obj 161 203 until; #X msg 193 175 read multiline.txt cr , rewind; #X obj 161 122 bng 20 250 50 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000; #X obj 161 265 fudiformat; #X obj 161 515 list prepend string; #X obj 161 544 list trim; #X obj 161 449 list prepend; #X msg 382 289 list; #X obj 161 149 t b b b; #X obj 237 483 list; #X obj 161 386 list split 1; #X obj 242 327 list length; #X obj 242 354 - 2; #X obj 161 292 t l l; #X obj 161 416 list append 10; #X connect 0 0 2 0; #X connect 1 0 9 0; #X connect 1 1 6 1; #X connect 4 0 5 0; #X connect 6 0 1 0; #X connect 7 0 1 0; #X connect 8 0 14 0; #X connect 9 0 19 0; #X connect 10 0 11 0; #X connect 11 0 2 0; #X connect 12 0 15 0; #X connect 12 0 10 0; #X connect 13 0 12 1; #X connect 14 0 6 0; #X connect 14 1 7 0; #X connect 14 2 13 0; #X connect 15 0 12 1; #X connect 16 0 20 0; #X connect 17 0 18 0; #X connect 18 0 16 1; #X connect 19 0 16 0; #X connect 19 1 17 0; #X connect 20 0 12 0;
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/3LON4GBP4E...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/Y5TQ4ZSLIE...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
On 1/28/26 11:56, cyrille henry via Pd-list wrote:
fudi is "just" ascii with a ; as the end. If you remove the ";", then you only have ascii...
actually it is UTF-8.
which also explains the problem with peter's umlauts, because the [string( message expects unicode points and not UTF-8 bytes.
(see wikipedia for the gory details)
e.g. the german umlaut "ä" is assigned the unicode point '228'. so [text2d] expects a message like [string 228( to render the letter.
however in UTF-8, "ä" is encoded as two bytes '195 164'. since [fudiformat] just outputs bytes, you will get a message [string 195 164(, which will render as "ä" (unicode points 195 and 164).
at the PdCon09 in [string 83 227 111 32 80 97 117 108 111(, me an maira wrote a small vanilla library to convert between UTF-8 and unicodepoints. it's available on deken as "unicode".
cheers c
Le 28/01/2026 à 11:50, Peter P. a écrit :
Hi Cyrille,
wow-that's impressive! Merci a lot for your patch and the insight!
Does this mean that text2d understands fudi? I can't see any conversion back from fudi.
best, Peter
- cyrille henry via Pd-list pd-list@lists.iem.at [2026-01-28 11:40]:
hello,
This patch use fudiformat to convert the text to ascii and various list object to concatenate all line and clean the ; and the end of the lines.
It is then rendered with the string message that allows the linefeeds.
cheers C
Le 28/01/2026 à 11:21, Peter P. a écrit :
Hi,
this topic seems to come up frequently [1] and I am looking for a vanilla solution of rendering multiline text from a textfile in Gem's [text2d] object.
I can output multiple lines but text2d expects all text to be prefixed with either "text" or as list. Both seem unable to pass on linefeeds correctly, at least in my minimal working example (attached).
Anything I can try next? Thanks for all your ideas! best, Peter
[1] https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/ thread/XUS657GKDCQE3GUDIGZYA5U46K5365UL/
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/ message/2YHOGTFYK2TRDMJPR6PPRKEVQFWS7K5Y/
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
#N canvas 907 166 572 694 12; #X declare -lib Gem; #X obj 37 69 gemhead; #X obj 161 236 textfile; #X obj 37 622 text2d; #X obj 229 13 declare -lib Gem; #X msg 195 53 create , 1; #X obj 195 80 gemwin; #X obj 161 203 until; #X msg 193 175 read multiline.txt cr , rewind; #X obj 161 122 bng 20 250 50 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000; #X obj 161 265 fudiformat; #X obj 161 515 list prepend string; #X obj 161 544 list trim; #X obj 161 449 list prepend; #X msg 382 289 list; #X obj 161 149 t b b b; #X obj 237 483 list; #X obj 161 386 list split 1; #X obj 242 327 list length; #X obj 242 354 - 2; #X obj 161 292 t l l; #X obj 161 416 list append 10; #X connect 0 0 2 0; #X connect 1 0 9 0; #X connect 1 1 6 1; #X connect 4 0 5 0; #X connect 6 0 1 0; #X connect 7 0 1 0; #X connect 8 0 14 0; #X connect 9 0 19 0; #X connect 10 0 11 0; #X connect 11 0 2 0; #X connect 12 0 15 0; #X connect 12 0 10 0; #X connect 13 0 12 1; #X connect 14 0 6 0; #X connect 14 1 7 0; #X connect 14 2 13 0; #X connect 15 0 12 1; #X connect 16 0 20 0; #X connect 17 0 18 0; #X connect 18 0 16 1; #X connect 19 0 16 0; #X connect 19 1 17 0; #X connect 20 0 12 0;
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/ message/3LON4GBP4E7K5NMCPTT2CZA2TMACSPIO/
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/ Y5TQ4ZSLIETXZSGRGX3SOBSYLSE2P76Z/
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/ TTO4ON34RSJDE6O3YKKNN2PDIALVJLDU/
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
Replying to myself here:
It seems that german umlauts ä ü ö or french accents é è ê are not rendered when converted to FUDI. They render in [text2d] when sent with a simple [text üöä< message.
best, P
Hi Cyrille,
wow-that's impressive! Merci a lot for your patch and the insight!
Does this mean that text2d understands fudi? I can't see any conversion back from fudi.
best, Peter
- cyrille henry via Pd-list pd-list@lists.iem.at [2026-01-28 11:40]:
hello,
This patch use fudiformat to convert the text to ascii and various list object to concatenate all line and clean the ; and the end of the lines.
It is then rendered with the string message that allows the linefeeds.
cheers C
Le 28/01/2026 à 11:21, Peter P. a écrit :
Hi,
this topic seems to come up frequently [1] and I am looking for a vanilla solution of rendering multiline text from a textfile in Gem's [text2d] object.
I can output multiple lines but text2d expects all text to be prefixed with either "text" or as list. Both seem unable to pass on linefeeds correctly, at least in my minimal working example (attached).
Anything I can try next? Thanks for all your ideas! best, Peter
[1] https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/thread/XUS657GKDCQ...
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/2YHOGTFYK2...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
#N canvas 907 166 572 694 12; #X declare -lib Gem; #X obj 37 69 gemhead; #X obj 161 236 textfile; #X obj 37 622 text2d; #X obj 229 13 declare -lib Gem; #X msg 195 53 create , 1; #X obj 195 80 gemwin; #X obj 161 203 until; #X msg 193 175 read multiline.txt cr , rewind; #X obj 161 122 bng 20 250 50 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000; #X obj 161 265 fudiformat; #X obj 161 515 list prepend string; #X obj 161 544 list trim; #X obj 161 449 list prepend; #X msg 382 289 list; #X obj 161 149 t b b b; #X obj 237 483 list; #X obj 161 386 list split 1; #X obj 242 327 list length; #X obj 242 354 - 2; #X obj 161 292 t l l; #X obj 161 416 list append 10; #X connect 0 0 2 0; #X connect 1 0 9 0; #X connect 1 1 6 1; #X connect 4 0 5 0; #X connect 6 0 1 0; #X connect 7 0 1 0; #X connect 8 0 14 0; #X connect 9 0 19 0; #X connect 10 0 11 0; #X connect 11 0 2 0; #X connect 12 0 15 0; #X connect 12 0 10 0; #X connect 13 0 12 1; #X connect 14 0 6 0; #X connect 14 1 7 0; #X connect 14 2 13 0; #X connect 15 0 12 1; #X connect 16 0 20 0; #X connect 17 0 18 0; #X connect 18 0 16 1; #X connect 19 0 16 0; #X connect 19 1 17 0; #X connect 20 0 12 0;
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/3LON4GBP4E...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
On 1/28/26 11:50, Peter P. wrote:
Hi Cyrille,
wow-that's impressive! Merci a lot for your patch and the insight!
Does this mean that text2d understands fudi? I can't see any conversion back from fudi.
it doesn't understand FUDI. however, you can send it a list of unicode-points via the "string" message, e.g. [string 112 56 116 101 114(
if it encounters a linefeed (ascii: 10), it will break the line: [string 108 228 116 101 114 10 112 56 116 101 114(
you can also use the normal [text( (or [list() messsage and add a "\n" manually (e.g. generated with [makefilename %c]).
like in the attached patch.
gdasmr IOhannes
On Wed, Jan 28, 2026 at 12:10 PM IOhannes m zmoelnig via Pd-list pd-list@lists.iem.at wrote:
like in the attached patch.
this is really cool - thanks for the contributions and inspiration, cyrille and iohannes! with left-aligned text, i saw that the lists with additional line break characters result in a leading whitespace on the left. i tried fixing this in the patch here - although this seems to get a bit too complex ...
cheers, ben
On 1/28/26 14:36, Benjamin Wesch wrote:
On Wed, Jan 28, 2026 at 12:10 PM IOhannes m zmoelnig via Pd-list pd-list@lists.iem.at wrote:
like in the attached patch.
this is really cool - thanks for the contributions and inspiration, cyrille and iohannes! with left-aligned text, i saw that the lists with additional line break characters result in a leading whitespace on the left.
yes. that's because we are actually adding a *word* with the content "\n" - and the word is surrounded by whitespace.
basically, my advice is to use the [string( message with unicode points:
unicode-points
this also allows you to render text with multiple consecutive whitespace characters (" " vs " "). note that the TAB character usually does not render as whitespace.
gfdasr IOhannes
On 1/28/26 14:36, Benjamin Wesch wrote:
On Wed, Jan 28, 2026 at 12:10 PM IOhannes m zmoelnig via Pd-list pd-list@lists.iem.at wrote:
like in the attached patch.
this is really cool - thanks for the contributions and inspiration, cyrille and iohannes! with left-aligned text, i saw that the lists with additional line break characters result in a leading whitespace on the left.
yes. that's because we are actually adding a *word* with the content "\n" - and the word is surrounded by whitespace.
basically, my advice is to use the [string( message with unicode points:
- use [file] to read the raw UTF-8 bytes
- use [unicode/utf82codenumber] to convert the UTF-8 bytes into
unicode-points
- prefix [string(
I tried to implement this (see attached) but [text2d] renders the actual bytes as numbers... Something I am missing?
Thanks to all of you! best, P
Am 28. Jänner 2026 19:08:15 MEZ schrieb "Peter P." peterparker@fastmail.com:
basically, my advice is to use the [string( message with unicode points:
- use [file] to read the raw UTF-8 bytes
- use [unicode/utf82codenumber] to convert the UTF-8 bytes into
unicode-points
- prefix [string(
I tried to implement this (see attached) but [text2d] renders the actual bytes as numbers...
I haven't checked your patch yet, but apart from the obvious (as Ben pointed out), I'd like to reiterate:
the "string" message does **not** take bytes but Unicode points (there's about 2^20 of them) which are numbers (been 0 and ~1000000). bytes can only have values between 0 and 255.
for ASCII characters (which only use Unicode points between 0 and 127), the UTF-8 representation is identical to the Unicode point representation.
mfg.sfg.jfd IOhannes
Thanks Ben, your hint made the whole patch work with umlauts and accents.
Thanks for the explanation IOhannes. I think I am having a hard time understanding the following:
All the best, Peter
Am 28. Jänner 2026 19:08:15 MEZ schrieb "Peter P." peterparker@fastmail.com:
basically, my advice is to use the [string( message with unicode points:
- use [file] to read the raw UTF-8 bytes
- use [unicode/utf82codenumber] to convert the UTF-8 bytes into
unicode-points
- prefix [string(
I tried to implement this (see attached) but [text2d] renders the actual bytes as numbers...
I haven't checked your patch yet, but apart from the obvious (as Ben pointed out), I'd like to reiterate:
the "string" message does **not** take bytes but Unicode points (there's about 2^20 of them) which are numbers (been 0 and ~1000000). bytes can only have values between 0 and 255.
for ASCII characters (which only use Unicode points between 0 and 127), the UTF-8 representation is identical to the Unicode point representation.
mfg.sfg.jfd IOhannes
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/3HTQ2OT4US...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
On 1/28/26 23:56, Peter P. wrote:
Thanks Ben, your hint made the whole patch work with umlauts and accents.
Thanks for the explanation IOhannes. I think I am having a hard time understanding the following:
- Bytes, which have a range between 0 and 255.
- "Unicode points" which are numbers representing characters including umlauts?
- "ASCII characters", which are somehow bytes but also use unicode points 0-127.
yes, this is a good recap. not sure what you missed :-)
"ASCII characters" is a list of characters, numbered from 0 to 127. these characters include the latin alphabet, numbers, a few special characters (like "~" or "#") and a handful of control characters. notably, it lacks umlauts and the like. https://en.wikipedia.org/wiki/ASCII
"Unicode" is another list of characters, numbered from 0 to a bit above 1000000 (these numbers are the so called "Unicode points"). Apart from the characters already in ASCII, it also list characters from different writing systems, including German (with umlauts!), Tamil and Chinese. It also lists a lot of emojis, but weirdly enough lacks characters for Tengwar. https://en.wikipedia.org/wiki/Unicode
"bytes" are data chunks of 8bit (and are the fundamental unit of data when computers are involved, e.g. when reading files, transmitting things over the network,...) since bytes are 8bit, they can represent numbers from 0 to 255.
if you have a text-file with plain ASCII text (only) in it, the bytes in the file correspond to the ASCII values. e.g. if the first byte in the text file is 0x48, this corresponds to the letter "H" (ASCII code 72). this is cool, but it really only works a byte can hold all the possible values of ASCII characters.
it doesn't work with Unicode. e.g. the letter "π" (Greek small letter pi), is assigned the code point 0x03C0 (number 960) - and there's no way to stuff this number into a single byte (8 bits).
a couple of schemes have been invented how these Unicode numbers are to be represented in bytes - but all of them need more than a single byte to represent 0x03C0.
the most common scheme in use today is UTF-8, which has a "variable length encoding" - meaning that a single unicode point can be represented as 1, 2, 3 or 4 bytes: basically, the smaller the value, the less bytes you need. a nice property of UTF-8 is, that it is a strict superset of ASCII, meaning that it is fully downward compatible with ASCII. that is: all characters from the ASCII table are assigned the same Unicode point *and* these characters are all represented as single bytes. so your ASCII file (or any other ASCII file) is a fully valid UTF-8 file. all characters beyond the 127 ASCII chars (upwards from unicode point 128), need more than 1 byte! https://en.wikipedia.org/wiki/UTF-8
now, Pd's internal representation of characters uses UTF-8. [fudiparse] takes a message, converts it into a UTF-8 string and then outputs the bytes of this string. e.g. a message [π( is converted into a string "π;\n" (the trailing semicolon and linefeed are FUDI specifics). these three characters have the Unicode points '960 59 10', which in UTF-8 is encoded as the bytes '207 128 59 10'. (in theory; it seems there's a minor bug so that the values are output a *signed* 8bit numbers, so the values '207 128' (0xCF and 0x80) are output as "-49 -128"'; luckily this bug usually doesn't matter, as the usual objects you use it's output with, e.g. [fudiparse], or [netsend], will happily handle this for you).
- The "string" message and its difference to the "text" message in [text2d].
the "text" message just takes Pd atoms and converts them into a string (very much like e.g. [print]) and renders it.
the "string" message takes a list of numbers (e.g. ASCII values, but really Unicode points!) converts them into a string and renders it.
if you have any more questions, do not hesitate to ask.
gasdm IOhannes