| === modified file 'doc/fig2dev.1' |
| --- doc/fig2dev.1 2010-09-28 13:22:38 +0000 |
| +++ doc/fig2dev.1 2010-09-28 13:28:26 +0000 |
| @@ -53,8 +53,8 @@ |
| \fBbox, cgm, epic, eepic, eepicemu, emf, eps, gbx (Gerber beta driver), gif, ibmgl, jpeg, |
| latex, map (HTML image map), mf (MetaFont), |
| mp (MetaPost), mmp (Multi-MetaPost), |
| -pcx, pdf, pdftex, pdftex_t, pic, pictex, png, ppm, ps, |
| -pstex, pstex_t, pstricks, ptk (Perl/tk), |
| +pcx, pdf, pdftex, pdftex_t, pdftex_p, pic, pictex, png, ppm, ps, |
| +pstex, pstex_t, pstex_p, pstricks, ptk (Perl/tk), |
| shape (LaTeX shaped paragraphs), sld (AutoCad slide format), |
| svg (beta driver), textyl, |
| tiff, tk (tcl/tk), tpic, xbm and |
| @@ -1062,6 +1062,62 @@ |
| font. Option 1 sets LaTeX font size only. Option 2 issues no font |
| commands at all. |
| |
| +.SH PSTEX_P and PDFTEX_P OPTIONS |
| +The \fBpstex_p\fR language has the same intention as |
| +the combination of \fBpstex\fR and \fBpstex_t\fR. |
| +The only reason to use \fBpstex_p\fR is that you have partially overlayed texts. |
| +\fBpstex_p\fR splits the Fig file concerning the depths of existing texts. Because |
| +of it's necessary to get the resulting size of the figure for the pdf document |
| +you have to specify the target document format |
| +(i.e. using \fBpstex_p\fR rsp. \fBpdftex_p\fR). |
| +.br |
| +Two files results by using this language: |
| +.br |
| +.HP +.3i |
| +1) A bash script for creating and removing the necessary graphics files. |
| +Extension: \fB.create\fR |
| +.HP +.3i |
| +.HP +.3i |
| +2) The latex code which includes all graphics files and special texts. Content is |
| +put to stdout. |
| + |
| +.TP |
| +The \fBpstex_p\fR driver has the following special options: |
| + |
| +.TP |
| +.B \-p basename |
| +specifies the basename of the files to be created (see (1) above). This option |
| +is mandatory. |
| +.TP |
| +.B "\-d dmag" |
| +Set a separate magnification for the length of line dashes to |
| +.I dmag. |
| +.TP |
| +.B \-E num |
| +Set encoding for latex text translation (0 no translation, 1 ISO-8859-1, 2 ISO-8859-2) |
| +.TP |
| +.B "\-l lwidth" |
| +Sets the threshold between LaTeX thin and thick lines to |
| +.I lwidth |
| +pixels. |
| +LaTeX supports only two different line width: \\thinlines and \\thicklines. |
| +Lines of width greater than |
| +.I lwidth |
| +pixels are drawn as \\thicklines. |
| +Also affects the size of dots in dotted line style. |
| +The default is 1. |
| +.TP |
| +.B \-v |
| +Verbose mode. |
| +.TP |
| +.B \-F |
| +Don't set the font face, series, and style; only set it's size and the |
| +baselineskip. By default, fig2dev sets all 5 font parameters when it |
| +puts some text. The disadvantage is that you can't set the font from your |
| +LaTeX document. With this option on, you can set the font from your LaTeX |
| +document (like "\fB\\sfshape \\input picture.eepic\fR"). |
| + |
| + |
| .SH TK and PTK OPTIONS (tcl/tk and Perl/tk) |
| .TP |
| .B -l dummy_arg |
| @@ -1107,6 +1163,13 @@ |
| .PP |
| Rotated text is only supported in the IBM-GL (HP/GL) and PostScript (including eps) |
| languages. |
| +.PP |
| +In \fBpdftex_p\fR language \fIfig2dev\fR can not determine the exact sizes of |
| +the special texts set by pdflatex afterwards. If these texts are bigger than |
| +expected the calculated bounding box might be too small so that some texts passes |
| +over the figure boundaries. If this happen you have to put an invisible |
| +rectangle (line width 0) around the text or the entire figure. |
| + |
| .SH COPYRIGHT |
| Copyright (c) 1991 Micah Beck |
| .br |
| @@ -1187,3 +1250,7 @@ |
| The GBX (Gerber) driver was written by |
| .br |
| Edward Grace (ej.grace@imperial.ac.uk). |
| +.sp |
| +The PSTEX_P and PDFTEX_P drivers (overlayed LaTeX texts) was written by |
| +.br |
| +Michael Pfeiffer (p3f@gmx.de) |
| |
| === modified file 'fig2dev/dev/genpstex.c' |
| --- fig2dev/dev/genpstex.c 2010-09-28 13:22:38 +0000 |
| +++ fig2dev/dev/genpstex.c 2010-09-28 13:26:39 +0000 |
| @@ -70,7 +70,307 @@ |
| genps_end (); |
| |
| static char pstex_file[1000] = ""; |
| - |
| +static int iObjectsRead = 0; |
| +static int iTextRead = 0; |
| +static int iObjectsFileNumber = 0; |
| +static int iStartDepth; |
| +static int iLastDepth; |
| +static FILE * ptCreateFile; |
| +static char szFileName[1000]; |
| +static int iLength; |
| +static int iPdfOutputs = 0; |
| + |
| +#ifdef never |
| +static double unitlength; |
| +static double dash_mag = 1.0; |
| + |
| +static int (*translate_coordinates)() = NULL; |
| +static int (*translate_coordinates_d)() = NULL; |
| +#else |
| +extern double unitlength; |
| +extern double dash_mag; |
| + |
| +extern int (*translate_coordinates)(); |
| +extern int (*translate_coordinates_d)(); |
| +#endif |
| + |
| +#define TOP 840 |
| +#define SWAP(x,y) {tmp=x; x=y; y=tmp;} |
| +#define TRANS(x,y) (*translate_coordinates)(&x,&y) |
| +#define TRANS2(x1,y1,x2,y2) (*translate_coordinates)(&x1,&y1); \ |
| + (*translate_coordinates)(&x2,&y2) |
| +#define TRANSD(x,y) (*translate_coordinates_d)(&x,&y) |
| + |
| +static void genpstex_p_finalize_objects(int depth); |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +static |
| +translate2(xp, yp) |
| + int *xp, *yp; |
| +{ |
| + *xp = *xp + 1; |
| + *yp = (double)(TOP - *yp -1); |
| + } |
| + |
| +static |
| +translate1_d(xp, yp) |
| + double *xp, *yp; |
| +{ |
| + *xp = *xp + 1.0; |
| + *yp = *yp + 1.0; |
| + } |
| + |
| +static |
| +translate2_d(xp, yp) |
| + double *xp, *yp; |
| +{ |
| + *xp = *xp + 1.0; |
| + *yp = (double)TOP - *yp -1.0; |
| + } |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +void genpstex_p_option(opt, optarg) |
| +char opt, *optarg; |
| +{ |
| + if (opt == 'p') |
| + { |
| + strcpy(pstex_file, optarg); |
| + } |
| + else |
| + genlatex_option(opt, optarg); |
| +} |
| + |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +void genpstex_p_start(objects) |
| + F_compound *objects; |
| +{ |
| + int tmp; |
| + struct stat tStat; |
| + long lUnitLength; |
| + |
| + if (*pstex_file == '\0') |
| + { |
| + put_msg("Argument -p is mandatory to pstex_p."); |
| + exit(1); |
| + } |
| + |
| + strncpy(szFileName, pstex_file, 900); |
| + iLength = strlen(szFileName); |
| + |
| + sprintf(szFileName + iLength, ".create"); |
| + ptCreateFile = fopen (szFileName, "wb"); |
| + |
| + if ( ! ptCreateFile) |
| + { |
| + put_msg("Couldn't open %s for writing", szFileName); |
| + exit(1); |
| + } |
| + fstat(fileno(ptCreateFile), & tStat); |
| + fchmod (fileno(ptCreateFile), tStat.st_mode | ((tStat.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) >> 2)); |
| + fprintf(ptCreateFile, "#!/bin/bash\n\n", szFileName); |
| + |
| + fprintf(ptCreateFile, "while getopts \"r\" Option\n"); |
| + fprintf(ptCreateFile, "do\n"); |
| + fprintf(ptCreateFile, " case $Option in\n"); |
| + fprintf(ptCreateFile, " r) iOptRemove=1;;\n"); |
| + fprintf(ptCreateFile, " *) echo \"illegal option -$Option\"\n"); |
| + fprintf(ptCreateFile, " esac\n"); |
| + fprintf(ptCreateFile, "done\n"); |
| + fprintf(ptCreateFile, "shift $(($OPTIND - 1))\n"); |
| + |
| + texfontsizes[0] = texfontsizes[1] = |
| + TEXFONTSIZE(font_size != 0.0? font_size : DEFAULT_FONT_SIZE); |
| + |
| + unitlength = mag/ppi; |
| + dash_mag /= unitlength*80.0; |
| + |
| + translate_coordinates = translate2; |
| + translate_coordinates_d = translate2_d; |
| + |
| + TRANS2(llx, lly, urx, ury); |
| + if (llx > urx) SWAP(llx, urx) |
| + if (lly > ury) SWAP(lly, ury) |
| + |
| + /* LaTeX start */ |
| + |
| + /* print any whole-figure comments prefixed with "%" */ |
| + if (objects->comments) { |
| + fprintf(tfp,"%%\n"); |
| + print_comments("% ",objects->comments, ""); |
| + fprintf(tfp,"%%\n"); |
| + } |
| + |
| + lUnitLength = (long) (round(4736286.72*unitlength)); |
| + fprintf(tfp, "\\setlength{\\unitlength}{%lisp}%%\n", |
| + lUnitLength); |
| + /* define the SetFigFont macro */ |
| + define_setfigfont(tfp); |
| + |
| + sprintf(szFileName + iLength, ".size"); |
| + fprintf(ptCreateFile, "if [ \"$iOptRemove\" == \"\" ]; then\n"); |
| + if (iPdfOutputs) |
| + fprintf(ptCreateFile, " echo \"\\setlength\\pdfpagewidth{%3.2fpt}\\setlength\\pdfpageheight{%3.2fpt}\" > %s\n", |
| + (float) lUnitLength / 65536 * (urx - llx), (float) lUnitLength / 65536 * (ury - lly), szFileName); |
| + else |
| + fprintf(ptCreateFile, "echo -n\"\" > %s\n", szFileName); |
| + fprintf(ptCreateFile, "else\n rm -f %s\nfi\n", szFileName); |
| +} |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +void genpdftex_p_start(objects) |
| + F_compound *objects; |
| +{ |
| + iPdfOutputs = 1; |
| + genpstex_p_start(objects); |
| +} |
| + |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +int genpstex_p_end() |
| +{ |
| + if (iTextRead) |
| + { |
| + fprintf(tfp, "\\end{picture}%%\n"); |
| + iTextRead = 0; |
| + } |
| + if (iObjectsRead) |
| + { |
| + genpstex_p_finalize_objects(iLastDepth); |
| + iObjectsRead = 0; |
| + } |
| + |
| + /* LaTeX ending */ |
| + fprintf(tfp, "\\begin{picture}(%d,%d)\n", urx-llx, ury-lly); |
| + fprintf(tfp, "\\end{picture}%%\n"); |
| + |
| + fclose(ptCreateFile); |
| + |
| + /* all ok */ |
| + return 0; |
| +} |
| + |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +void genpstex_p_finalize_objects(depth) |
| +int depth; |
| +{ |
| + char szFileName[1000]; |
| + int iLength; |
| + |
| + strncpy(szFileName, pstex_file, 900); |
| + iLength = strlen(szFileName); |
| + |
| + |
| + sprintf(szFileName + iLength, "%03d", iObjectsFileNumber++); |
| + fprintf(ptCreateFile, "if [ \"$iOptRemove\" == \"\" ]; then\n"); |
| + if (iPdfOutputs) |
| + { |
| + fprintf(ptCreateFile, " %s -L pstex -D +%d:%d %s", prog, depth, iStartDepth, from, szFileName); |
| + fprintf(ptCreateFile, " | epstopdf -f --outfile %s.pdf\n", szFileName, szFileName); |
| + } |
| + else |
| + fprintf(ptCreateFile, "%s -L pstex -D +%d:%d %s %s.eps\n", prog, depth, iStartDepth, from, szFileName); |
| + fprintf(ptCreateFile, "else\n rm -f %s.", szFileName); |
| + if (iPdfOutputs) |
| + fprintf(ptCreateFile, "pdf"); |
| + else |
| + fprintf(ptCreateFile, "eps"); |
| + fprintf(ptCreateFile, "\nfi\n"); |
| + |
| + fprintf(tfp, "\\begin{picture}(0,0)%%\n"); |
| +/* newer includegraphics directive suggested by Stephen Harker 1/13/99 */ |
| +#if defined(LATEX2E_GRAPHICS) |
| +# if defined(EPSFIG) |
| + fprintf(tfp, "\\epsfig{file=%s.eps}%%\n",szFileName); |
| +# else |
| + fprintf(tfp, "\\includegraphics{%s}%%\n",szFileName); |
| +# endif |
| +#else |
| + fprintf(tfp, "\\special{psfile=%s.eps}%%\n",szFileName); |
| +#endif |
| + fprintf(tfp, "\\end{picture}%%\n"); |
| +} |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +void genpstex_p_object(depth) |
| +int depth; |
| +{ |
| + if (iTextRead) |
| + { |
| + fprintf(tfp, "\\end{picture}%%\n"); |
| + iTextRead = 0; |
| + } |
| + if (iObjectsRead == 0) |
| + { |
| + iStartDepth = depth; |
| + iObjectsRead = 1; |
| + } |
| + iLastDepth = depth; |
| + |
| +} |
| + |
| +void genpstex_p_arc(obj) |
| +F_arc *obj; |
| +{ |
| + genpstex_p_object(obj->depth); |
| +} |
| + |
| + |
| +void genpstex_p_ellipse(obj) |
| +F_ellipse *obj; |
| +{ |
| + genpstex_p_object(obj->depth); |
| +} |
| + |
| +void genpstex_p_line(obj) |
| +F_line *obj; |
| +{ |
| + genpstex_p_object(obj->depth); |
| +} |
| + |
| +void genpstex_p_spline(obj) |
| +F_spline *obj; |
| +{ |
| + genpstex_p_object(obj->depth); |
| +} |
| + |
| + |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| +void genpstex_p_text(t) |
| +F_text *t; |
| +{ |
| + |
| + if (!special_text(t)) |
| + genpstex_p_object(t->depth); |
| + else |
| + { |
| + if (iObjectsRead) |
| + { |
| + genpstex_p_finalize_objects(iLastDepth); |
| + iObjectsRead = 0; |
| + } |
| + if (iTextRead == 0) |
| + { |
| + fprintf(tfp, "\\begin{picture}(0,0)(%d,%d)\n", llx, lly); |
| + iTextRead = 1; |
| + } |
| + genlatex_text(t); |
| + } |
| + |
| +} |
| + |
| +/************************************************************************* |
| + *************************************************************************/ |
| void genpstex_t_option(opt, optarg) |
| char opt, *optarg; |
| { |
| @@ -112,6 +412,8 @@ |
| else genlatex_text(t); |
| } |
| |
| +/************************************************************************* |
| + *************************************************************************/ |
| void genpstex_text(t) |
| F_text *t; |
| { |
| @@ -128,6 +430,32 @@ |
| genlatex_option(opt, optarg); |
| } |
| |
| +struct driver dev_pstex_p = { |
| + genpstex_p_option, |
| + genpstex_p_start, |
| + gendev_null, |
| + genpstex_p_arc, |
| + genpstex_p_ellipse, |
| + genpstex_p_line, |
| + genpstex_p_spline, |
| + genpstex_p_text, |
| + genpstex_p_end, |
| + INCLUDE_TEXT |
| +}; |
| + |
| +struct driver dev_pdftex_p = { |
| + genpstex_p_option, |
| + genpdftex_p_start, |
| + gendev_null, |
| + genpstex_p_arc, |
| + genpstex_p_ellipse, |
| + genpstex_p_line, |
| + genpstex_p_spline, |
| + genpstex_p_text, |
| + genpstex_p_end, |
| + INCLUDE_TEXT |
| +}; |
| + |
| struct driver dev_pstex_t = { |
| genpstex_t_option, |
| genpstex_t_start, |
| |
| === modified file 'fig2dev/drivers.h' |
| --- fig2dev/drivers.h 2010-09-28 13:22:38 +0000 |
| +++ fig2dev/drivers.h 2010-09-28 13:29:46 +0000 |
| @@ -30,8 +30,10 @@ |
| extern struct driver dev_pdf; |
| extern struct driver dev_pdftex; |
| extern struct driver dev_pdftex_t; |
| +extern struct driver dev_pdftex_p; |
| extern struct driver dev_pstex; |
| extern struct driver dev_pstex_t; |
| +extern struct driver dev_pstex_p; |
| extern struct driver dev_pstricks; |
| extern struct driver dev_textyl; |
| extern struct driver dev_tk; |
| @@ -75,6 +77,7 @@ |
| {"pdf", &dev_pdf}, |
| {"pdftex", &dev_pdftex}, |
| {"pdftex_t", &dev_pdftex_t}, |
| + {"pdftex_p", &dev_pdftex_p}, |
| {"pic", &dev_pic}, |
| {"pictex", &dev_pictex}, |
| {"png", &dev_bitmaps}, |
| @@ -82,6 +85,7 @@ |
| {"ps", &dev_ps}, |
| {"pstex", &dev_pstex}, |
| {"pstex_t", &dev_pstex_t}, |
| + {"pstex_p", &dev_pstex_p}, |
| {"pstricks", &dev_pstricks}, |
| {"ptk", &dev_ptk}, |
| {"shape", &dev_shape}, |
| |
| === modified file 'fig2dev/fig2dev.c' |
| --- fig2dev/fig2dev.c 2010-09-28 13:22:38 +0000 |
| +++ fig2dev/fig2dev.c 2010-09-28 13:26:39 +0000 |
| @@ -649,6 +649,18 @@ |
| #endif /* NFSS */ |
| printf(" -p name name of the PostScript file to be overlaid\n"); |
| |
| + printf("PSTEX_P and PDFTEX_P Options:\n"); |
| + printf(" -p name basename of the files to be created\n"); |
| +#ifdef NFSS |
| + printf(" -F don't set font family/series/shape, so you can\n"); |
| + printf(" set it from latex\n"); |
| +#endif /* NFSS */ |
| + printf(" -d dmag set separate magnification for length of line dashes to dmag\n"); |
| + printf(" -E num set encoding for text translation (0 no translation,\n"); |
| + printf(" 1 ISO-8859-1, 2 ISO-8859-2)\n"); |
| + printf(" -l lwidth set threshold between thin and thick lines to lwidth\n"); |
| + printf(" -v verbose mode\n"); |
| + |
| printf("SHAPE (ShapePar driver) Options:\n"); |
| printf(" -n name Set basename of the macro (e.g. \"face\" gives faceshape and facepar)\n"); |
| printf("Tcl/Tk (tk) and Perl/Tk (ptk) Options:\n"); |
| @@ -776,6 +788,12 @@ |
| int rec_comp(r1, r2) |
| struct obj_rec *r1, *r2; |
| { |
| + if (r2->depth == r1->depth) |
| + { |
| + if ((r1->gendev == dev->text) ^ (r2->gendev == dev->text)) |
| + return ((r1->gendev == dev->text) * 2 - 1); |
| + return (0); |
| + } |
| return (r2->depth - r1->depth); |
| } |
| |
| |