Hallo gem-devs!
I currently need to display formated text in GEM: I use text2d and need to display a longer text over more lines - so I have to check where I have to make a newline ...
I know I can implement that with the pd message system, but it's a little bit hacky and not so dynamic.
So I thought about implementing it directly in the TextBase class:
e.g.: ////////// // The string to display char **m_theString; ////////// // max. characters pro lines // (if 0 then there will be only 1 line // with as much characters as needed!) int m_maxchar; ////////// // lines of the string int m_lines;
with changing m_theString to a double pointer and m_maxchar is the maximum of characters in one line - so I can automatically calculate the nr of lines (m_lines) and display the text dynamically in more lines - and of course if a word doesn't fit into the line anymore it will be put in the next line...
So my question, would that be usefull ? (because it's a little bit of work - I would have to modify all the different text objects ...) If not I will simply use a hack, which also would do the job, but maybe this solution could be usefull ... let me know what you think ...
Thanks, LG Georg
Hallo again!
So I thought about implementing it directly in the TextBase class:
just realized, that it maybe doesn't make much sense with 3d text, so I will simply add it to text2d, or make an own object ...
LG Georg
Georg Holzmann wrote:
Hallo again!
So I thought about implementing it directly in the TextBase class:
just realized, that it maybe doesn't make much sense with 3d text, so I will simply add it to text2d, or make an own object ...
why should it make no sense with 3d-text or outlined text ?
mfg.adsr. IOhannes
Hallo!
why should it make no sense with 3d-text or outlined text ?
okay, maybe it would make sense ... anyway, I will make it for text2d first and if it is usefull I can add it to the rest (in TextBase class) ...
LG Georg
mfg.adsr. IOhannes
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
It DOES makes sense to add it to text3d, maybe not extruded text... I often work with text in a spacial way, and to have these types of enhancement would be really nice to have for *all* text.
b>
Georg Holzmann wrote:
Hallo again!
So I thought about implementing it directly in the TextBase class:
just realized, that it maybe doesn't make much sense with 3d text, so I will simply add it to text2d, or make an own object ...
LG Georg
Hallo Gem-devs!
here is the first "demo".
Some questions:
- Is it okay to use STL ? It's quiet handy here ...
- you can control now the number of chars in a line with the [maxchar( message and if maxchar is 0 then there will be only one line with unlimited chars ... is that okay, and a good name for the message (i don't know ...)
- Right, Center, etc. is not working now - I guess I will have to play a little bit with the BBox ...
- only for FTGL now, is still someone using GLTT ? because it's hard to test here for me ...
and I also attached a simple test patch, with some explanation.
So should I make a seperate object for this, or put it to text2d or to TextBase (would be some work) - what do you think ?
LG Georg
#N canvas 692 194 677 494 10; #X obj 76 387 cnv 15 100 60 empty empty empty 20 12 0 14 -195568 -66577 0; #N canvas 0 0 450 300 gemwin 0; #X obj 132 136 gemwin; #X obj 67 89 outlet; #X obj 67 10 inlet; #X obj 67 41 route create; #X msg 67 70 set destroy; #X msg 142 68 set create; #X msg 198 112 destroy; #X msg 132 112 create , 1; #X connect 2 0 3 0; #X connect 3 0 4 0; #X connect 3 0 7 0; #X connect 3 1 5 0; #X connect 3 1 6 0; #X connect 4 0 1 0; #X connect 5 0 1 0; #X connect 6 0 0 0; #X connect 7 0 0 0; #X restore 81 426 pd gemwin; #X msg 81 407 create; #X text 77 386 Create window:; #X text 95 36 Example:; #X obj 103 57 gemhead; #X floatatom 140 276 5 0 100 1 size - -; #X msg 277 61 text hello world!; #X msg 125 186 1 2 3 4; #X msg 129 227 alias $1; #X obj 129 209 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X obj 103 78 translateXYZ; #X floatatom 207 61 5 -10 10 0 - - -; #X floatatom 166 56 3 -3.5 3.5 0 - - -; #X obj 103 297 text2d; #X msg 130 128 font helmetr.ttf; #X obj 130 105 loadbang; #X msg 273 131 text an other text; #X msg 273 159 text llk daiuh adhiah asdohua hu; #X msg 275 184 text asdfghjklsdfgsdfg; #X msg 317 310 maxchar $1; #X floatatom 316 289 5 0 0 0 - - -; #X msg 273 91 text gestern wars wieder ganz lustig und wir haben einen Donaudampfschifffahrtskapitaen umgebracht!; #X msg 130 253 justify left base; #X msg 319 400 linedist $1; #X floatatom 319 382 5 0 0 0 - - -; #X msg 276 210 text; #X text 282 34 some text:; #X text 310 265 max chars in a line; #X text 405 293 (is this a good name?); #X text 315 341 line distance:; #X text 335 357 1 = 1 line , 0.5 = half line , ...; #X connect 1 0 2 0; #X connect 2 0 1 0; #X connect 5 0 11 0; #X connect 6 0 14 1; #X connect 7 0 14 0; #X connect 8 0 14 0; #X connect 9 0 14 0; #X connect 10 0 9 0; #X connect 11 0 14 0; #X connect 12 0 11 3; #X connect 13 0 11 1; #X connect 15 0 14 0; #X connect 16 0 15 0; #X connect 17 0 14 0; #X connect 18 0 14 0; #X connect 19 0 14 0; #X connect 20 0 14 0; #X connect 21 0 20 0; #X connect 22 0 14 0; #X connect 23 0 14 0; #X connect 24 0 14 0; #X connect 25 0 24 0; #X connect 26 0 14 0;
Hallo again!
So, I think now it's working as it should, also with the BoundingBox, Right,Center, ... and all that stuff ... (attached)
Please IOhannes (or someone else) check the code+behaviour, if it is okay (I didn't used the text objects before - so I don't know what you want ...) I can put it in TextBase (and all the render functions of the other text objects ... ) so all the text objects could make use of it ...
An other question: Why is there a Render method in TextBase (with an FTGL notice) ? Shouldn't this method be abstract?
LG Georg
#N canvas 692 194 677 605 10; #X obj 380 450 cnv 15 100 60 empty empty empty 20 12 0 14 -195568 -66577 0; #N canvas 0 0 450 300 gemwin 0; #X obj 67 89 outlet; #X obj 67 10 inlet; #X obj 67 41 route create; #X msg 67 70 set destroy; #X msg 142 68 set create; #X msg 198 112 destroy; #X msg 132 112 create , 1; #X obj 132 136 gemwin; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 2 0 6 0; #X connect 2 1 4 0; #X connect 2 1 5 0; #X connect 3 0 0 0; #X connect 4 0 0 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X restore 385 489 pd gemwin; #X msg 385 470 destroy; #X text 381 449 Create window:; #X text 95 36 Example:; #X obj 103 57 gemhead; #X floatatom 140 276 5 0 100 1 size - -; #X msg 277 61 text hello world!; #X msg 125 186 1 2 3 4; #X msg 129 227 alias $1; #X obj 129 209 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X obj 103 78 translateXYZ; #X floatatom 207 61 5 -10 10 0 - - -; #X floatatom 166 56 3 -3.5 3.5 0 - - -; #X obj 103 297 text2d; #X msg 130 128 font helmetr.ttf; #X obj 130 105 loadbang; #X msg 273 131 text an other text; #X msg 273 159 text llk daiuh adhiah asdohua hu; #X msg 275 184 text asdfghjklsdfgsdfg; #X msg 394 303 maxchar $1; #X floatatom 393 282 5 0 0 0 - - -; #X msg 273 91 text gestern wars wieder ganz lustig und wir haben einen Donaudampfschifffahrtskapitaen umgebracht!; #X msg 396 393 linedist $1; #X floatatom 396 375 5 0 0 0 - - -; #X msg 276 210 text; #X text 282 34 some text:; #X text 387 258 max chars in a line; #X text 482 286 (is this a good name?); #X text 392 334 line distance:; #X text 412 350 1 = 1 line , 0.5 = half line , ...; #X msg 214 388 base; #X msg 214 431 middle; #X msg 214 409 top; #X msg 138 531 justify $1 $2; #X msg 163 370 left; #X msg 163 393 center; #X msg 163 416 right; #X msg 163 438 base; #X msg 214 454 bottom; #X obj 163 460 symbol; #X obj 214 475 symbol; #X obj 163 508 pack s s; #X obj 171 485 t b s; #X connect 1 0 2 0; #X connect 2 0 1 0; #X connect 5 0 11 0; #X connect 6 0 14 1; #X connect 7 0 14 0; #X connect 8 0 14 0; #X connect 9 0 14 0; #X connect 10 0 9 0; #X connect 11 0 14 0; #X connect 12 0 11 3; #X connect 13 0 11 1; #X connect 15 0 14 0; #X connect 16 0 15 0; #X connect 17 0 14 0; #X connect 18 0 14 0; #X connect 19 0 14 0; #X connect 20 0 14 0; #X connect 21 0 20 0; #X connect 22 0 14 0; #X connect 23 0 14 0; #X connect 24 0 23 0; #X connect 25 0 14 0; #X connect 31 0 41 0; #X connect 32 0 41 0; #X connect 33 0 41 0; #X connect 34 0 14 0; #X connect 35 0 40 0; #X connect 36 0 40 0; #X connect 37 0 40 0; #X connect 38 0 40 0; #X connect 39 0 41 0; #X connect 40 0 42 0; #X connect 41 0 43 0; #X connect 42 0 34 0; #X connect 43 0 42 0; #X connect 43 1 42 1;
Georg Holzmann wrote:
Hallo again!
So, I think now it's working as it should, also with the BoundingBox, Right,Center, ... and all that stuff ... (attached)
Please IOhannes (or someone else) check the code+behaviour, if it is okay (I didn't used the text objects before - so I don't know what you want ...) I can put it in TextBase (and all the render functions of the other text objects ... ) so all the text objects could make use of it ...
great that it is done. i will have a look at it. (although i still (as discussed offline) would prefer an external object that does the line-breaking and...)
An other question: Why is there a Render method in TextBase (with an FTGL notice) ? Shouldn't this method be abstract?
all right, no that i looked at the code again i can confirm that this method should not be abstract for FTGL.
all text-objects BUT [text2d] inherit the render()-function (FTGL); so you just looked at the wrong objects...
mfga.sdr. IOhannes
LG Georg
Hallo!
(although i still (as discussed offline) would prefer an external object that does the line-breaking and...)
but I can't image how that should work - with dynamical number of lines etc. ...
all text-objects BUT [text2d] inherit the render()-function (FTGL); so you just looked at the wrong objects...
ah - okay. But that's good news - so I don't have to rewrite all the render methods ;)
LG Georg
Georg Holzmann wrote:
Hallo!
(although i still (as discussed offline) would prefer an external object that does the line-breaking and...)
but I can't image how that should work - with dynamical number of lines etc. ...
just as simple as inserting line-breaks "\n" where a line-break should occur. and the text-objects will break the lines according to that information (and do alignment as requested)
mfg.ads.r IOhannes
Hallo!
just as simple as inserting line-breaks "\n" where a line-break should occur.
yes, but the problem is that you must then store the whole text in a symbol and that's not possible. If you make a long symbol PD breaks it ... (just try:
[symbol asdfjaowejfölsagaiuhrföaijpöoadifvjölakjfvöaijfvölakfjlskjdflakjföaoijvölaskdfjöaljfweöoifjsdöalkfölasfj ( | [print] )
Or maybe insert the \n in a list ? (we would really need a string in pd ... :(
LG Georg
Georg Holzmann wrote:
Hallo!
just as simple as inserting line-breaks "\n" where a line-break should occur.
yes, but the problem is that you must then store the whole text in a symbol and that's not possible. If you make a long symbol PD breaks it ... (just try:
[symbol asdfjaowejfölsagaiuhrföaijpöoadifvjölakjfvöaijfvölakfjlskjdflakjföaoijvölaskdfjöaljfweöoifjsdöalkfölasfj ( | [print] )
oho!
just try the attached patch (zexy needed); of course this proves nothing (but gives us some hints)
i think that [print] is a bad debugging tool for extreme symbols.
it would be better to look at the symbol within C.
mfg.asd.r IOhannes
hi
of course [l2s] wouldn't make much sense with a limited length of symbols (at least with so low limits).
IOhannes m zmoelnig wrote:
i think that [print] is a bad debugging tool for extreme symbols.
it would be better to look at the symbol within C.
and doing so, i have done symbols with 20000 characters without problems.
of course this (like [l2s]) will polute the symbol-hash and (what is more important) will add a memory-leak (as symbols that once appear in a pd-sessions will stay there forever)
so a string-type would really be nice.
mfg.asd.r IOhannes
mfg.asd.r IOhannes
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
Hallo!
of course this (like [l2s]) will polute the symbol-hash and (what is more important) will add a memory-leak (as symbols that once appear in a pd-sessions will stay there forever)
yes ... :(
so a string-type would really be nice.
anyway, would it make much sense, if we use lists for that? e.g.
[list this is a long text over more lines( | [maxchar 10] (or a more meaningful name ...) | [list this is a \n long text \n over more \n lines( | [text2d]
LG Georg
Georg Holzmann wrote:
Hallo!
of course this (like [l2s]) will polute the symbol-hash and (what is more important) will add a memory-leak (as symbols that once appear in a pd-sessions will stay there forever)
yes ... :(
it is not a very big problem, i think (of course a memory-leak, or what appears to be a memory-leak, is always a problem)
in most cases you will not manage to fill up your memory (only if you really generate a lot of symbols on the fly)
so a string-type would really be nice.
anyway, would it make much sense, if we use lists for that? e.g.
[list this is a long text over more lines( | [maxchar 10] (or a more meaningful name ...) | [list this is a \n long text \n over more \n lines( | [text2d]
otoh, TextBase generates a string out of the incoming list anyhow. it does not care whether the "\n" is a separate symbol or hidden within a symbol: "bi \n ba" is the same string (on the TexBase-side) as "bi" "\n" "ba" (using " " as a separator). both should result in: "bi ba"
(but none is "bi\nba"!)
and i do think [linebreak] is a better name than [maxchar] ;-)
mfga.sd.-r IOhannes
Hallo!
otoh, TextBase generates a string out of the incoming list anyhow. it does not care whether the "\n" is a separate symbol or hidden within a symbol: "bi \n ba" is the same string (on the TexBase-side) as "bi" "\n" "ba" (using " " as a separator). both should result in: "bi ba"
yes, of course ...
(but none is "bi\nba"!)
hm ... I don't really undestand that ... you mean "bi\nba" should not result in "bi ba" ?
and i do think [linebreak] is a better name than [maxchar] ;-)
that's it - thanks!
but anyway, I think I will let it as it is for now ... because list parsing stuff would be again much additional work (I can forget all the vector+string stuff then ... :(
so maybe I have time to put it in TextBase this evening, please let me know if you think that's for nothing ...
LG Georg
mfga.sd.-r IOhannes
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
Georg Holzmann wrote:
Hallo!
(but none is "bi\nba"!)
hm ... I don't really undestand that ... you mean "bi\nba" should not result in "bi ba" ?
this is a minor issue (itüpfelreiterei): mind the spaces
"bi\nba" should result in "bi ba"
"bi" "\n" "ba" (one list with 3 symbols) would result in "bi_ _ba" (replacing the spaces witrh underscores)
i don't think that automatic stripping of spaces is a good thing for a text-render object.
so maybe I have time to put it in TextBase this evening, please let me know if you think that's for nothing ...
ok, i have added your changes to the CVS, but i have kicked out the line-breaking thing (it just breaks whereever it encounters a "\n" (ascii 10(dec)))
mfg.a.sdr IOhannes
On Tue, 30 Aug 2005, Georg Holzmann wrote:
yes, but the problem is that you must then store the whole text in a symbol and that's not possible. If you make a long symbol PD breaks it ... (just try: [symbol asdfjaowejfölsagaiuhrföaijpöoadifvjölakjfvöaijfvölakfjlskjdflakjföaoijvölaskdfjö aljfweöoifjsdöalkfölasfj ( | [print] )
[print] cuts symbols after 78 characters and prints an asterisk.
I've tried with [rubyprint] and [display] and they can print a lot more characters.
I think this mostly affects [print]. There are possibly other limitations of length in Pd but those limits are very high -- at least much longer than the classic limit of 255 characters per symbol in MAX :-}
(we would really need a string in pd ... :(
Yup, yup.
____________________________________________________________________ Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju Freelance Digital Arts Engineer, Montréal QC Canada
On Sun, 4 Sep 2005, Mathieu Bouchard wrote:
I think this mostly affects [print]. There are possibly other limitations of length in Pd but those limits are very high -- at least much longer than the classic limit of 255 characters per symbol in MAX :-}
Actually, the limit is currently 999, as you can see in m_pd.h
#define MAXPDSTRING 1000
But this can be modified to some other higher value. However, externals have to be recompiled for this change to take effect.
Also, some externals may ignore that value, and part of the pd core does. Here's the patch I tested it with (using -lib gridflow):
[bang} | [#in r001.jpg] | [# || 1] | [#export_symbol] | [#import (240 320 3)] | [#out window]
and then when you bang the thing you see a picture appearing, and you can verify that the image has really been converted to a symbol.
The [# || 1] simply replaces all zeroes by ones, because symbols can't contain 0, which are reserved for terminating strings.
____________________________________________________________________ Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju Freelance Digital Arts Engineer, Montréal QC Canada
Hey Georg,
I've thought this would be handy for sure. A "textbox" where you just specify the x,y of the upper left and lower right that contains the words would be great. The ability to justify each line independantly would be really nice...
I think it is worth it for certain, being one of those people who works with a lot of text.
b.
Georg Holzmann wrote:
Hallo gem-devs!
I currently need to display formated text in GEM: I use text2d and need to display a longer text over more lines - so I have to check where I have to make a newline ...
I know I can implement that with the pd message system, but it's a little bit hacky and not so dynamic.
So I thought about implementing it directly in the TextBase class:
e.g.: ////////// // The string to display char **m_theString; ////////// // max. characters pro lines // (if 0 then there will be only 1 line // with as much characters as needed!) int m_maxchar; ////////// // lines of the string int m_lines;
with changing m_theString to a double pointer and m_maxchar is the maximum of characters in one line - so I can automatically calculate the nr of lines (m_lines) and display the text dynamically in more lines - and of course if a word doesn't fit into the line anymore it will be put in the next line...
So my question, would that be usefull ? (because it's a little bit of work - I would have to modify all the different text objects ...) If not I will simply use a hack, which also would do the job, but maybe this solution could be usefull ... let me know what you think ...
Thanks, LG Georg
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev