[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: TeX output for UML diagrams [path]



Le dim, jan 06, 2002, à 12:34:53 +0200, Ruslan Shevchenko a écrit:

> 1. Small problem with printing UML diagram in TeX: TeX special symbols 
> in names (such as #) are not escaped, as result TeX output
> are not compiled by TeX.
> So, I attach patch against dia-0.88.1

thanks for the patch ! It looks mostly good; I've not yet applied it, see 
comments/questions below. But as it applies cleanly to CVS head, I don't see
why wouldn't it go in.

> 2. Are anybody know: what can cause invisability of some words in TeX 
> diagrams ?

I dunno, sorry. I use dia in dia+LaTeX combo through EPS (EPDF actually).


> @@ -45,6 +45,7 @@
>  #include <string.h>
>  #include <time.h>
>  #include <math.h>
> +#include <stdlib.h>
>  #ifdef HAVE_UNISTD_H
>  #include <unistd.h>
>  #endif
> @@ -649,12 +650,89 @@
>      fprintf(renderer->file, "\\fill[fillstyle=solid,fillcolor=diafillcolor,linecolor=diafillcolor]}\n");
>  }
>  
[ ... ]
 
> +static char* create_tex_escaped_string(const char* in_text)
> +{
> + /* count number of symbols to escaped */
> + int extra_count = 0;
> + const char* in_cursor;
> + char* out_cursor;
> + char* out_text;
> + char* prefix;
> + int   replace=0;
> + for(in_cursor=in_text;*in_cursor; ++in_cursor) {
> +   extra_count+=is_tex_escaped_symbol(*in_cursor,&prefix,&replace);

in all these loops, what happens if the input string is encoded in UTF-8 ? 

(how does TeX behave when presented with UTF-8 data ? Can it even do that ?
 OK, I tease you, but I'd be very happy to learn how)

> + }
> + /* now alloc memory and print prefixed escaped string */
> + out_text = malloc(strlen(in_text)+extra_count+1);

<nitpick>Please use gmalloc() here</nitpick>


> + out_cursor=out_text;
> + for(in_cursor=in_text;*in_cursor;) {
> +   if (is_tex_escaped_symbol(*in_cursor,&prefix,&replace)) {
> +     while(*prefix) *out_cursor++ = *prefix++;
> +   }
> +   if (!replace) {
> +     *out_cursor++=*in_cursor++;
> +   }else{
> +     in_cursor++;
> +   }
> + }
> + *out_cursor++='\0';
> + return out_text;
> +}
> +
>  static void
>  draw_string(RendererPSTRICKS *renderer,
>  	    const char *text,
>  	    Point *pos, Alignment alignment,
>  	    Color *color)
>  {
> +    char* tex_escaped_text;
> +
>      set_line_color(renderer,color);
>  
>      fprintf(renderer->file,"\\rput");
> @@ -668,7 +746,12 @@
>  	fprintf(renderer->file,"[r]");
>  	break;
>      }
> -    fprintf(renderer->file,"(%f,%f){\\scalebox{1 -1}{%s}}\n",pos->x, pos->y,text);
> +    
> +    tex_escaped_text=create_tex_escaped_string(text); 
> +
> +    fprintf(renderer->file,"(%f,%f){\\scalebox{1 -1}{%s}}\n",pos->x, pos->y,tex_escaped_text);
> +
> +    free(tex_escaped_text);

<nitpick>gfree()</nitpick>


Thanks in advance !

	-- Cyrille

-- 
Grumpf.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK