Gentoo Archives: gentoo-commits

From: "Peter Volkov (pva)" <pva@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in media-gfx/transfig/files: transfig-3.2.5d-fig2mpdf.patch
Date: Tue, 28 Sep 2010 14:41:55
Message-Id: 20100928144151.53D1920054@flycatcher.gentoo.org
1 pva 10/09/28 14:41:51
2
3 Added: transfig-3.2.5d-fig2mpdf.patch
4 Log:
5 Version bump. Use POSIX shell compatible fig2ps2tex.sh to avoid dependency on tcsh, bug #338295, thank Nathan Phillip Brink (ohnobinki) for report.
6
7 (Portage version: 2.1.9.12/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 media-gfx/transfig/files/transfig-3.2.5d-fig2mpdf.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-gfx/transfig/files/transfig-3.2.5d-fig2mpdf.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-gfx/transfig/files/transfig-3.2.5d-fig2mpdf.patch?rev=1.1&content-type=text/plain
14
15 Index: transfig-3.2.5d-fig2mpdf.patch
16 ===================================================================
17 === modified file 'doc/fig2dev.1'
18 --- doc/fig2dev.1 2010-09-28 13:22:38 +0000
19 +++ doc/fig2dev.1 2010-09-28 13:28:26 +0000
20 @@ -53,8 +53,8 @@
21 \fBbox, cgm, epic, eepic, eepicemu, emf, eps, gbx (Gerber beta driver), gif, ibmgl, jpeg,
22 latex, map (HTML image map), mf (MetaFont),
23 mp (MetaPost), mmp (Multi-MetaPost),
24 -pcx, pdf, pdftex, pdftex_t, pic, pictex, png, ppm, ps,
25 -pstex, pstex_t, pstricks, ptk (Perl/tk),
26 +pcx, pdf, pdftex, pdftex_t, pdftex_p, pic, pictex, png, ppm, ps,
27 +pstex, pstex_t, pstex_p, pstricks, ptk (Perl/tk),
28 shape (LaTeX shaped paragraphs), sld (AutoCad slide format),
29 svg (beta driver), textyl,
30 tiff, tk (tcl/tk), tpic, xbm and
31 @@ -1062,6 +1062,62 @@
32 font. Option 1 sets LaTeX font size only. Option 2 issues no font
33 commands at all.
34
35 +.SH PSTEX_P and PDFTEX_P OPTIONS
36 +The \fBpstex_p\fR language has the same intention as
37 +the combination of \fBpstex\fR and \fBpstex_t\fR.
38 +The only reason to use \fBpstex_p\fR is that you have partially overlayed texts.
39 +\fBpstex_p\fR splits the Fig file concerning the depths of existing texts. Because
40 +of it's necessary to get the resulting size of the figure for the pdf document
41 +you have to specify the target document format
42 +(i.e. using \fBpstex_p\fR rsp. \fBpdftex_p\fR).
43 +.br
44 +Two files results by using this language:
45 +.br
46 +.HP +.3i
47 +1) A bash script for creating and removing the necessary graphics files.
48 +Extension: \fB.create\fR
49 +.HP +.3i
50 +.HP +.3i
51 +2) The latex code which includes all graphics files and special texts. Content is
52 +put to stdout.
53 +
54 +.TP
55 +The \fBpstex_p\fR driver has the following special options:
56 +
57 +.TP
58 +.B \-p basename
59 +specifies the basename of the files to be created (see (1) above). This option
60 +is mandatory.
61 +.TP
62 +.B "\-d dmag"
63 +Set a separate magnification for the length of line dashes to
64 +.I dmag.
65 +.TP
66 +.B \-E num
67 +Set encoding for latex text translation (0 no translation, 1 ISO-8859-1, 2 ISO-8859-2)
68 +.TP
69 +.B "\-l lwidth"
70 +Sets the threshold between LaTeX thin and thick lines to
71 +.I lwidth
72 +pixels.
73 +LaTeX supports only two different line width: \\thinlines and \\thicklines.
74 +Lines of width greater than
75 +.I lwidth
76 +pixels are drawn as \\thicklines.
77 +Also affects the size of dots in dotted line style.
78 +The default is 1.
79 +.TP
80 +.B \-v
81 +Verbose mode.
82 +.TP
83 +.B \-F
84 +Don't set the font face, series, and style; only set it's size and the
85 +baselineskip. By default, fig2dev sets all 5 font parameters when it
86 +puts some text. The disadvantage is that you can't set the font from your
87 +LaTeX document. With this option on, you can set the font from your LaTeX
88 +document (like "\fB\\sfshape \\input picture.eepic\fR").
89 +
90 +
91 .SH TK and PTK OPTIONS (tcl/tk and Perl/tk)
92 .TP
93 .B -l dummy_arg
94 @@ -1107,6 +1163,13 @@
95 .PP
96 Rotated text is only supported in the IBM-GL (HP/GL) and PostScript (including eps)
97 languages.
98 +.PP
99 +In \fBpdftex_p\fR language \fIfig2dev\fR can not determine the exact sizes of
100 +the special texts set by pdflatex afterwards. If these texts are bigger than
101 +expected the calculated bounding box might be too small so that some texts passes
102 +over the figure boundaries. If this happen you have to put an invisible
103 +rectangle (line width 0) around the text or the entire figure.
104 +
105 .SH COPYRIGHT
106 Copyright (c) 1991 Micah Beck
107 .br
108 @@ -1187,3 +1250,7 @@
109 The GBX (Gerber) driver was written by
110 .br
111 Edward Grace (ej.grace@×××××××××××.uk).
112 +.sp
113 +The PSTEX_P and PDFTEX_P drivers (overlayed LaTeX texts) was written by
114 +.br
115 +Michael Pfeiffer (p3f@×××.de)
116
117 === modified file 'fig2dev/dev/genpstex.c'
118 --- fig2dev/dev/genpstex.c 2010-09-28 13:22:38 +0000
119 +++ fig2dev/dev/genpstex.c 2010-09-28 13:26:39 +0000
120 @@ -70,7 +70,307 @@
121 genps_end ();
122
123 static char pstex_file[1000] = "";
124 -
125 +static int iObjectsRead = 0;
126 +static int iTextRead = 0;
127 +static int iObjectsFileNumber = 0;
128 +static int iStartDepth;
129 +static int iLastDepth;
130 +static FILE * ptCreateFile;
131 +static char szFileName[1000];
132 +static int iLength;
133 +static int iPdfOutputs = 0;
134 +
135 +#ifdef never
136 +static double unitlength;
137 +static double dash_mag = 1.0;
138 +
139 +static int (*translate_coordinates)() = NULL;
140 +static int (*translate_coordinates_d)() = NULL;
141 +#else
142 +extern double unitlength;
143 +extern double dash_mag;
144 +
145 +extern int (*translate_coordinates)();
146 +extern int (*translate_coordinates_d)();
147 +#endif
148 +
149 +#define TOP 840
150 +#define SWAP(x,y) {tmp=x; x=y; y=tmp;}
151 +#define TRANS(x,y) (*translate_coordinates)(&x,&y)
152 +#define TRANS2(x1,y1,x2,y2) (*translate_coordinates)(&x1,&y1); \
153 + (*translate_coordinates)(&x2,&y2)
154 +#define TRANSD(x,y) (*translate_coordinates_d)(&x,&y)
155 +
156 +static void genpstex_p_finalize_objects(int depth);
157 +
158 +/*************************************************************************
159 + *************************************************************************/
160 +static
161 +translate2(xp, yp)
162 + int *xp, *yp;
163 +{
164 + *xp = *xp + 1;
165 + *yp = (double)(TOP - *yp -1);
166 + }
167 +
168 +static
169 +translate1_d(xp, yp)
170 + double *xp, *yp;
171 +{
172 + *xp = *xp + 1.0;
173 + *yp = *yp + 1.0;
174 + }
175 +
176 +static
177 +translate2_d(xp, yp)
178 + double *xp, *yp;
179 +{
180 + *xp = *xp + 1.0;
181 + *yp = (double)TOP - *yp -1.0;
182 + }
183 +
184 +/*************************************************************************
185 + *************************************************************************/
186 +void genpstex_p_option(opt, optarg)
187 +char opt, *optarg;
188 +{
189 + if (opt == 'p')
190 + {
191 + strcpy(pstex_file, optarg);
192 + }
193 + else
194 + genlatex_option(opt, optarg);
195 +}
196 +
197 +
198 +/*************************************************************************
199 + *************************************************************************/
200 +void genpstex_p_start(objects)
201 + F_compound *objects;
202 +{
203 + int tmp;
204 + struct stat tStat;
205 + long lUnitLength;
206 +
207 + if (*pstex_file == '\0')
208 + {
209 + put_msg("Argument -p is mandatory to pstex_p.");
210 + exit(1);
211 + }
212 +
213 + strncpy(szFileName, pstex_file, 900);
214 + iLength = strlen(szFileName);
215 +
216 + sprintf(szFileName + iLength, ".create");
217 + ptCreateFile = fopen (szFileName, "wb");
218 +
219 + if ( ! ptCreateFile)
220 + {
221 + put_msg("Couldn't open %s for writing", szFileName);
222 + exit(1);
223 + }
224 + fstat(fileno(ptCreateFile), & tStat);
225 + fchmod (fileno(ptCreateFile), tStat.st_mode | ((tStat.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) >> 2));
226 + fprintf(ptCreateFile, "#!/bin/bash\n\n", szFileName);
227 +
228 + fprintf(ptCreateFile, "while getopts \"r\" Option\n");
229 + fprintf(ptCreateFile, "do\n");
230 + fprintf(ptCreateFile, " case $Option in\n");
231 + fprintf(ptCreateFile, " r) iOptRemove=1;;\n");
232 + fprintf(ptCreateFile, " *) echo \"illegal option -$Option\"\n");
233 + fprintf(ptCreateFile, " esac\n");
234 + fprintf(ptCreateFile, "done\n");
235 + fprintf(ptCreateFile, "shift $(($OPTIND - 1))\n");
236 +
237 + texfontsizes[0] = texfontsizes[1] =
238 + TEXFONTSIZE(font_size != 0.0? font_size : DEFAULT_FONT_SIZE);
239 +
240 + unitlength = mag/ppi;
241 + dash_mag /= unitlength*80.0;
242 +
243 + translate_coordinates = translate2;
244 + translate_coordinates_d = translate2_d;
245 +
246 + TRANS2(llx, lly, urx, ury);
247 + if (llx > urx) SWAP(llx, urx)
248 + if (lly > ury) SWAP(lly, ury)
249 +
250 + /* LaTeX start */
251 +
252 + /* print any whole-figure comments prefixed with "%" */
253 + if (objects->comments) {
254 + fprintf(tfp,"%%\n");
255 + print_comments("% ",objects->comments, "");
256 + fprintf(tfp,"%%\n");
257 + }
258 +
259 + lUnitLength = (long) (round(4736286.72*unitlength));
260 + fprintf(tfp, "\\setlength{\\unitlength}{%lisp}%%\n",
261 + lUnitLength);
262 + /* define the SetFigFont macro */
263 + define_setfigfont(tfp);
264 +
265 + sprintf(szFileName + iLength, ".size");
266 + fprintf(ptCreateFile, "if [ \"$iOptRemove\" == \"\" ]; then\n");
267 + if (iPdfOutputs)
268 + fprintf(ptCreateFile, " echo \"\\setlength\\pdfpagewidth{%3.2fpt}\\setlength\\pdfpageheight{%3.2fpt}\" > %s\n",
269 + (float) lUnitLength / 65536 * (urx - llx), (float) lUnitLength / 65536 * (ury - lly), szFileName);
270 + else
271 + fprintf(ptCreateFile, "echo -n\"\" > %s\n", szFileName);
272 + fprintf(ptCreateFile, "else\n rm -f %s\nfi\n", szFileName);
273 +}
274 +
275 +/*************************************************************************
276 + *************************************************************************/
277 +void genpdftex_p_start(objects)
278 + F_compound *objects;
279 +{
280 + iPdfOutputs = 1;
281 + genpstex_p_start(objects);
282 +}
283 +
284 +
285 +/*************************************************************************
286 + *************************************************************************/
287 +int genpstex_p_end()
288 +{
289 + if (iTextRead)
290 + {
291 + fprintf(tfp, "\\end{picture}%%\n");
292 + iTextRead = 0;
293 + }
294 + if (iObjectsRead)
295 + {
296 + genpstex_p_finalize_objects(iLastDepth);
297 + iObjectsRead = 0;
298 + }
299 +
300 + /* LaTeX ending */
301 + fprintf(tfp, "\\begin{picture}(%d,%d)\n", urx-llx, ury-lly);
302 + fprintf(tfp, "\\end{picture}%%\n");
303 +
304 + fclose(ptCreateFile);
305 +
306 + /* all ok */
307 + return 0;
308 +}
309 +
310 +
311 +/*************************************************************************
312 + *************************************************************************/
313 +void genpstex_p_finalize_objects(depth)
314 +int depth;
315 +{
316 + char szFileName[1000];
317 + int iLength;
318 +
319 + strncpy(szFileName, pstex_file, 900);
320 + iLength = strlen(szFileName);
321 +
322 +
323 + sprintf(szFileName + iLength, "%03d", iObjectsFileNumber++);
324 + fprintf(ptCreateFile, "if [ \"$iOptRemove\" == \"\" ]; then\n");
325 + if (iPdfOutputs)
326 + {
327 + fprintf(ptCreateFile, " %s -L pstex -D +%d:%d %s", prog, depth, iStartDepth, from, szFileName);
328 + fprintf(ptCreateFile, " | epstopdf -f --outfile %s.pdf\n", szFileName, szFileName);
329 + }
330 + else
331 + fprintf(ptCreateFile, "%s -L pstex -D +%d:%d %s %s.eps\n", prog, depth, iStartDepth, from, szFileName);
332 + fprintf(ptCreateFile, "else\n rm -f %s.", szFileName);
333 + if (iPdfOutputs)
334 + fprintf(ptCreateFile, "pdf");
335 + else
336 + fprintf(ptCreateFile, "eps");
337 + fprintf(ptCreateFile, "\nfi\n");
338 +
339 + fprintf(tfp, "\\begin{picture}(0,0)%%\n");
340 +/* newer includegraphics directive suggested by Stephen Harker 1/13/99 */
341 +#if defined(LATEX2E_GRAPHICS)
342 +# if defined(EPSFIG)
343 + fprintf(tfp, "\\epsfig{file=%s.eps}%%\n",szFileName);
344 +# else
345 + fprintf(tfp, "\\includegraphics{%s}%%\n",szFileName);
346 +# endif
347 +#else
348 + fprintf(tfp, "\\special{psfile=%s.eps}%%\n",szFileName);
349 +#endif
350 + fprintf(tfp, "\\end{picture}%%\n");
351 +}
352 +
353 +/*************************************************************************
354 + *************************************************************************/
355 +void genpstex_p_object(depth)
356 +int depth;
357 +{
358 + if (iTextRead)
359 + {
360 + fprintf(tfp, "\\end{picture}%%\n");
361 + iTextRead = 0;
362 + }
363 + if (iObjectsRead == 0)
364 + {
365 + iStartDepth = depth;
366 + iObjectsRead = 1;
367 + }
368 + iLastDepth = depth;
369 +
370 +}
371 +
372 +void genpstex_p_arc(obj)
373 +F_arc *obj;
374 +{
375 + genpstex_p_object(obj->depth);
376 +}
377 +
378 +
379 +void genpstex_p_ellipse(obj)
380 +F_ellipse *obj;
381 +{
382 + genpstex_p_object(obj->depth);
383 +}
384 +
385 +void genpstex_p_line(obj)
386 +F_line *obj;
387 +{
388 + genpstex_p_object(obj->depth);
389 +}
390 +
391 +void genpstex_p_spline(obj)
392 +F_spline *obj;
393 +{
394 + genpstex_p_object(obj->depth);
395 +}
396 +
397 +
398 +
399 +/*************************************************************************
400 + *************************************************************************/
401 +void genpstex_p_text(t)
402 +F_text *t;
403 +{
404 +
405 + if (!special_text(t))
406 + genpstex_p_object(t->depth);
407 + else
408 + {
409 + if (iObjectsRead)
410 + {
411 + genpstex_p_finalize_objects(iLastDepth);
412 + iObjectsRead = 0;
413 + }
414 + if (iTextRead == 0)
415 + {
416 + fprintf(tfp, "\\begin{picture}(0,0)(%d,%d)\n", llx, lly);
417 + iTextRead = 1;
418 + }
419 + genlatex_text(t);
420 + }
421 +
422 +}
423 +
424 +/*************************************************************************
425 + *************************************************************************/
426 void genpstex_t_option(opt, optarg)
427 char opt, *optarg;
428 {
429 @@ -112,6 +412,8 @@
430 else genlatex_text(t);
431 }
432
433 +/*************************************************************************
434 + *************************************************************************/
435 void genpstex_text(t)
436 F_text *t;
437 {
438 @@ -128,6 +430,32 @@
439 genlatex_option(opt, optarg);
440 }
441
442 +struct driver dev_pstex_p = {
443 + genpstex_p_option,
444 + genpstex_p_start,
445 + gendev_null,
446 + genpstex_p_arc,
447 + genpstex_p_ellipse,
448 + genpstex_p_line,
449 + genpstex_p_spline,
450 + genpstex_p_text,
451 + genpstex_p_end,
452 + INCLUDE_TEXT
453 +};
454 +
455 +struct driver dev_pdftex_p = {
456 + genpstex_p_option,
457 + genpdftex_p_start,
458 + gendev_null,
459 + genpstex_p_arc,
460 + genpstex_p_ellipse,
461 + genpstex_p_line,
462 + genpstex_p_spline,
463 + genpstex_p_text,
464 + genpstex_p_end,
465 + INCLUDE_TEXT
466 +};
467 +
468 struct driver dev_pstex_t = {
469 genpstex_t_option,
470 genpstex_t_start,
471
472 === modified file 'fig2dev/drivers.h'
473 --- fig2dev/drivers.h 2010-09-28 13:22:38 +0000
474 +++ fig2dev/drivers.h 2010-09-28 13:29:46 +0000
475 @@ -30,8 +30,10 @@
476 extern struct driver dev_pdf;
477 extern struct driver dev_pdftex;
478 extern struct driver dev_pdftex_t;
479 +extern struct driver dev_pdftex_p;
480 extern struct driver dev_pstex;
481 extern struct driver dev_pstex_t;
482 +extern struct driver dev_pstex_p;
483 extern struct driver dev_pstricks;
484 extern struct driver dev_textyl;
485 extern struct driver dev_tk;
486 @@ -75,6 +77,7 @@
487 {"pdf", &dev_pdf},
488 {"pdftex", &dev_pdftex},
489 {"pdftex_t", &dev_pdftex_t},
490 + {"pdftex_p", &dev_pdftex_p},
491 {"pic", &dev_pic},
492 {"pictex", &dev_pictex},
493 {"png", &dev_bitmaps},
494 @@ -82,6 +85,7 @@
495 {"ps", &dev_ps},
496 {"pstex", &dev_pstex},
497 {"pstex_t", &dev_pstex_t},
498 + {"pstex_p", &dev_pstex_p},
499 {"pstricks", &dev_pstricks},
500 {"ptk", &dev_ptk},
501 {"shape", &dev_shape},
502
503 === modified file 'fig2dev/fig2dev.c'
504 --- fig2dev/fig2dev.c 2010-09-28 13:22:38 +0000
505 +++ fig2dev/fig2dev.c 2010-09-28 13:26:39 +0000
506 @@ -649,6 +649,18 @@
507 #endif /* NFSS */
508 printf(" -p name name of the PostScript file to be overlaid\n");
509
510 + printf("PSTEX_P and PDFTEX_P Options:\n");
511 + printf(" -p name basename of the files to be created\n");
512 +#ifdef NFSS
513 + printf(" -F don't set font family/series/shape, so you can\n");
514 + printf(" set it from latex\n");
515 +#endif /* NFSS */
516 + printf(" -d dmag set separate magnification for length of line dashes to dmag\n");
517 + printf(" -E num set encoding for text translation (0 no translation,\n");
518 + printf(" 1 ISO-8859-1, 2 ISO-8859-2)\n");
519 + printf(" -l lwidth set threshold between thin and thick lines to lwidth\n");
520 + printf(" -v verbose mode\n");
521 +
522 printf("SHAPE (ShapePar driver) Options:\n");
523 printf(" -n name Set basename of the macro (e.g. \"face\" gives faceshape and facepar)\n");
524 printf("Tcl/Tk (tk) and Perl/Tk (ptk) Options:\n");
525 @@ -776,6 +788,12 @@
526 int rec_comp(r1, r2)
527 struct obj_rec *r1, *r2;
528 {
529 + if (r2->depth == r1->depth)
530 + {
531 + if ((r1->gendev == dev->text) ^ (r2->gendev == dev->text))
532 + return ((r1->gendev == dev->text) * 2 - 1);
533 + return (0);
534 + }
535 return (r2->depth - r1->depth);
536 }