diff options
-rwxr-xr-x | doc/help-pdp_dot.pd | 83 | ||||
-rw-r--r-- | doc/pdp_qtext-help.pd | 123 | ||||
-rw-r--r-- | doc/pdp_text-help.pd | 95 | ||||
-rw-r--r-- | modules/pdp_qtext.c | 67 | ||||
-rw-r--r-- | modules/pdp_text.c | 70 |
5 files changed, 239 insertions, 199 deletions
diff --git a/doc/help-pdp_dot.pd b/doc/help-pdp_dot.pd deleted file mode 100755 index 4324637..0000000 --- a/doc/help-pdp_dot.pd +++ /dev/null @@ -1,83 +0,0 @@ -#N canvas 243 42 781 666 10; -#X obj 341 20 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 --1; -#X msg 196 92 loop \$1; -#X obj 197 70 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1 1 -; -#X msg 452 93 open \$1; -#X obj 452 69 openpanel; -#X obj 452 49 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 --1; -#X floatatom 389 55 5 0 0 0 - - -; -#X msg 298 21 stop; -#X obj 396 24 hsl 300 15 0 1000 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 0 1; -#X obj 330 91 metro 70; -#X obj 325 123 pdp_yqt; -#X obj 25 193 pdp_v4l; -#X obj 34 162 metro 70; -#X obj 79 128 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 --1; -#X msg 36 129 stop; -#X msg 121 160 open /dev/video; -#X obj 607 117 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 -1; -#X obj 607 169 pdp_control; -#X msg 607 142 thread \$1; -#X floatatom 607 230 5 0 0 0 - - -; -#X obj 607 201 route pdp_drop; -#X floatatom 238 295 5 0 0 0 - - -; -#X floatatom 237 337 5 0 0 0 - - -; -#X obj 108 441 pdp_glx; -#X obj 108 400 pdp_dot ----; -#X text 297 521 pdp_dot : dot matrix filter; -#X text 297 536 written by Yves Degoyon ( ydegoyon@free.fr ); -#X msg 280 292 100; -#X obj 316 292 loadbang; -#X msg 283 335 100; -#X obj 319 335 loadbang; -#X text 240 310 number of x divisions ( [5 \, width] default : 100 -); -#X text 238 354 number of y divisions ( [5 \, height] default : 100 -); -#X msg 315 263 25; -#X msg 282 264 40; -#X msg 351 262 10; -#X obj 325 159 pdp_glx; -#X msg 240 265 100; -#X connect 0 0 9 0; -#X connect 1 0 10 0; -#X connect 2 0 1 0; -#X connect 3 0 10 0; -#X connect 4 0 3 0; -#X connect 5 0 4 0; -#X connect 6 0 9 1; -#X connect 7 0 9 0; -#X connect 8 0 6 0; -#X connect 9 0 10 0; -#X connect 10 0 24 0; -#X connect 10 0 36 0; -#X connect 11 0 24 0; -#X connect 12 0 11 0; -#X connect 13 0 12 0; -#X connect 14 0 12 0; -#X connect 15 0 11 0; -#X connect 16 0 18 0; -#X connect 17 0 20 0; -#X connect 18 0 17 0; -#X connect 20 0 19 0; -#X connect 21 0 24 1; -#X connect 22 0 24 2; -#X connect 24 0 23 0; -#X connect 27 0 21 0; -#X connect 28 0 27 0; -#X connect 29 0 22 0; -#X connect 30 0 29 0; -#X connect 33 0 21 0; -#X connect 33 0 22 0; -#X connect 34 0 21 0; -#X connect 34 0 22 0; -#X connect 35 0 21 0; -#X connect 35 0 22 0; -#X connect 37 0 21 0; -#X connect 37 0 22 0; diff --git a/doc/pdp_qtext-help.pd b/doc/pdp_qtext-help.pd index 4f12d12..b10a507 100644 --- a/doc/pdp_qtext-help.pd +++ b/doc/pdp_qtext-help.pd @@ -1,9 +1,9 @@ -#N canvas 84 12 846 664 10; +#N canvas 87 48 846 664 10; #X obj 152 576 pdp_glx; #X obj 268 13 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; #X msg 188 88 loop \$1; -#X obj 189 66 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1 1 +#X obj 189 66 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1 ; #X msg 303 34 open \$1; #X obj 302 10 openpanel; @@ -12,7 +12,6 @@ #X floatatom 340 57 5 0 0 0 - - -; #X msg 225 14 stop; #X obj 257 84 metro 70; -#X obj 346 152 pdp_v4l; #X obj 355 121 metro 70; #X obj 400 87 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; @@ -54,7 +53,6 @@ #X text 200 204 text <text> x y [ r g b angle ]; #X floatatom 392 504 5 0 0 0 - - -; #X text 440 503 Angle; -#X msg 14 523 font helmetr/5; #X floatatom 415 522 5 0 0 0 - - -; #X text 461 522 Scroll; #X msg 19 204 layermode feed; @@ -102,66 +100,73 @@ layer; #X msg 541 519 text2b \$1; #X msg 547 542 text2a \$1; #X msg 21 300 margin 50; +#X msg 14 523 font ae_Arab/32; +#X msg 53 575 display :2.0; +#X msg 261 354 text %1579 200 200; +#X text 450 354 Utf-8 text ( load font ae_Arab before ); +#X obj 346 151 pdp_v4l2; #X connect 1 0 9 0; -#X connect 2 0 15 0; +#X connect 2 0 14 0; #X connect 3 0 2 0; -#X connect 4 0 15 0; +#X connect 4 0 14 0; #X connect 5 0 4 0; #X connect 6 0 5 0; #X connect 7 0 9 1; #X connect 8 0 9 0; -#X connect 9 0 15 0; -#X connect 10 0 60 0; +#X connect 9 0 14 0; +#X connect 10 0 91 0; #X connect 11 0 10 0; -#X connect 12 0 11 0; -#X connect 13 0 11 0; -#X connect 14 0 10 0; -#X connect 15 0 60 0; -#X connect 16 0 18 0; -#X connect 17 0 20 0; -#X connect 18 0 17 0; -#X connect 20 0 19 0; -#X connect 21 0 60 0; -#X connect 22 0 60 0; -#X connect 23 0 60 0; -#X connect 24 0 60 0; -#X connect 25 0 60 0; -#X connect 26 0 60 1; -#X connect 32 0 60 2; -#X connect 34 0 60 3; -#X connect 35 0 60 4; -#X connect 36 0 60 5; -#X connect 37 0 60 6; -#X connect 42 0 10 0; -#X connect 43 0 60 0; -#X connect 44 0 60 0; -#X connect 45 0 60 0; -#X connect 47 0 60 7; -#X connect 49 0 60 0; -#X connect 50 0 60 8; -#X connect 52 0 60 0; -#X connect 53 0 60 0; -#X connect 54 0 60 0; -#X connect 55 0 60 0; -#X connect 56 0 60 0; -#X connect 57 0 60 0; -#X connect 58 0 57 0; -#X connect 59 0 60 0; -#X connect 60 0 0 0; -#X connect 61 0 60 0; -#X connect 62 0 60 0; -#X connect 70 0 60 0; -#X connect 74 0 60 0; -#X connect 75 0 74 0; -#X connect 76 0 75 0; -#X connect 77 0 75 0; -#X connect 78 0 70 0; +#X connect 12 0 10 0; +#X connect 13 0 91 0; +#X connect 14 0 58 0; +#X connect 15 0 17 0; +#X connect 16 0 19 0; +#X connect 17 0 16 0; +#X connect 19 0 18 0; +#X connect 20 0 58 0; +#X connect 21 0 58 0; +#X connect 22 0 58 0; +#X connect 23 0 58 0; +#X connect 24 0 58 0; +#X connect 25 0 58 1; +#X connect 31 0 58 2; +#X connect 33 0 58 3; +#X connect 34 0 58 4; +#X connect 35 0 58 5; +#X connect 36 0 58 6; +#X connect 41 0 91 0; +#X connect 42 0 58 0; +#X connect 43 0 58 0; +#X connect 44 0 58 0; +#X connect 46 0 58 7; +#X connect 48 0 58 8; +#X connect 50 0 58 0; +#X connect 51 0 58 0; +#X connect 52 0 58 0; +#X connect 53 0 58 0; +#X connect 54 0 58 0; +#X connect 55 0 58 0; +#X connect 56 0 55 0; +#X connect 57 0 58 0; +#X connect 58 0 0 0; +#X connect 59 0 58 0; +#X connect 60 0 58 0; +#X connect 68 0 58 0; +#X connect 72 0 58 0; +#X connect 73 0 72 0; +#X connect 74 0 73 0; +#X connect 75 0 73 0; +#X connect 76 0 68 0; +#X connect 78 0 79 0; +#X connect 79 0 58 0; #X connect 80 0 81 0; -#X connect 81 0 60 0; -#X connect 82 0 83 0; -#X connect 83 0 60 0; -#X connect 84 0 86 0; -#X connect 85 0 87 0; -#X connect 86 0 60 0; -#X connect 87 0 60 0; -#X connect 88 0 60 0; +#X connect 81 0 58 0; +#X connect 82 0 84 0; +#X connect 83 0 85 0; +#X connect 84 0 58 0; +#X connect 85 0 58 0; +#X connect 86 0 58 0; +#X connect 87 0 58 0; +#X connect 88 0 0 0; +#X connect 89 0 58 0; +#X connect 91 0 58 0; diff --git a/doc/pdp_text-help.pd b/doc/pdp_text-help.pd index 96d6ef0..5b733e1 100644 --- a/doc/pdp_text-help.pd +++ b/doc/pdp_text-help.pd @@ -1,9 +1,9 @@ -#N canvas 325 39 763 664 10; +#N canvas 443 128 763 664 10; #X obj 152 627 pdp_glx; #X obj 268 64 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; #X msg 158 123 loop \$1; -#X obj 159 101 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1 +#X obj 159 101 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X msg 370 44 open \$1; #X obj 369 20 openpanel; @@ -12,9 +12,8 @@ #X floatatom 316 99 5 0 0 0 - - -; #X msg 225 65 stop; #X obj 323 68 hsl 300 15 0 1000 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 4000 1; +-1 -1 0 1; #X obj 257 135 metro 70; -#X obj 346 203 pdp_v4l; #X obj 355 172 metro 70; #X obj 400 138 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; @@ -33,9 +32,9 @@ #X msg 186 384 text %34%48%49:37:58%34 20 220; #X msg 177 359 text "01:37:58" 230 220; #X msg 171 330 text a%32hundred%32%% 120 128 255 0 0; -#X obj 204 425 hdl 15 1 0 10 empty empty empty 0 -6 0 8 -262144 -1 +#X obj 203 428 hdl 15 1 0 10 empty empty empty 0 -6 0 8 -262144 -1 -1 0; -#X text 364 424 Select current text ( 10 items by default ); +#X text 363 427 Select current text ( 10 items by default ); #X text 308 282 Add a simple text; #X text 349 305 Add a text with special characters; #X text 438 330 Add a real percent now ( but in red ); @@ -55,7 +54,6 @@ #X msg 29 352 clear; #X msg 30 387 delete 1; #X msg 30 421 resize 20; -#X msg 30 489 font helmetr/14; #X obj 155 598 pdp_text -----------------; #X text 139 254 text <text> x y [ r g b angle ]; #X floatatom 331 554 5 0 0 0 - - -; @@ -66,57 +64,62 @@ #X msg 63 540 blend \$1; #X floatatom 14 562 5 0 0 0 - - -; #X msg 64 560 antialias \$1; -#X msg 29 458 font helmetr/5; #X floatatom 354 572 5 0 0 0 - - -; #X text 400 572 Scroll; #X obj 380 594 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144 -1 -1 0 1; #X text 517 594 Alpha ( global ); #X msg 163 304 text on%32air!! 150 78; +#X msg 63 627 display :2; +#X obj 345 202 pdp_v4l2; +#X msg 195 406 text %1579 200 200; +#X msg 29 459 font ae_Arab/32; +#X text 362 405 Unicode character ( load ae_Arab font before ); #X connect 1 0 10 0; -#X connect 2 0 16 0; +#X connect 2 0 15 0; #X connect 3 0 2 0; -#X connect 4 0 16 0; +#X connect 4 0 15 0; #X connect 5 0 4 0; #X connect 6 0 5 0; #X connect 7 0 10 1; #X connect 8 0 10 0; #X connect 9 0 7 0; -#X connect 10 0 16 0; -#X connect 11 0 50 0; +#X connect 10 0 15 0; +#X connect 11 0 64 0; #X connect 12 0 11 0; -#X connect 13 0 12 0; -#X connect 14 0 12 0; -#X connect 15 0 11 0; -#X connect 16 0 50 0; -#X connect 17 0 19 0; -#X connect 18 0 21 0; -#X connect 19 0 18 0; -#X connect 21 0 20 0; -#X connect 24 0 50 0; -#X connect 25 0 50 0; -#X connect 26 0 50 0; -#X connect 27 0 50 0; -#X connect 28 0 50 1; -#X connect 35 0 50 2; -#X connect 37 0 50 3; -#X connect 38 0 50 4; -#X connect 39 0 50 5; -#X connect 40 0 50 6; -#X connect 45 0 11 0; -#X connect 46 0 50 0; -#X connect 47 0 50 0; -#X connect 48 0 50 0; -#X connect 49 0 50 0; -#X connect 50 0 0 0; -#X connect 52 0 50 7; -#X connect 54 0 50 0; -#X connect 55 0 54 0; +#X connect 13 0 11 0; +#X connect 14 0 64 0; +#X connect 15 0 48 0; +#X connect 16 0 18 0; +#X connect 17 0 20 0; +#X connect 18 0 17 0; +#X connect 20 0 19 0; +#X connect 23 0 48 0; +#X connect 24 0 48 0; +#X connect 25 0 48 0; +#X connect 26 0 48 0; +#X connect 27 0 48 1; +#X connect 34 0 48 2; +#X connect 36 0 48 3; +#X connect 37 0 48 4; +#X connect 38 0 48 5; +#X connect 39 0 48 6; +#X connect 44 0 64 0; +#X connect 45 0 48 0; +#X connect 46 0 48 0; +#X connect 47 0 48 0; +#X connect 48 0 0 0; +#X connect 50 0 48 7; +#X connect 52 0 48 0; +#X connect 53 0 52 0; +#X connect 54 0 55 0; +#X connect 55 0 48 0; #X connect 56 0 57 0; -#X connect 57 0 50 0; -#X connect 58 0 59 0; -#X connect 59 0 50 0; -#X connect 60 0 50 0; -#X connect 61 0 50 8; -#X connect 63 0 50 9; -#X connect 65 0 50 0; +#X connect 57 0 48 0; +#X connect 58 0 48 8; +#X connect 60 0 48 9; +#X connect 62 0 48 0; +#X connect 63 0 0 0; +#X connect 64 0 48 0; +#X connect 65 0 48 0; +#X connect 66 0 48 0; diff --git a/modules/pdp_qtext.c b/modules/pdp_qtext.c index 84cabec..da08ba7 100644 --- a/modules/pdp_qtext.c +++ b/modules/pdp_qtext.c @@ -278,8 +278,6 @@ static void pdp_qtext_add(t_pdp_qtext *x, t_symbol *s, int argc, t_atom *argv) ndigits=0; piname=pname+1; while ( isdigit( *(piname++) ) ) ndigits++; - - ivalue=atoi(pname+1); // special case %% if ( ( pname != argv[0].a_w.w_symbol->s_name ) && ( *(pname+1) == '%' ) ) @@ -288,7 +286,49 @@ static void pdp_qtext_add(t_pdp_qtext *x, t_symbol *s, int argc, t_atom *argv) pname++; continue; } - *(pdname++)=(char)ivalue; + + ivalue=atoi(pname+1); + // encode to utf + if ( ivalue < 0x7F ) + { + *(pdname++)=(char)ivalue; + } + else if ( ivalue <= 0x7FF ) + { + *(pdname++)=(char)(192 + (ivalue/64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0xFFFF ) + { + *(pdname++)=(char)(224 + (ivalue/4096)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0x1FFFFF ) + { + *(pdname++)=(char)(240 + (ivalue/262144)); + *(pdname++)=(char)(128 + ((ivalue/4096)%64)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0x3FFFFFF ) + { + *(pdname++)=(char)(248 + (ivalue/16777216)); + *(pdname++)=(char)(128 + ((ivalue/262144)%64)); + *(pdname++)=(char)(128 + ((ivalue/4096)%64)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0x7FFFFFFF ) + { + *(pdname++)=(char)(252 + (ivalue/1073741824)); + *(pdname++)=(char)(128 + ((ivalue/16777216)%64)); + *(pdname++)=(char)(128 + ((ivalue/262144)%64)); + *(pdname++)=(char)(128 + ((ivalue/4096)%64)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + pname+=ndigits+1; } else if ( !strncmp( pname, "\"", 1 ) ) // quotes are ignored unless %34 @@ -1086,8 +1126,25 @@ void pdp_qtext_setup(void) font = imlib_load_font(DEFAULT_FONT); if ( !font ) { - error( "[pdp_qtext] error: could not load default font, no text rendering!" ); - post( "\tinstall Bitstream Vera, it's free! (http://www.gnome.org/fonts/)" ); + char **ifonts; + int nbfonts, jf; + char fname[64]; + + ifonts = imlib_list_fonts( &nbfonts ); + for ( jf=0; jf<nbfonts; jf++ ) + { + sprintf( fname, "%s/14", ifonts[jf] ); + font = imlib_load_font( fname ); + if ( !font ) + { + post( "[pdp_qtext] error loading font : %s", fname ); + } + else + { + post( "[pdp_qtext] using font : %s", fname ); + break; + } + } } imlib_context_set_font( font ); } diff --git a/modules/pdp_text.c b/modules/pdp_text.c index e0c313b..d586c21 100644 --- a/modules/pdp_text.c +++ b/modules/pdp_text.c @@ -98,7 +98,7 @@ static void pdp_text_add(t_pdp_text *x, t_symbol *s, int argc, t_atom *argv) // allocate new text area len = strlen( argv[0].a_w.w_symbol->s_name ); - pdname = x->x_text_array[x->x_nbtexts] = (char *) getbytes( len+1 ); + pdname = x->x_text_array[x->x_nbtexts] = (char *) getbytes( 6*len+1 ); pname = (char *) getbytes( len+1 ); memset( pname, 0x0, len+1 ); memcpy( pname, argv[0].a_w.w_symbol->s_name, len ); @@ -114,8 +114,6 @@ static void pdp_text_add(t_pdp_text *x, t_symbol *s, int argc, t_atom *argv) piname=pname+1; while ( isdigit( *(piname++) ) ) ndigits++; - ivalue=atoi(pname+1); - // special case %% if ( ( pname != argv[0].a_w.w_symbol->s_name ) && ( *(pname+1) == '%' ) ) { @@ -123,7 +121,50 @@ static void pdp_text_add(t_pdp_text *x, t_symbol *s, int argc, t_atom *argv) pname++; continue; } - *(pdname++)=(char)ivalue; + + ivalue=atoi(pname+1); + + // encode to utf + if ( ivalue < 0x7F ) + { + *(pdname++)=(char)ivalue; + } + else if ( ivalue <= 0x7FF ) + { + *(pdname++)=(char)(192 + (ivalue/64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0xFFFF ) + { + *(pdname++)=(char)(224 + (ivalue/4096)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0x1FFFFF ) + { + *(pdname++)=(char)(240 + (ivalue/262144)); + *(pdname++)=(char)(128 + ((ivalue/4096)%64)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0x3FFFFFF ) + { + *(pdname++)=(char)(248 + (ivalue/16777216)); + *(pdname++)=(char)(128 + ((ivalue/262144)%64)); + *(pdname++)=(char)(128 + ((ivalue/4096)%64)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + else if ( ivalue <= 0x7FFFFFFF ) + { + *(pdname++)=(char)(252 + (ivalue/1073741824)); + *(pdname++)=(char)(128 + ((ivalue/16777216)%64)); + *(pdname++)=(char)(128 + ((ivalue/262144)%64)); + *(pdname++)=(char)(128 + ((ivalue/4096)%64)); + *(pdname++)=(char)(128 + ((ivalue/64)%64)); + *(pdname++)=(char)(128 + (ivalue%64)); + } + pname+=ndigits+1; } else if ( !strncmp( pname, "\"", 1 ) ) // quotes are ignored unless %34 @@ -649,8 +690,25 @@ void pdp_text_setup(void) font = imlib_load_font(DEFAULT_FONT); if ( !font ) { - error( "[pdp_text] error: could not load default font, no text rendering!" ); - post( "\tinstall Bitstream Vera, it's free! (http://www.gnome.org/fonts/)" ); + char **ifonts; + int nbfonts, jf; + char fname[64]; + + ifonts = imlib_list_fonts( &nbfonts ); + for ( jf=0; jf<nbfonts; jf++ ) + { + sprintf( fname, "%s/14", ifonts[jf] ); + font = imlib_load_font( fname ); + if ( !font ) + { + post( "[pdp_text] error loading font : %s", fname ); + } + else + { + post( "[pdp_text] using font : %s", fname ); + break; + } + } } imlib_context_set_font( font ); } |