debian/0000775000000000000000000000000013343260143007167 5ustar debian/watch0000664000000000000000000000031012227260650010215 0ustar # See uscan(1) for format # Compulsory line, this is a version 3 file version=3 opts="dversionmangle=s/-rel$//,uversionmangle=s/([a-z])$/.$1/" http://www.xfig.org/art17.html .*/transfig.(.*).tar.gz debian/source/0000775000000000000000000000000012227260651010473 5ustar debian/source/format0000664000000000000000000000001412227260650011700 0ustar 3.0 (quilt) debian/dirs0000664000000000000000000000011312227260650010051 0ustar usr/share/xfig usr/share/doc/transfig/fig2mpdf usr/share/lintian/overrides debian/compat0000664000000000000000000000000212227260650010370 0ustar 7 debian/README.Debian0000664000000000000000000000211612227260647011241 0ustar transfig for DEBIAN ------------------- Metafont support ================ If you want to use the mf (metafont) output language, you need the grafbase.mf (not graphbase.mf!), which is available from CTAN: graphics/mfpic/source/grafbase.mf CGM support =========== To use the -b (binary) option for CGM export, the ralcgm program is required. This is currently not available as a Debian package, but you may download the sources from ftp://ftp.cc.rl.ac.uk/pub/graphics/ralcgm/ pstex ===== There are many people heaving problems with the pstex driver. The problem is, that newer versions of transfig need \usepackage{color} to work with pstex. So simply add \usepackage{graphicx} and \usepackage{color} to your LaTeX file before using pstex and everything should work correct. Big LaTeX fonts =============== If you want to use LaTeX fonts bigger than 42pt, you have to add \usepackage{type1cm} to your LaTeX file, which switches over to the Type1 vector fonts, that are available in all sizes. Roland Rosenfeld $Id: README.Debian,v 1.6 2006/07/23 12:34:40 roland Exp $ debian/override.Lintian0000664000000000000000000000036012227260650012330 0ustar transfig: capitalization-error-in-description tk Tk transfig: capitalization-error-in-description latex LaTeX transfig: spelling-error-in-binary usr/bin/fig2dev yur your transfig: spelling-error-in-binary usr/bin/fig2dev ReEncode Re-encode debian/docs0000664000000000000000000000010012227260650010034 0ustar LATEX.AND.XFIG NOTES README doc/tpic.spec doc/manual/manual.pdf debian/patches/0000775000000000000000000000000013343260007010615 5ustar debian/patches/02_ru_RU.KOI8-R.patch0000664000000000000000000000072612227260650014114 0ustar Author: Roland Rosenfeld Description: Add ru_RU.KOI8-R.ps for russion KOI8-R output (Closes: #310738). Bug-Debian: http://bugs.debian.org/310738 --- a/fig2dev/dev/Imakefile +++ b/fig2dev/dev/Imakefile @@ -69,5 +69,6 @@ $(LN) cs_CZ.ps hr_HR.ps; $(LN) cs_CZ.ps hu_HU.ps; \ $(LN) cs_CZ.ps ro_RO.ps; $(LN) cs_CZ.ps pl_PL.ps; \ $(LN) cs_CZ.ps sk_SK.ps; $(LN) cs_CZ.ps sl_SI.ps ) + InstallNonExecFile(ru_RU.KOI8-R.ps,FIG2DEV_LIBDIR) #endif debian/patches/13_remove_extralibs.patch0000664000000000000000000000073412227260650015523 0ustar Author: Roland Rosenfeld Description: Remove unnecessary dependencies on libz and libX11. --- a/fig2dev/Imakefile +++ b/fig2dev/Imakefile @@ -154,12 +154,12 @@ #ifdef USEPNG DUSEPNG = -DUSE_PNG -PNGLIBS = -L$(PNGLIBDIR) -lpng -L$(ZLIBDIR) -lz +PNGLIBS = -L$(PNGLIBDIR) -lpng #endif /* USEPNG */ #ifdef USEXPM DUSEXPM = -DUSE_XPM -XPMLIBS = -L$(XPMLIBDIR) -lXpm -lX11 +XPMLIBS = -L$(XPMLIBDIR) -lXpm #endif /* USEXPM */ #if defined(NOSTRSTR) debian/patches/CVE-2018-16140.patch0000664000000000000000000000743413343242514013327 0ustar Backported of: From e0c4b02429116b15ad1568c2c425f06b95b95830 Mon Sep 17 00:00:00 2001 From: Thomas Loimer Date: Sat, 25 Aug 2018 20:46:45 +0200 Subject: [PATCH] Harden input in read.c, fixes tickets #27 and #28 Also fixes issues similar to those described in https://sourceforge.net/p/mcj/tickets/27 and https://sourceforge.net/p/mcj/tickets/28. diff --git a/fig2dev/dev/readpcx.c b/fig2dev/dev/readpcx.c index 5b2d3d0..74dee84 100755 --- a/fig2dev/dev/readpcx.c +++ b/fig2dev/dev/readpcx.c @@ -86,8 +86,6 @@ _read_pcx(pcxfile,pic) fprintf(tfp, "%% Begin Imported PCX File: %s\n\n", pic->file); pic->subtype = P_PCX; - pic->bitmap=NULL; - fread(&header,1,sizeof(struct pcxhed),pcxfile); if (header.manuf!=10 || header.encod!=1) return 0; diff --git a/fig2dev/read.c b/fig2dev/read.c index c1823b0..8a33d3e 100755 --- a/fig2dev/read.c +++ b/fig2dev/read.c @@ -189,12 +189,23 @@ F_compound *obj; bzero((char*)obj, COMOBJ_SIZE); (void) fgets(buf, BUF_SIZE, fp); /* get the version line */ + if (strncmp(buf, "#FIG ", 5)) { + put_msg("Incorrect format string in first line of input file."); + return -1; + } + + /* remove newline and any carriage return (from a PC, perhaps) */ len = strlen(buf); - if (len > 0) - buf[len-1] = '\0'; /* remove newline */ - if (buf[len-2] == '\r') - buf[len-2] = '\0'; /* and any CR (from a PC perhaps) */ + if (buf[len-1] == '\n') { + if (buf[len-2] == '\r') + buf[len-2] = '\0'; + else + buf[len-1] = '\0'; + } else { /* fgets() only stops at newline and end-of-file */ + put_msg("File is truncated at first line."); + return -1; + } /* v2_flag is for version 2 or higher */ v2_flag = (!strncmp(buf, "#FIG 2", 6) || !strncmp(buf, "#FIG 3", 6)); /* v21_flag is for version 2.1 or higher */ @@ -745,6 +756,8 @@ FILE *fp; l->next = NULL; l->join_style = 0; l->cap_style = 0; /* butt line cap */ + l->pic = NULL; + l->comments = NULL; sscanf(buf,"%*d%d",&l->type); /* get the line type */ @@ -809,12 +822,18 @@ FILE *fp; l->back_arrow = make_arrow(type, style, thickness, wid, ht); } if (l->type == T_PIC_BOX) { - Pic_malloc(l->pic); - l->pic->transp = -1; - if (l->pic == NULL) { + if ((Pic_malloc(l->pic)) == NULL) { free((char *) l); return (NULL); } + l->pic->transp = -1; + l->pic->bitmap = NULL; +#ifdef HAVE_X11_XPM_H + /* initialize l->pic->xpmimage by (ab)using a + public libxpm-function */ + XpmCreateXpmImageFromBuffer("", &l->pic->xpmimage, NULL); +#endif + if (get_line(fp) < 0 || sscanf(buf, "%d %[^\n]", &l->pic->flipped, file) != 2) { put_msg(Err_incomp, @@ -837,9 +856,8 @@ FILE *fp; } else { strcpy(l->pic->file, file); } - } else - l->pic = NULL; - + } + if (NULL == (l->points = Point_malloc(p))) { put_msg(Err_mem); return(NULL); @@ -903,6 +921,7 @@ FILE *fp; s->fill_style = 0; s->for_arrow = NULL; s->back_arrow = NULL; + s->comments = NULL; s->next = NULL; if (v30_flag) { @@ -1075,6 +1094,7 @@ FILE *fp; Text_malloc(t); t->font = 0; t->size = 0.0; + t->comments = NULL; t->next = NULL; if (v30_flag) { /* order of parms is more like other objects now, @@ -1316,11 +1336,12 @@ get_line(fp) if (*buf == '#') { /* save any comments */ if (save_comment(fp) < 0) return -1; - } else if (*buf != '\n') { /* Skip empty lines */ + /* skip empty lines */ + } else if (*buf != '\n' || !(*buf == '\r' && buf[1] == '\n')) { len = strlen(buf); - buf[len-1] = '\0'; /* strip trailing newline */ - if (buf[len-2] == '\r') - buf[len-2] = '\0'; /* strip any trailing CRs */ + /* remove newline and possibly a carriage return */ + if (buf[len-1] == '\n') + buf[len - (buf[len-2] == '\r' ? 2 : 1)] = '\0'; return 1; } } debian/patches/series0000664000000000000000000000071413343260007012034 0ustar 01_manual_fixup.patch 02_ru_RU.KOI8-R.patch 03_Imakefile_Debian.patch 04_displaywho.patch 05_locale.patch 06_gen_manual.patch 08_genps_oldpatterns.patch 09_maxfontsize.patch 13_remove_extralibs.patch 14_fig2mpdf.patch 15_fig2mpdf-doc.patch 18_fig2ps2tex_bashisms.patch 20_transfig_pdftex.patch 21_rename_optopt.patch 22_typos.patch 28_fix_fig2dev_chmod.patch #29_implict-declaration.patch 30_fprintf_format.patch 31_index_not_static.patch CVE-2018-16140.patch debian/patches/22_typos.patch0000664000000000000000000000144112227260650013323 0ustar Author: Roland Rosenfeld Description: Fix some spelling errors in the binaries --- a/fig2dev/dev/readgif.c +++ b/fig2dev/dev/readgif.c @@ -151,7 +151,7 @@ if (c == '!') { /* Extension */ if (! ReadOK(file,&c,1)) - fprintf(stderr,"GIF read error on extention function code\n"); + fprintf(stderr,"GIF read error on extension function code\n"); (void) DoGIFextension(file, c); continue; } --- a/fig2dev/read.c +++ b/fig2dev/read.c @@ -109,7 +109,7 @@ /* Format error; relevant error message is already delivered */ } else - put_msg("File \"%s\" is not accessable; %s", file, strerror(err)); + put_msg("File \"%s\" is not accessible; %s", file, strerror(err)); } /********************************************************** debian/patches/01_manual_fixup.patch0000664000000000000000000003773512227260650014651 0ustar Author: Roland Rosenfeld Description: Escape hyphen '-' in man pages --- a/doc/fig2dev.1 +++ b/doc/fig2dev.1 @@ -63,9 +63,9 @@ Notes: .br .I dvips -and + and .I xdvi -must be compiled with the tpic support (-DTPIC) for epic, eepic and tpic to work. +must be compiled with the tpic support (\-DTPIC) for epic, eepic and tpic to work. .br You must have ghostscript and ps2pdf, which comes with the ghostscript distribution to get the pdf output and the bitmap formats (png, jpeg, etc.), and the netpbm (pbmplus) @@ -81,16 +81,16 @@ .TP .B "\-D +/-rangelist" -With +rangelist, keep only those depths in the list. With -rangelist, keep all +With +rangelist, keep only those depths in the list. With \-rangelist, keep all depths except those in the list. The rangelist may be a list of comma-separated -numbers or ranges separated by colon (:). For example, -D +10,40,55:70,80 +numbers or ranges separated by colon (:). For example, \-D +10,40,55:70,80 means keep only layers 10, 40, 55 \fBthrough\fR 70, and 80. .TP -.B -K -The selection of the depths with the '-D +/-rangelist' option does normally not +.B \-K +The selection of the depths with the '\-D +/\-rangelist' option does normally not affect the calcualtion of the bounding box. Thus the generated document might -have a much larger bounding box than necessary. If -K is given then the +have a much larger bounding box than necessary. If \-K is given then the bounding box is adjusted to include only those objects in the selected depths. .TP @@ -107,10 +107,10 @@ .TP .B "\-G minor[:major][:unit]" Draws a grid on the page. Specify thin, or thin and thick line -spacing in one of several units. For example, "-G .25:1cm" draws a thin, +spacing in one of several units. For example, "\-G .25:1cm" draws a thin, gray line every .25 cm and a thicker gray line every 1 cm. Specifying -"-G 1in" draws a thin line every 1 inch. -Fractions may be used, e.g. "-G 1/16:1/2in" will draw a thin line every +"\-G 1in" draws a thin line every 1 inch. +Fractions may be used, e.g. "\-G 1/16:1/2in" will draw a thin line every 1/16 inch (0.0625 inch) and a thick line every 1/2 inch. .br Allowable units are: i, in, inch, f, ft, feet, c, cm, mm, and m. @@ -126,7 +126,7 @@ Set the magnification at which the figure is rendered to .I mag. The default is 1.0. -This may not be used with the maxdimension option (-Z). +This may not be used with the maxdimension option (\-Z). .TP .B "\-s size" @@ -141,7 +141,7 @@ .I maxdimension inches or cm, depending on whether the figure was saved with imperial or metric units. -This may not be used with the magnification option (-m). +This may not be used with the magnification option (\-m). .TP .I other options @@ -157,7 +157,7 @@ something that they won't do with EPS files that have an ASCII preview. .TP .B "\-b dummyarg" -Generate binary output (dummy argument required after the "-b"). +Generate binary output (dummy argument required after the "\-b"). .TP .B \-r @@ -335,7 +335,7 @@ file. The table must have 21 entries - one for each of the area fill patterns. Each entry consists of 5 numbers which specify the -1.) pattern number (-1 - 6), +1.) pattern number (\-1 - 6), 2.) pattern length (inches), 3.) fill type (1 - 5), 4.) fill spacing (inches) and @@ -390,7 +390,7 @@ .TP .B \-F Use correct font sizes (points, 1/72 inch) instead of the traditional size that xfig/fig2dev uses, -which is (1/80 inch). The corresponding xfig command-line option is -correct_font_size. +which is (1/80 inch). The corresponding xfig command-line option is \-correct_font_size. .TP .B \-g color @@ -403,13 +403,13 @@ Convert all colors to grayscale. .TP -.B -S smoothfactor +.B \-S smoothfactor This will smooth the output by passing .I smoothfactor to ghostscript in the -.I -dTextAlphaBits +.I \-dTextAlphaBits and -.I -dGraphicsAlphaBits +.I \-dGraphicsAlphaBits options to improve font rendering and graphic smoothing. A value of 2 for .I smoothfactor @@ -418,7 +418,7 @@ .SH GIF OPTIONS .TP -.B -t color +.B \-t color Use .I color for the transparent color in the GIF file. This must be specified @@ -428,7 +428,7 @@ .SH JPEG OPTIONS .TP -.B -q image_quality +.B \-q image_quality use the integer value .I image_quality for the JPEG "Quality" factor. Valid values are 0-100, with the default being 75. @@ -495,7 +495,7 @@ .I fig2dev scales the figure by 1/8 before generating METAFONT code. The magnification can be further changed with the -.B -m +.B \-m option or by giving magnification options to .B mf. .LP @@ -506,33 +506,33 @@ under the subdirectory: graphics/mfpic .TP -.B -C code +.B \-C code specifies the starting METAFONT font code. The default is 32. .TP -.B -n name +.B \-n name specifies the name to use in the output file. .TP -.B -p pen_magnification +.B \-p pen_magnification specifies how much the line width should be magnified compared to the original figure. The default is 1. .TP -.B -t top +.B \-t top specifies the top of the whole coordinate system. The default is .B ypos. .TP -.B -x xmin +.B \-x xmin specifies the minimum x coordinate value of the figure (inches). The default is 0. .TP -.B -y ymin +.B \-y ymin specifies the minumum y coordinate value of the figure (inches). The default is 0. .TP -.B -X xmax +.B \-X xmax specifies the maximum x coordinate value of the figure (inches). The default is 8. .TP -.B -Y ymax +.B \-Y ymax specifies the maximum y coordinate value of the figure (inches). The default is 8. @@ -546,7 +546,7 @@ Include file content as additional header. .TP -.B -o +.B \-o Old mode (no latex). .TP @@ -597,15 +597,15 @@ Set encoding for latex text translation (0 no translation, 1 ISO-8859-1, 2 ISO-8859-2) .SH GBX OPTIONS (Gerber, RS-247-X) -Typically you will wish to set the y scale to -1. See -.B -g +Typically you will wish to set the y scale to \-1. See +.B \-g for more information. .TP -.B -d [mm|in] +.B \-d [mm|in] Output dimensions should be assumed to be millimeters (mm) or inches (in). The default is millimeters. .TP -.B -p [pos|neg] +.B \-p [pos|neg] Select the image polarity. For positive images lines drawn in the fig file will generate lines of material. For negative images lines drawn in the fig file will result in removed material. Consider etching a @@ -613,29 +613,29 @@ choosing 'neg' will result in these lines being etched through the chrome, leaving transparent lines. .TP -.B -g x++ +.B \-g x++ This controls the geometry of the output, scaling the dimensions as shown and applying the given offset. Typically you will wish to set -the y scale to -1, mirroring about the x axis. This is because Gerber +the y scale to \-1, mirroring about the x axis. This is because Gerber assumes the origin to be bottom left, while xfig selects top left. .TP -.B -f . +.B \-f . This controls the number of digits of precision before and after the -implied decimal point. With -f 5.3 the following number 12345678 -corresponds to 12345.678. Whereas with -f 3.5 it corresponds to +implied decimal point. With \-f 5.3 the following number 12345678 +corresponds to 12345.678. Whereas with \-f 3.5 it corresponds to 123.45678. The default is for 3 places before the decimal point and 5 after. This corresponds, to a range of 0 to 1m in 10 micron increments. .TP -.B -i [on|off] +.B \-i [on|off] Controls the output of comments describing the type of objects being output. The text appears as comments starting with ## on each line in the output file. By default this is on. .SH POSTSCRIPT, ENCAPSULATED POSTSCRIPT (EPS), and PDF OPTIONS With PostScript, xfig can be used to create multiple page figures -Specify the -M option to produce a multi-page output. -For posters, add -O to overlap the pages slightly to get around the problem of +Specify the \-M option to produce a multi-page output. +For posters, add \-O to overlap the pages slightly to get around the problem of the unprintable area in most printers, then cut and paste the pages together. Due to memory limitations of most laser printers, the figure should not have large imported images (bitmaps). Great for text with very big letters. @@ -658,7 +658,7 @@ .LP The EPS driver has the following two special options: .TP -.B -B 'Wx [Wy X0 Y0]' +.B \-B 'Wx [Wy X0 Y0]' This specifies that the bounding box of the EPS file should have the width Wx and the height Wy. Note that it doesn't scale the figure to this size, it merely sets the bounding box. @@ -667,13 +667,13 @@ screen (0,0) (upper-left). Wx, Wy, X0 and Y0 are interpreted in centimeters or inches depending on the measure given in the fig-file. -Remember to put either quotes (") or apostrophes (') to group the arguments to -B. +Remember to put either quotes (") or apostrophes (') to group the arguments to \-B. .TP -.B -R 'Wx [Wy X0 Y0]' -Same as the -B option except that X0 and Y0 is relative to the lower +.B \-R 'Wx [Wy X0 Y0]' +Same as the \-B option except that X0 and Y0 is relative to the lower left corner of the .B figure. -Remember to put either quotes (") or apostrophes (') to group the arguments to -R. +Remember to put either quotes (") or apostrophes (') to group the arguments to \-R. .LP The PDF driver uses all the PostScript options. .LP @@ -697,106 +697,106 @@ In addition, there are 16 patterns such as bricks, diagonal lines, crosshatch, etc. .TP -.B -A +.B \-A Add an ASCII (EPSI) preview. .TP -.B -b borderwidth +.B \-b borderwidth Make blank border around figure of width .I borderwidth. .br -Not availble in EPS. +Not available in EPS. .TP -.B -C dummy_arg +.B \-C dummy_arg Add a color *binary* TIFF preview for Microsoft products that need a binary preview. -See also -T (monochrome preview). A dummy argument must be supplied for historical reasons. +See also \-T (monochrome preview). A dummy argument must be supplied for historical reasons. .TP -.B -c +.B \-c option centers the figure on the page. The centering may not be accurate if there are texts in the .I fig_file that extends too far to the right of other objects. .TP -.B -e +.B \-e option puts the figure against the edge (not centered) of the page. -Not availble in EPS. +Not available in EPS. .TP -.B -F +.B \-F Use correct font sizes (points) instead of the traditional size that xfig/fig2dev uses, -which is 1/80 inch. The corresponding xfig command-line option is -correct_font_size. +which is 1/80 inch. The corresponding xfig command-line option is \-correct_font_size. .TP -.B -g color +.B \-g color Use .I color for the background. .TP -.B -l dummy_arg +.B \-l dummy_arg Generate figure in landscape mode. The dummy argument is ignored, but must appear on the command line for reasons of compatibility. This option will override the orientation specification in the file (for file versions 3.0 and higher). .br -Not availble in EPS. +Not available in EPS. .TP -.B -M +.B \-M Generate multiple pages if figure exceeds paper size. .br -Not availble in EPS. +Not available in EPS. .TP .B \-N Convert all colors to grayscale. .TP -.B -n name +.B \-n name Set the Title part of the PostScript output to .I name. This is useful when the input to .I fig2dev comes from standard input. .TP -.B -O +.B \-O When used with \fB-M\fR, overlaps the pages slightly to get around the problem of the unprintable area in most printers. .br -Not availble in EPS. +Not available in EPS. .TP -.B -p dummy_arg +.B \-p dummy_arg Generate figure in portrait mode. The dummy argument is ignored, but must appear on the command line for reasons of compatibility. This option will override the orientation specification in the file (for file versions 3.0 and higher). This is the default for Fig files of version 2.1 or lower. .br -Not availble in EPS. +Not available in EPS. .TP -.B -T +.B \-T Add a monochrome *binary* TIFF preview for Microsoft products that need a binary preview. -See also -C (color preview). +See also \-C (color preview). .TP .TP -.B -x offset +.B \-x offset shift the figure in the X direction by .I offset units (1/72 inch). A negative value shifts the figure to the left and a positive value to the right. .br -Not availble in EPS. +Not available in EPS. .TP -.B -y offset +.B \-y offset shift the figure in the Y direction by .I offset units (1/72 inch). A negative value shifts the figure up and a positive value down. .br -Not availble in EPS. +Not available in EPS. .TP -.B -z papersize +.B \-z papersize Sets the papersize. -Not availble in EPS. +Not available in EPS. .br Available paper sizes are: .nf @@ -839,17 +839,17 @@ special text. .TP -.B -F +.B \-F Use correct font sizes (points) instead of the traditional size that xfig/fig2dev uses, -which is 1/80 inch. The corresponding xfig command-line option is -correct_font_size. +which is 1/80 inch. The corresponding xfig command-line option is \-correct_font_size. .TP -.B -g color +.B \-g color Use .I color for the background. .TP -.B -n name +.B \-n name sets the Title part of the PostScript output to .I name. This is useful when the input to @@ -876,7 +876,7 @@ LaTeX document. With this option on, you can set the font from your LaTeX document (like "\fB\\sfshape \\input picture.eepic\fR"). .TP -.B -p file +.B \-p file specifies the name of the PostScript file to be overlaid. If not set or its value is null then no PS file will be inserted. @@ -977,7 +977,7 @@ .TP .B \-P Shorthand for -.B -n 3 +.B \-n 3 . .TP @@ -992,7 +992,7 @@ directory! Don't put your stuff here. The .B includegraphics commands in the output file refer to this directory. Even -if the -p option is not used, +if the \-p option is not used, .B includegrpahics commands follow this convention with the default directory .I "\./eps". @@ -1064,26 +1064,26 @@ .SH TK and PTK OPTIONS (tcl/tk and Perl/tk) .TP -.B -l dummy_arg +.B \-l dummy_arg Generate figure in landscape mode. The dummy argument is ignored, but must appear on the command line for reasons of compatibility. This option will override the orientation specification in the file (for file versions 3.0 and higher). .TP -.B -p dummy_arg +.B \-p dummy_arg Generate figure in portrait mode. The dummy argument is ignored, but must appear on the command line for reasons of compatibility. This option will override the orientation specification in the file (for file versions 3.0 and higher). This is the default for Fig files of version 2.1 or lower. .TP -.B -P +.B \-P Generate canvas of full page size instead of using the bounding box of the figure's objects. The default is to use only the bounding box. .TP -.B -z papersize +.B \-z papersize Sets the papersize. See the POSTSCRIPT OPTIONS for available paper sizes. -This is only used when the -P option (use full page) is used. +This is only used when the \-P option (use full page) is used. .SH "SEE ALSO" [x]fig(1), --- a/doc/transfig.1 +++ b/doc/transfig.1 @@ -3,11 +3,11 @@ transfig \- creates a makefile for portable LaTeX figures .SH SYNOPSIS .B transfig -[ -L \fIlanguage\fR ] -[ -M \fImakefile\fR ] -[ -T \fItexfile\fR ] -[ -I \fImacrofile\fR ] -[ -V ] +[ \-L \fIlanguage\fR ] +[ \-M \fImakefile\fR ] +[ \-T \fItexfile\fR ] +[ \-I \fImacrofile\fR ] +[ \-V ] [ \fIcontrol_specs\fR figfile ... ] .SH DESCRIPTION .I Transfig @@ -76,13 +76,13 @@ is the default. .PP The names of the makefile and TeX macro file can be set with the --M and -T options. +\-M and \-T options. The default names are "Makefile" and "transfig.tex", respectively. If there is already an existing \fImakefile\fR in the directory, transfig first renames it to \fImakefile~\fR. The same holds for any existing TeX macro file. -If the -I option is specified, then a command to read in \fImacrofile\fR is +If the \-I option is specified, then a command to read in \fImacrofile\fR is inserted into the TeX macro file. -If the -V option is specified, the program version number is printed only. +If the \-V option is specified, the program version number is printed only. .PP Control specifiers are .TP debian/patches/30_fprintf_format.patch0000664000000000000000000000266712107157632015201 0ustar Author: Roland Rosenfeld Description: Add a format string to fprintf()/sprintf() call instead of directly printing out Err_Mem. This is needed by harding options. --- a/fig2dev/trans_spline.c +++ b/fig2dev/trans_spline.c @@ -648,7 +648,7 @@ F_control *cp; if ((cp = (F_control *) malloc(CONTROL_SIZE)) == NULL) - fprintf(stderr,Err_mem); + fprintf(stderr, "%s", Err_mem); return cp; } @@ -659,7 +659,7 @@ F_line *l; if ((l = (F_line *) malloc(LINOBJ_SIZE)) == NULL) - fprintf(stderr,Err_mem); + fprintf(stderr, "%s", Err_mem); l->pic = NULL; l->next = NULL; l->for_arrow = NULL; --- a/fig2dev/dev/gencgm.c +++ b/fig2dev/dev/gencgm.c @@ -139,7 +139,7 @@ if (from) { figname = malloc(strlen(from)+1); - sprintf(figname, from); + sprintf(figname, "%s", from); p = strrchr(figname, '/'); if (p) figname = p+1; /* remove path from name for comment in file */ --- a/fig2dev/dev/genmp.c +++ b/fig2dev/dev/genmp.c @@ -1150,7 +1150,7 @@ } } else { /* special text in latex mode: just write the text. */ - fprintf(tfp, t->cstring); + fprintf(tfp, "%s", t->cstring); } fprintf(tfp," etex;\n"); @@ -1164,7 +1164,7 @@ fprintf(tfp," picture q;\n"); fprintf(tfp," q=thelabel.urt(\""); - fprintf(tfp, t->cstring); + fprintf(tfp, "%s", t->cstring); fprintf(tfp, "\" infont "); if (t->font<0) { fprintf(tfp, "defaultfont"); debian/patches/03_Imakefile_Debian.patch0000664000000000000000000000424312227260650015277 0ustar Author: Roland Rosenfeld Description: Change several paths to fit Debian needs. Modify some settings for the Debian package. --- a/fig2dev/Imakefile +++ b/fig2dev/Imakefile @@ -34,7 +34,7 @@ XCOMM You should point XFIGLIBDIR to the same directory you did when you compiled XCOMM and installed xfig. -XFIGLIBDIR = /usr/local/lib/X11/xfig +XFIGLIBDIR = /usr/share/xfig XCOMM ****** XCOMM If your system doesn't have the strerror() function (has sys_errlist) then @@ -53,7 +53,7 @@ XCOMM inline functions. With the "INLINE" keyword, you should notice that XCOMM the display will be a bit faster in complex figures -XCOMM USEINLINE = -DUSE_INLINE +USEINLINE = -DUSE_INLINE XCOMM **************** XCOMM Change RGB if necessary, to point to your rgb.txt color database @@ -62,7 +62,7 @@ XCOMM the full name (rgb.txt) now. XCOMM -RGB = $(LIBDIR)/rgb.txt +RGB = /etc/X11/rgb.txt XCOMM Comment out the following #define USEPNG if you don't want PNG support XCOMM Uncomment the #define for USEPNG if you want to be able to import @@ -97,7 +97,7 @@ XCOMM **************** XCOMM Uncomment the following to set default paper size to A4 -XCOMM DDA4 = -DA4 +DDA4 = -DA4 XCOMM **************** XCOMM Uncomment the following to set IBM Graphics Enhancement Cartridge @@ -141,7 +141,7 @@ #ifdef I18N I18N_DEFS = -DI18N -FIG2DEV_LIBDIR = /usr/local/lib/fig2dev +FIG2DEV_LIBDIR = /usr/share/xfig/fig2dev I18N_DEV_DEFS = $(I18N_DEFS) -DFIG2DEV_LIBDIR=$(FIG2DEV_LIBDIR) -DFIG2DEV_LIBDIR_STR=\\\"$(FIG2DEV_LIBDIR)\\\" #endif /* I18N */ @@ -229,7 +229,7 @@ else (set -x; $(MKDIRHIER) $(DESTDIR)$(XFIGLIBDIR)/bitmaps ); fi ; \ echo Copying bitmap files for tk to $(DESTDIR)$(XFIGLIBDIR)/bitmaps ; \ for f in * ; do \ - $(INSTALL) -c $$f $(DESTDIR)$(XFIGLIBDIR)/bitmaps ; \ + $(INSTALL) -m644 $$f $(DESTDIR)$(XFIGLIBDIR)/bitmaps ; \ done) ; install.all:: --- a/transfig/Imakefile +++ b/transfig/Imakefile @@ -32,7 +32,7 @@ XCOMM \\usepackage{} command for LaTeX2e. XCOMM The default is to use \\documentstyle{} for LaTeX209. -XCOMM USELATEX2E = -DLATEX2E +USELATEX2E = -DLATEX2E XCOMM ******* DON'T CHANGE ANYTHING BELOW THIS POINT ******* debian/patches/09_maxfontsize.patch0000664000000000000000000000335312227260650014525 0ustar Author: Roland Rosenfeld Description: For fonts >=42pt use the given font size in TeX instead of restricting this to 42pt. This allows to create posters using \usepackage{type1cm}. See http://linuxgazette.vlsm.org/issue96/artime.html and Bug#343139 Bug-Debian: http://bugs.debian.org/343139 --- a/LATEX.AND.XFIG +++ b/LATEX.AND.XFIG @@ -55,7 +55,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX Preamble %%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\documentstyle[12pt,bezier,amstex]{article} % include bezier curves +\documentclass[12pt,bezier,amstex]{article} % include bezier curves \renewcommand\baselinestretch{1.0} % single space \pagestyle{empty} % no headers and page numbers \oddsidemargin -10 true pt % Left margin on odd-numbered pages. @@ -72,7 +72,9 @@ \usepackage{epsfig} \usepackage{graphicx} % Graphics package - + +\usepackage{type1cm} % Necessary for fonts bigger than 42pt + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Document Beginning %%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --- a/fig2dev/dev/texfonts.h +++ b/fig2dev/dev/texfonts.h @@ -83,9 +83,11 @@ #endif #define TEXFONT(F) (texfontnames[((F) <= MAX_FONT) ? (F) : (MAX_FONT-1)]) - +/* #define TEXFONTSIZE(S) (texfontsizes[((S) <= MAXFONTSIZE) ? (int)(round(S))\ : (MAXFONTSIZE-1)]) +*/ +#define TEXFONTSIZE(S) (((S) <= MAXFONTSIZE) ? texfontsizes[(int)(round(S))] : (S)) #define TEXFONTMAG(T) TEXFONTSIZE(T->size*(rigid_text(T) ? 1.0 : fontmag)) void setfigfont( F_text *text ); /* genepic.c */ debian/patches/31_index_not_static.patch0000664000000000000000000000064212226747064015515 0ustar Author: YunQiang Su Description: index() is not static, otherwise transfig is liked with -L/usr/lib (Closes: #722857) Bug-Debian: http://bugs.debian.org/722857 --- a/fig2dev/getopt.c +++ b/fig2dev/getopt.c @@ -36,7 +36,7 @@ #define ENDARGS "--" /* this is included because index is not on some UNIX systems */ -static char * +char * index (s, c) register char *s; register int c; debian/patches/14_fig2mpdf.patch0000664000000000000000000011717212227260650013655 0ustar Author: Michael Pfeiffer Description: creating multilayered or singlelayer PDF or EPS figures for including into LaTeX documents. Origin: http://p3f.gmxhome.de/fig2mpdf/fig2mpdf.html --- a/doc/fig2dev.1 +++ b/doc/fig2dev.1 @@ -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) --- a/fig2dev/dev/genpstex.c +++ b/fig2dev/dev/genpstex.c @@ -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 > %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, --- a/fig2dev/drivers.h +++ b/fig2dev/drivers.h @@ -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}, --- a/fig2dev/fig2dev.c +++ b/fig2dev/fig2dev.c @@ -651,6 +651,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"); @@ -778,6 +790,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); } --- /dev/null +++ b/fig2mpdf/copyright.txt @@ -0,0 +1,25 @@ +The following files contain copyright and license info for +the code they contain: +fig2mpdf, fig2mpdf.1, transfig.3.2.4.patch, transfig-3.2.5-alpha7.patch + +-- fig2mpdf copyright begins here -- + + fig2mpdf/pdftex_p and pstex_p driver of fig2dev + Copyright (C) 2006 Michael Pfeiffer -- p3fff@web.de + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + (Author's note: the license is in the file gpl.txt, which is included + in the archive.) --- /dev/null +++ b/fig2mpdf/fig2mpdf @@ -0,0 +1,653 @@ +#!/bin/sh + +unset POSIXLY_CORRECT + +gawk ' +######################################################################### +######################################################################### +BEGIN { + + cmdGawk = "gawk"; + cmdCat = "cat"; + cmdLess = "less"; + cmdRm = "rm" + cmdMv = "mv" + cmdLatex = "latex"; + cmdPdftex = "pdflatex"; + cmdEpsToPdf = "epstopdf"; + cmdDvips = "dvips"; + cmdFig2dev = "fig2dev"; + cmdTouch = "touch"; + + szVersion = "1.1.2"; + iError = 0; + iGapWidth = 1; + + + # get the options + szOptString = "&l%e&m$p%i%I$s$H$g%G%v%V%d"; + getopt(szOptString); + + if (aOptions["d"]) + { + aOptions["v"] = "-"; + for (iI = 0; iI < ARGC; iI++) + printf("ARGV[%d]=%s\n", iI, ARGV[iI]); + + iDim = split(szOptString, aOpts, "[$%&]"); + for (iI = 2; iI <= iDim; iI++) + debug("aOptions[%s] = >%s<\n", aOpts[iI], aOptions[aOpts[iI]]); + } + + + + if (aOptions["V"] != "") + { + printf("fig2mpdf: version %s\n", szVersion); + iError = 1; + exit(0); + } + + szTmpPrefix = "_fig2mpdf" + + iLine = -1; + iInString = 0; + iDepths = 1; + + iInvalidDepth = -2 + iAdminDepth = 2000 + + szBase = ARGV[1]; + szOrigFile = ARGV[1]; + szOrigPath = ARGV[1]; + + # set default switch state + iDoMultiLayer = 0; + iDoLatex = 0; + iDoPdftex = 1; + iIncludeLowestRange = 1; + + # set iDoLatex and iDoMultiLayer concerning the given suffix + match(szBase, /\.[^\.\/]+$/); + if (RLENGTH != -1) + { + szSuffix = substr(szBase, RSTART); + if (szSuffix == ".lfig") + iDoLatex = 1; + else if (szSuffix == ".mfig") + iDoMultiLayer = 1; + else if ((szSuffix == ".mlfig") || (szSuffix == ".lmfig")) + { + iDoLatex = 1; + iDoMultiLayer = 1; + } + } + + ################################ + # evalutate options + + # set toggle latex + if (aOptions["l"] == "-") + iDoLatex = 1; + if (aOptions["l"] == "+") + iDoLatex = 0; + + # set multilayer flag + if (aOptions["m"] == "-") + iDoMultiLayer = 1; + if (aOptions["m"] == "+") + iDoMultiLayer = 0; + + # set toggle pdftex + if (aOptions["e"] == "-") + iDoPdftex = 0; + + # evaluate do not include lowest layer in all figs + iIncludeLowestRange = (aOptions["i"] == "-"); + + # evaluate include all lower ranges in the sub figs + iIncludeAllLowerRanges = (aOptions["I"] != "-"); + + # check consistencies + # if there are ranges given -> do multilayer + if (aOptions["p"] != "") + iDoMultiLayer = 1; + + + if (aOptions["g"] != "") + { + if ( ! match (aOptions["g"], /^[0-9]+$/)) + usage(); + + iGapWidth = aOptions["g"] + 1; + } + + # get the basename of the source + gsub(/\.[^\/]+$/, "", szBase); + gsub(/^.*\//, "", szBase); + + # get the path to the original + gsub(/[^\/]+$/, "", szOrigPath); +} +######################################################################### +######################################################################### + +( iInString != 0) { + aszLine[iLine] = sprintf("%s\n%s", aszLine[iLine], $0); + iInString = (match($0, "\\\\001$") == 0); + iSubLine++; + next; +} + +/^[135][ ]/ { + iCmd = $1; + iSubCmd = -1; + iSubLine = 0; + aiDepth[++iLine] = fnGetDepth($1); + aszLine[iLine] = $0; + next; +} + +/^[2][ ]/ { + iCmd = $1; + iSubCmd = $2; + iSubLine = 0; + aiDepth[++iLine] = fnGetDepth($1); + aszLine[iLine] = $0; + next; +} + + +/^[4][ ]/ { + iCmd = $1; + iSubCmd = $2; + iSubLine = 0; + aiDepth[++iLine] = fnGetDepth($1); + aszLine[iLine] = $0; + iInString = (match($0, "\\\\001$") == 0); + next; +} + +/^(6[ ])|(-6)/ { + iCmd = $1; + iSubCmd = -1; + iSubLine = 0; + next; +} + +/^[^ ]/ { + iCmd = -1; + aiDepth[++iLine] = fnGetDepth("A"); + iSubLine = 0; + aszLine[iLine] = $0; + next; +} + +/^[ ]/ { + iSubLine++; + if ((iCmd == 2) && (iSubCmd == 5) && (iSubLine == 1)) + { + if (match($0, "^\t[01] ")) + { + szFileName = substr($0, RSTART + RLENGTH); + if ( ! match(szFileName, /^\//)) + szFileName = sprintf("%s%s", szOrigPath, szFileName); + aszLine[iLine] = sprintf("%s\n\t%s %s", aszLine[iLine], $1, szFileName); + } + else + aszLine[iLine] = sprintf("%s\n%s", aszLine[iLine], $0); + } + else + aszLine[iLine] = sprintf("%s\n%s", aszLine[iLine], $0); +} + + +END { + iLine++; + iLowestLayer = 0; + iFirstRange = 0; + + if (iError == 0) + { + + + if (iDoMultiLayer) + { + asort(aiDepths, aiSortedDepth); + + # check for ranges as options + if (aOptions["p"] != "") + { + # we have explicit ranges + gsub(/-/, ":", aOptions["p"]); + iRanges = split(aOptions["p"], aszRanges, ","); + } + else + { + if (iDepths < 4) + { + iRanges = 1; + aszRanges[1] = "1:999"; + } + else + { + iRanges = 0; + iLastRange = aiSortedDepth[iDepths - 2] + 0; + iRangeStart = iLastRange; + for (iI = iDepths - 3; iI > 0; iI--) + { + aiSortedDepth[iI] += 0; + if ((aiSortedDepth[iI] < iLastRange - iGapWidth) || (iI == 1)) + { + if (aiSortedDepth[iI] >= iLastRange - iGapWidth) + iLastRange = aiSortedDepth[iI]; + + if (iLastRange != iRangeStart) + aszRanges[++iRanges] = sprintf("%d:%d", iLastRange, iRangeStart); + else + aszRanges[++iRanges] = sprintf("%d", iRangeStart); + iRangeStart = aiSortedDepth[iI]; + + if ((iI == 1) && (aiSortedDepth[iI] < iLastRange - iGapWidth)) + aszRanges[++iRanges] = sprintf("%d", aiSortedDepth[iI]); + } + iLastRange = aiSortedDepth[iI]; + } + } + } + + + # check for a multilayer file with only one range + if ((iRanges == 1) && iIncludeLowestRange) + { + iIncludeLowestRange = 0; + } + + szInitRangeList = " -D "; + szSep = ""; + + if (iIncludeLowestRange) + { + szInitRangeList = sprintf("%s+%s", szInitRangeList, aszRanges[1]); + szSep = ","; + } + szRangeList = szInitRangeList; + + # step through the ranges + for (iI = iIncludeLowestRange; iI < iRanges; iI++) + { + szFileBase = sprintf("%s-%d", szBase, iI - iIncludeLowestRange); + + if (aOptions["I"]) + { + szRangeList = sprintf("%s%s+%s", szRangeList, szSep, aszRanges[iI + 1]); + szSep = ","; + } + else + szRangeList = sprintf("%s%s+%s", szInitRangeList, szSep, aszRanges[iI + 1]); + + + if (iDoLatex) + szTargetFile = fnDoTexFig(szFileBase, szOrigFile, szRangeList, (iDoPdftex != 0)); + else + szTargetFile = fnDoNormalFig(szFileBase, szOrigFile, szRangeList, (iDoPdftex != 0)); + + + if (aOptions["G"]) + { + match(szTargetFile, /\.[^.]*$/); + szCommand = sprintf("%s %s %s.page%d%s", cmdMv, szTargetFile, szBase, iI - iIncludeLowestRange, substr(szTargetFile, RSTART, RLENGTH)); + debug("%s\n", szCommand); + system(szCommand); + } + } + } + else + { + szRangeList = ""; + + if (iDoLatex) + szTargetFile = fnDoTexFig(szBase, szOrigFile, szRangeList, (iDoPdftex != 0)); + else + szTargetFile = fnDoNormalFig(szBase, szOrigFile, szRangeList, (iDoPdftex != 0)); + } + } +} + + + +######################################################################### +######################################################################### +function debug(str, arg0, arg1, arg2, arg3, arg4) +{ + if (aOptions["v"]) + printf (str, arg0, arg1, arg2, arg3, arg4); +} + +######################################################################### +######################################################################### +function fnGetDepth (iControl) +{ + + if (iControl == 1) + { + iReturn = sprintf("%04d", $7); + } + else if (iControl == 2) + { + iReturn = sprintf("%04d", $7); + } + else if (iControl == 3) + { + iReturn = sprintf("%04d", $7); + } + else if (iControl == 4) + { + iReturn = sprintf("%04d", $4); + } + else if (iControl == 5) + { + iReturn = sprintf("%04d", $7); + } + else if ((iControl == 6) || (iControl == -6)) + { + iReturn = sprintf("%04d", iInvalidDepth); + } + else + { + iReturn = sprintf("%04d", iAdminDepth); + } + + if (iReturn >= 0) + { + if (ahDepths[iReturn] == 0) + { + ahDepths[iReturn] = 1; + aiDepths[iDepths++] = iReturn; + } + } + + return (iReturn); + +} + +######################################################################### +######################################################################### +function fnDoNormalFig(szFileNameBase, szFigFile, szRangeList, iPdf, + szEpsFile, szPdfFile, szTargetFile, szCommand) +{ + + debug("FileNameBase >%s< FigFile >%s< Pdf:%d\n", szFileNameBase, szFigFile, iPdf); + + if (iPdf) + szEpsFile = sprintf("%s%s.eps", szTmpPrefix, szFileNameBase); + else + { + szEpsFile = sprintf("%s.eps", szFileNameBase); + szTargetFile = szEpsFile; + } + + szCommand = sprintf("%s -L eps %s %s %s 2> /dev/null", cmdFig2dev, szRangeList, szFigFile, szEpsFile); + debug("%s\n", szCommand); + system(szCommand); + + if (iPdf) + { + szPdfFile = sprintf("%s.pdf", szFileNameBase); + szTargetFile = szPdfFile; + szCommand = sprintf("%s --outfile=%s %s", cmdEpsToPdf, szPdfFile, szEpsFile); + debug("%s\n", szCommand); + system(szCommand); + + + if ( ! aOptions["d"]) + { + szCommand = sprintf("%s -f %s", cmdRm, szEpsFile); + debug("%s\n", szCommand); + system(szCommand); + } + } + + + return (szTargetFile); +} + + +######################################################################### +######################################################################### +function fnDoTexFig(szFileNameBase, szFigFile, szRangeList, iPdf, + szEpsFile, szPdfFile, szTexDoc, szTexPdf, szTexLog, szTexAux, szTexInp, szTmpPs, szTmpPdf, szTexSiz, szTmpEps, szCommand, szHeader) +{ + + debug("FileNameBase >%s< FigFile >%s< Pdf:%d\n", szFileNameBase, szFigFile, iPdf); + + szEpsFile = sprintf("%s.eps", szFileNameBase); + szPdfFile = sprintf("%s.pdf", szFileNameBase); + szTexDoc = sprintf("%s%s_doc.tex", szTmpPrefix, szFileNameBase); + szTexPdf = sprintf("%s%s_doc.pdf", szTmpPrefix, szFileNameBase); + szTexDvi = sprintf("%s%s_doc.dvi", szTmpPrefix, szFileNameBase); + szTexLog = sprintf("%s%s_doc.log", szTmpPrefix, szFileNameBase); + szTexAux = sprintf("%s%s_doc.aux", szTmpPrefix, szFileNameBase); + szTexInpPref = sprintf("%s%s_inp", szTmpPrefix, szFileNameBase); + szTexInp = sprintf("%s.tex", szTexInpPref); + szTexCreator = sprintf("%s.create", szTexInpPref); + szTexSiz = sprintf("%s.size", szTexInpPref); + + if (iPdf) + szCommand = sprintf("%s -L pdftex_p %s -p %s %s %s", cmdFig2dev, szRangeList, szTexInpPref, szFigFile, szTexInp); + else + szCommand = sprintf("%s -L pstex_p %s -p %s %s %s", cmdFig2dev, szRangeList, szTexInpPref, szFigFile, szTexInp); + debug("%s\n", szCommand); + system(szCommand); + + szCommand = sprintf("./%s", szTexCreator); + debug("%s\n", szCommand); + system(szCommand); + + # check if there is an own hederfile to include + if (aOptions["s"] == "") + aOptions["s"] = "times"; + + if (aOptions["H"] == "") + { + szHeader = sprintf("\\documentclass{article}\n\ +\\usepackage{german,amssymb,amsmath}\n\ +\\usepackage{%s}", aOptions["s"]); + } + else + szHeader = sprintf("\\input{%s}\n", aOptions["H"]); + + szHeader = sprintf("%s\n\ +\\usepackage{color}\n\ +\\usepackage{ifpdf}\n\ +\\setlength{\\textwidth}{100cm}\n\ +\\setlength{\\textheight}{100cm}\n\ +\\setlength{\\topmargin}{-1in}\n\ +\\setlength{\\headsep}{0pt}\n\ +\\setlength{\\headheight}{0pt}\n\ +\\setlength{\\oddsidemargin}{-1in}\n\ +\\parindent=0cm\n\ +\\ifpdf\n\ +\\usepackage[pdftex]{graphicx}\n\ +\\DeclareGraphicsExtensions{.pdf,.png,.jpg}\n\ +\\usepackage{epsfig}\n\ +\\input{%s}\n\ +\\else\n\ +\\usepackage{graphicx}\n\ +\\usepackage{epsfig}\n\ +\\fi\n\ +", szHeader, szTexSiz); + + szCommand = sprintf("%s > %s << EOF\n\ +%s\\begin{document}\n\ +\\pagestyle{empty}\n\ +\\input{%s}\n\ +\\end{document}\n\ +EOF", cmdCat, szTexDoc, szHeader, szTexInp); + if (aOptions["d"] != "") + debug("%s\n", szCommand); + system(szCommand); + + if (iPdf) + { + + szCommand = sprintf("%s -interaction batchmode %s", cmdPdftex, szTexDoc); + debug("%s\n", szCommand); + iReturn = system(szCommand); + + if (iReturn) + { + szCommand = sprintf("%s %s | %s +G", cmdCat, szTexLog, cmdLess); + system (szCommand); + } + else + { + szCommand = sprintf("%s %s %s", cmdMv, szTexPdf, szPdfFile); + debug("%s\n", szCommand); + system(szCommand); + } + + } + else + { + szCommand = sprintf("%s -interaction batchmode %s", cmdLatex, szTexDoc); + debug("%s\n", szCommand); + iReturn = system(szCommand); + if (iReturn) + { + szCommand = sprintf("%s %s | %s +G", cmdCat, szTexLog, cmdLess); + system (szCommand); + } + else + { + szCommand = sprintf("%s -q -E %s -o %s 2>&1 > /dev/null", cmdDvips, szTexDvi, szEpsFile); + debug("%s\n", szCommand); + system(szCommand); + } + } + + if ( ! aOptions["d"]) + { + szCommand = sprintf("./%s -r", szTexCreator); + debug("%s\n", szCommand); + system(szCommand); + } + + if ( ! aOptions["d"]) + { + szCommand = sprintf("%s -f %s %s %s %s %s %s %s", cmdRm, szTexDoc, szTexLog, szTexAux, szTexDvi, szTexInp, szTexCreator, szTexPdf); + debug("%s\n", szCommand); + system(szCommand); + } + + if (iPdf) + return (szPdfFile); + else + return (szEpsFile); +} + + +######################################################################### +######################################################################### +function getopt(sOptions, n, m, fHuntParam, iSearchMinus, iSPos, iCLen, iHuntSwitches, szSwChar, szOptChar) { +# Options: Flagoptions: %f +# Parameter: $p + + n = 1; # index in argv + m = 1; # processed entries in argv finally it points to the firs$ + iSearchMinus = 1; # indicate that a switch leading sign minus is expected + + # check for initial -- to separate the gawk switches from the script switches + if (ARGV[n] == "--") + n++; + + + while (n < ARGC) + { + iHuntSwitches = 0; + iCLen = length(ARGV[n]); + + szSwChar = substr(ARGV[n], 1, 1); + if ((szSwChar == "-") || (szSwChar == "+")) + { + if ((iSearchMinus == 0) || fHuntParam) + usage(); + iHuntSwitches = 1; + iSPos = 2; + fHuntParam = 0; + } + else + { + iSPos = 1; + + if (fHuntParam == 0) + iSearchMinus = 0; + } + + while (iSPos <= iCLen) + { + if (iHuntSwitches) + { + szOptChar = substr(ARGV[n], iSPos, 1); + iOPos = index(sOptions, szOptChar); + if (iOPos == 0) + { + printf("unknown option \"%s\"\n", szOptChar); + usage(); + } + if ((substr(sOptions, iOPos - 1, 1) == "&") || ((substr(sOptions, iOPos - 1, 1) == "%") && (szSwChar == "-"))) + { + aOptions[szOptChar] = szSwChar; + iSPos = iSPos + 1; + } + else if ((substr(sOptions, iOPos - 1, 1) == "$") && (szSwChar == "-")) + { + fHuntParam = 1; + iHuntSwitches = 0; + iSPos = iSPos + 1; + } + else + usage(); + + } + else if (fHuntParam) + { + fHuntParam = 0; + aOptions[szOptChar] = substr(ARGV[n], iSPos, iCLen + 1 - iSPos); + iSPos = iCLen + 1; + } + else + { + ARGV[m++] = ARGV[n]; + iSPos = iCLen + 1; + } + } + n = n + 1; + } + ARGC = m; +} + + +######################################################################### +######################################################################### +function usage() { + print "usage: fig2mpdf [-|+lm] [-eiIGvV] [-p ] [-g ] [-s