macintosh@felix.UUCP (02/26/87)
This is part 1 of 3 of "drawimp", a program that runs on Unix to convert MacDraw files into Impress commands for printing on Imagen laser printers. Allan Weber USC Signal and Image Processing Institute (213) 743-5519 Arpa: Weber%Brand@USC-Oberon.ARPA UUCP: ...sdcrdcf!usc-oberon!brand!weber --- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # README # Makefile # drawimp.h # macdraw.info # drawimp.c # drawimp.man # error.c # impress.c # pxl.c # This archive created: Mon Feb 2 11:06:48 1987 export PATH; PATH=/bin:$PATH if test -f 'README' then echo shar: will not over-write existing file "'README'" else cat << \SHAR_EOF > 'README' README for drawimp distribution Last edit: 19-Sep-86 This is the fourth version of the MacDraw to Impress program, "drawimp". The program is used to convert a MacDraw picture to a close approximation that will print on an Imagen laser printer. The following things have not been implemented yet but hopefully will be eventually. Smoothed polygons PICT objects from MacPaint Clipping of objects that cross 8x10 inch page boundaries Rotated, centered, or flushed-right text Various notes about the program (in no particular order): 1. The file patterns.c contains the data for the 36 patterns available for filling and drawing in MacDraw. Some of the patterns that represent a 1/2 or 1/4 density grey level have been entered at the higher resolution level so the pattern will look different than that from a MacPaint image. The patterns are also slightly smaller than they should be since they have been expanded by a factor of 4 whereas the rest of the image has been expanded by about 4.17. Because of this, any image that relies on the phase of the pattern being correct at some point in the image will not come out right. 2. Impress on the 8/300 has a limit of 14 patterns that can be downloaded, not counting clear, white, and black. It is up to the user to make sure the picture does not exceed this limit. 3. The file impress.c contains functions to output the Impress command strings. So far it only contains the function needed by drawimp, others will be added when required. 4. The text output uses the fonts supplied with the Unix TeX distribution. If you don't have the TeX "am" fonts, it probably won't work. The program will look for fonts in the directory pointed to by the environment variable TEXFONTS. If TEXFONTS is not defined, it will use the default path specifed in pxl.h. If and when we get the newer TeX distribution with the "cm" fonts the program will be changed to use them. 6. The routines for handling the text fonts were taken from the Imagen driver supplied with the Unix Tex distribution. These files (including one VAX machine language routine) may not be too portable to other non-VAX systems. The rest of drawimp should run on non-VAX systems with few changes. The program can be run without the text routines by defining NO_TEXT in drawimp.c and linking just drawimp.o, patterns.o, and impress.o: % cc -o drawimp -DNO_TEXT drawimp.c patterns.o impress.o -lm 7. Currently all MacDraw fonts default to the same times-roman type of TeX font. Bold and Italic are supported as are most of the special characters that can be printed with one character (no vowels with accent marks, etc.). The selection of which character to use for each MacDraw character is done in mactext.c and can be changed to suit individual tastes. 8. The TeX characters are slightly different sizes than the Mac characters so text strings will not come out the same length. Things like tables where it is necessary to line things up should be done with multiple short text strings on each line rather than one long line that uses spaces or tabs to achieve the alignment. I recommend using the New York font when putting text in the drawing since it appears to be the closest in size and will give the best approximation to the correct length of text strings. 9. IMPORTANT! Check the font filename definitions at the beginning of mactext.c to make sure the font files that will be required are on the system. The parameters in the tables can be changed to match existing font files. It's all documented in mactext.c near the tables. The way fonts are specified is a bit crude but it works. 10. The -t option is used to generate imPress files that do not have a header and is used for drawings that are to be included in a LaTex document using the TeX \special command. This allows one to print a LaTeX document on the Imagen, complete with figures, so as to avoid doing any cutting and pasting afterwards. The distribution includes the files we use to make this work (special.c and PicMacros.tex). See the file README.SPCL for more info. 11. Some changes in the user interface (by popular demand) since the first version. Drawimp now accepts multiple input files and will process them one after the other to create a single output stream. The imPRESS data will have ENDPAGE commands separating the data from different files. Input from stdin is no longer supported. In normal mode, all output goes to stdout (-o option has been removed). The -d option now causes the debugging information to be written to stderr, and does not inhibit the imPRESS output from being written to stdout. If all you want is a list of objects in the file, use "drawimp -d myfile.data >/dev/null". 999. Please send any question, comments or bug reports to me at one of the addresses shown below. Allan Weber USC Signal & Image Processing Institute Powell Hall 306, MC-0272 Los Angeles, CA 90089 (213) 743-5519 Arpa: Weber%Brand@USC-ECL Usenet: ...sdcrdcf!usc-oberon!brand!weber SHAR_EOF fi # end of overwriting check if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else cat << \SHAR_EOF > 'Makefile' CFLAGS = -O -s # CFLAGS = -O -s -f68881 OBJS = drawimp.o impress.o patterns.o mactext.o textimp.o \ pxl.o scaletfm.o error.o machint.o # OBJS = drawimp.o impress.o patterns.o mactext.o textimp.o \ # pxl.o scaletfm.o error.o drawimp: $(OBJS) cc -o drawimp $(OBJS) -lm drawimp.o: drawimp.c drawimp.h impress.o: impress.c patterns.o: patterns.c mactext.o: mactext.c drawimp.h textimp.o: textimp.c pxl.h types.h drawimp.h pxl.o: pxl.c pxl.h scaletfm.o: scaletfm.c pxl.h types.h error.o: error.c machint.o: machint.s SHAR_EOF fi # end of overwriting check if test -f 'drawimp.h' then echo shar: will not over-write existing file "'drawimp.h'" else cat << \SHAR_EOF > 'drawimp.h' /* This is an include file for the MacDraw file reading program. Some of the structs are not really used but are here to show the way data is stored in the file. In the structs, char = 1 byte, short = 2 bytes. Allan Weber (Weber%Brand@USC-ECL) USC Signal and Image Processing Institute Last edit: 5-Dec-85 */ #define DEF_RES 300 /* default Imagen resolution */ #define H_SHIFT 18 /* shifts to center page on paper */ #define V_SHIFT 36 #define TEXTURE_FAMILY 95 #define FONT_FAMILY_TOP (TEXTURE_FAMILY - 1) #define TEMP_PREFIX "/tmp/McDXXXXXX" #define TEX_EXT ".imp" /* file extension for LaTex files */ #define MAC_EXT ".data" /* file extension for MacDraw file */ #define MAC_H_SIZE 576 #define MAC_V_SIZE 720 #define MAC_H_PAGES 12 #define MAC_V_PAGES 5 #define HEADER_SIZE 512 #define ARROW_ANGLE 15 /* The following #define values relate to the different attributes used by MacDraw for various objects. */ /* Text style */ #define PLAIN 0 #define BOLD 1 #define ITALIC 2 #define UNDERLINE 4 #define HOLLOW 8 #define SHADOW 16 /* Font type */ #define CHICAGO 1 #define GENEVA 2 #define NEW_YORK 3 /* Font size */ #define SIZE_9 1 #define SIZE_10 2 #define SIZE_12 3 #define SIZE_14 4 #define SIZE_18 5 /* Text spacing */ #define SINGLE 1 #define THREE_HALF 2 #define DOUBLE 3 /* Text alignment */ #define LEFT 1 #define CENTER 2 #define RIGHT 3 /* Line width */ #define LINE_0 1 #define LINE_1 2 #define LINE_2 3 #define LINE_4 4 #define LINE_6 5 /* Arrow direction */ #define NO_ARROW 0 #define RIGHT_ARROW 1 #define LEFT_ARROW 2 #define BOTH_ARROW 3 /* The following structs are for various data structures used in the MacDraw data records. */ struct lcoord { /* long coordinate - radix point between halves */ unsigned short i,f; }; struct lpoint { /* long point */ struct lcoord v,h; }; struct lrect { /* long rectangle */ struct lcoord top, left, bottom, right; }; struct srect { /* short rectangle */ short top, left, bottom, right; }; struct frect { /* float rectangle */ float top, left, bottom, right; }; struct bpoint { /* incremental point */ char x,y; }; /* The following are structs for the data records. Fields with unknown purposes are named Z1, Z2, etc. */ struct MDheader { /* record header for each object */ char code; char Z1,Z2,Z3; char line; char pen; char fill; char special; }; struct MDtext { /* Text record */ short Z1,Z2; char style; char font; char size; char spacing; char alignment; char angle; short count; struct srect rect; }; struct MDvector { /* Vector record (right angle and sloped) */ struct lpoint start, stop; }; struct MDbox { /* Rectangle, Ellipse, and RoundRect record */ struct lrect rect; }; struct MDarc { /* Arc record */ struct lrect rect; unsigned short start, angle; }; struct MDgroup { /* Group identifier record */ struct lrect rect; unsigned short Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8; }; struct MDpolygon { /* Polygon record */ unsigned short Z1; unsigned short rec_size; unsigned short points; struct lrect rect; char closed; char Z2; }; struct MDcurve { /* Curve record */ unsigned short Z1; unsigned short rec_size; unsigned short points; struct lrect rect; char closed; char Z2; struct lpoint start; }; #define MAX_RECORD 40 SHAR_EOF fi # end of overwriting check if test -f 'macdraw.info' then echo shar: will not over-write existing file "'macdraw.info'" else cat << \SHAR_EOF > 'macdraw.info' MacDraw data file information Allan Weber (Weber%Brand@USC-ECL.ARPA) USC Signal and Image Processing Institute Last edit: 16-Dec-85 This file contains a description of the data records produced by "Macdraw Version 1.7 3/18/85". Some of the information in the data records has not yet been deciphered and is indicated below by question marks. Note: Many of the data structures for points and rectangles use 4-byte "fixed-point numbers" instead of the normal 2-byte integers. Fixed-point numbers are described in "Inside Macintosh", page MI-11. They are similar to integers with the addition of a 2-byte fractional part, thus yielding a number with the same range but greater precision. A MacDraw file starts with a 512 byte header. There does not appear to be any information in the header required for recreating the image on a device like a laser printer. File header (512 bytes) Offset 0..213 ? 214..229 Enclosing rectangle for entire drawing (Fixed-point) 230..511 ? After the file header is a sequence of data records, one for each object in the image. Each object data record starts with an 8-byte record header, followed in most cases by varible length object dependent data. The first byte in each of the record headers indicates the type of object. At the end of the file is a terminator (type 0) record. Record header (8 bytes) Offset 0 code 0 = terminator 1 = text 2 = right angle vector 3 = sloped vector 4 = rectangle 5 = round rectangle 6 = ellipse 7 = arc 8 = curve 9 = polygon 10= group 11 = PICT data (from MacPaint) 1 lock 0 = unlocked, 1 = locked 2 ? 3 ? 4 line width code: 1 = 0 pixels, 2 = 1 pixel, 3 = 2 pixels, 4 = 4 pixels, 5 = 6 pixels 5 pen pattern number: 1..36 6 fill pattern number: 1..36 7 special for vectors, the arrow type 0 = ------, 1 = ----->, 2 = <-----, 3 = <-----> for round rectangles, the corner radius: 1 = 0", 2 = 1/8, 3 = 3/16, 4 = 1/4, 5 = 5/16, 6 = 3/8 8.. An object-specific record (if any) follows after the header Object Specific Data (follows record header) 0: Terminator record (0 bytes) A terminator record is used to mark the end of the list of objects or the end of a set of objects that have been grouped together. 1: Text record (20 bytes + length of string) 0..3 ? 4 style 0 = plain, 1 = bold, 2 = italic, 4 = underline, 8 = hollow, 16 = shadow 5 font 1 = Chicago, 2 = Geneva, 3 = New York, 4 = Monaco, 5 = Venice, 6 = London, 7 = Athens 6 size 1 = 9 pt, 2 = 10 pt, 3 = 12 pt, 4 = 14 pt, 5 = 18 pt, etc. 7 spacing 1 = single, 2 = three halves, 3 = double 8 align 1 = left, 2 = center, 3 = right 9 angle 0 = normal 4 = flip horizontal 1 = rotate right 5 = flip vertical 2 = upsidedown 6 = rotate right and flip horizontal 3 = rotate left 7 = rotate left and flip horizontal 10:11 Number of characters in text string 12:19 Rectangle enclosing text (Integer) (Note: the rectangle gives the location of the text BEFORE doing any rotating and/or flipping according to byte 9.) 20 Start of text string (not terminated with null) 2,3: Vector record (16 bytes) 0:7 Start point (Fixed-point) 8:15 End point (Fixed-point) 4,5,6: Rectangles and Ellipse record (16 bytes) 0:15 Rectangle enclosing object (Fixed-point) 7: Arc record (20 bytes) 0:15 Rectangle enclosing ellipse used to generate arc (Fixed-point) 16:17 Start angle (degrees) 18:19 Extent of arc (degrees) 8: Curve record (32 bytes + 2 bytes/point) 0..1 ? 2:3 Number of bytes in rest of record 4:5 Number of points in curve including start point and ending null point 6:21 Rectangle enclosing curve (Fixed-point) 22 1 = make closed (add final point same as first point) 23 ? 24:31 Start point (Fixed-point) 32 Start of X,Y increment pairs (2 bytes/pair), 2's complement, terminated by a pair of zero bytes. 9: Polygon record (24 bytes + 8 bytes/point) 0..1 ? 2:3 Number of bytes in rest of record 4:5 Number of points in polygon 6:21 Rectangle enclosing curve (Fixed-point) 22 1 = make closed (add final point same as first point) 2 = smoothed polygon 23 ? 24 Start of list of points in the polygon (Fixed-point), 8 bytes/pnt 10: Group record (32 bytes) A group record is used to indicate the beginning of a collection of objects that have been grouped together using the Group command under the Arrange menu. The group contains all the following objects until a terminator record is encountered. 0:15 Rectangle enclosing all members in the group (Fixed-point) 16..31 ? 11: PICT record (42+) 0..3 ? 4:11 ? Rectangle (Integer) 12:27 Rectangle enclosing picture (Fixed-point) 28..31 ? 32:33 Width of picture in bytes 34:41 ? Rectangle (Integer) 42.. Bitmap SHAR_EOF fi # end of overwriting check if test -f 'drawimp.c' then echo shar: will not over-write existing file "'drawimp.c'" else cat << \SHAR_EOF > 'drawimp.c' /* drawimp - MacDraw to Impress translator This program will read a MacDraw file and output a sequence of Impress commands to draw the picture on an Imagen laser printer. Program is compatible with MacDraw files created by "MacDraw Version 1.7 3/18/85". Drawimp has two processing modes. The normal mode causes the MacDraw files listed on the command line to be processed in order listed with the Impress data written to stdout with ENDPAGE commands between data from each file. This will put each file on separate pages. In TeX mode (with -t switch) each input file, is processed and the results are written to a separate output file with the extension (if any) changed to .imp. The output files have no header or trailing ENDPAGE or EOF commands. The -d switch causes debugging information to be written to stderr. This consists of a list of objects and some info about them. The -p switch is used to select which pages of the MacDraw file to output. Syntax is: -pr1-r2:c1-c2[,r1-r2:c1-c2] The -R switch is used to specify the Image resolution in dots per inch. The default is set in drawimp.h A few examples: drawimp Picture.data >Picture.imp drawimp -p1:2 Picture.data >Picture.imp drawimp -d Picture.data >/dev/null drawimp -d Picture.data >Picture.imp drawimp -t Picture1.data Picture2.data drawimp -R240 Picture1.data | ipr Not (yet) implemented: Smoothed polygons PICT objects from MacPaint Clipping of objects that cross 8x10 inch page boundaries Note: This program has been used extensively on VAX systems but only for a short time on SUN systems. It seems to work on SUNs but some compatibility bugs may still be left in it. The only code that is dependent on the VAX byte ordering is in swapbyte() and is is conditionally compiled. There may be other places where the program needs to be changed for other machines. Please send any bug reports to Weber%Brand@USC-Oberon.USC.EDU Allan Weber (Weber%Brand@USC-Oberon.USC.EDU) USC Signal and Image Processing Institute History: 16-Apr-85 Version 1 23-Apr-85 Version 2 - Fixed bug in arcs, added arrows, added rest of patterns, changed cvtpnt to use 32-bit coordinates, added -p switch for page select 28-Aug-85 Version 3 - Added text using TeX fonts and routines from the Unix TeX distribution. Added fix to arc routine from Richard Roy (dick@su-dit). 16-Dec-85 Version 4 Added -t switch to produce impress file without header, endpage, or eof bytes for including output file in TeX documents going to Imagen. Also moves whatever is on page to upper left corner. More fixes to arcs to handle filled arcs and arcs of other than 90 degrees. Implemented different radius corners for the rounded rectangles. 10-Apr-86 Fixed bug in TeX mode stuff to shift picture to top-left. 27-Jan-87 Ported to SUN systems. Fixed a couple of bugs that showed up. */ #include <stdio.h> #include <ctype.h> #include <math.h> #include "drawimp.h" /* #define DEBUG */ /* define DEBUG to get point conversions printed out */ /* #define NO_TEXT */ /* define NO_TEXT to build without text capability */ FILE *infp, *outfp, *fontfp; int gdepth, done; int debug = 0; int tex_output = 0; int draw_top, draw_left; int line_table[] = { 0, 0, 1, 8, 16, 20 }; /* line width table */ int ar_size[] = { 0, 0, 10, 15, 20, 25}; /* arrowhead size table */ int corner_rad[] = { 0, 0, 9, 14, 18, 23, 27 }; /* corner radius table */ int texture_table[37]; char *ProgName; char fheader[HEADER_SIZE]; char tmp[MAX_RECORD]; char filename[80]; struct MDheader rheader; struct srect cur_page; double ar_angle, ar_size2[6], ar_radius[6]; extern char pattern[37][128]; /* This array contains info about each page of the file begin drawn. The objects in the MacDraw file can occur in any order and we have to sort them out into separate page for output. The .flag indicates whether this page is to be output or not (from -p option). The .font field is used to store the ImFamily value from the textimp.c file that was in use the last time we were doing that page. By remembering which font was in use on a page, we don't have to send the imPress SetFamily commands each time we go back to put more stuff on that page if the font hasn't changed. The .name field holds the name of the temporary file so we can delete it later. The file pointer is in .fp and is 0 if no file open for that page yet. The page_ptr variable points to the entry for the page currently being worked on. */ struct page { /* table of drawing pages */ int flag; /* flag for page in use */ int font; /* font in use on this page */ char name[20]; /* file name of where the data went */ FILE *fp; /* file pointer */ } pagetbl[MAC_V_PAGES][MAC_H_PAGES], *page_ptr; /* This table contains the values used to convert from MacDraw units (1/72 inch) to the resolution of the Imagen. The .res field is the Imagen resolution in pixels/inch. The .num and .den fields are the numerator and denoninator used to do the multiplication, as in: Imagen = MacDraw * .num / .den The scaling factor is split into separate numerator and denominator to allow conversion without overflow problems. */ struct { int res; int num,den; } restbl[] = { 240, 10, 3, 300, 25, 6, -1, 0, 0 }; int md2im_num, md2im_den; int resolution = DEF_RES; char *getpages(); int terminal(), text(), vector(), rectangle(), roundrect(); int ellipse(), arc(), curve(), polygon(), group(); int (*opfun[])() = {terminal, text, vector, vector, rectangle, roundrect, ellipse, arc, curve, polygon, group }; char *USAGE = "[-Rres] [-d] [-t] [-ppages] in_file > out_file"; extern char *malloc(); extern char *mktemp(); extern char *strcpy(); extern FILE *impout(); #ifndef NO_TEXT extern int ImFamily; /* current Imagen font number from textimp */ #endif main(argc,argv) int argc; char *argv[]; { int i; int h,h1,h2; int v,v1,v2; int gotpages = 0; char *s,c; struct lrect r; struct page *pp; ProgName = argv[0]; while(--argc > 0 && (*++argv)[0] == '-') { for (s = argv[0]+1; *s != '\0'; s++) switch(*s) { case 'd': /* debug */ debug = 1; break; case 'p': /* page select */ ++s; while (*s != '\0') { v1 = 1; v2 = 5; s = getpages(s,&v1,&v2); if (*s != ':') { fprintf(stderr, "%s: error in page list\n", ProgName); argc = -1; while (*s != '\0') s++; break; } else s++; h1 = 1; h2 = 12; s = getpages(s,&h1,&h2); if (v1 == 0) v1 = 1; if (h1 == 0) h1 = 1; for (v = v1; v <= v2; v++) for (h = h1; h <= h2; h++) pagetbl[v-1][h-1].flag=1; if (*s == ',') s++; } s--; /* back pointer up one place */ gotpages = 1; break; case 't': tex_output = 1; break; case 'R': /* Image resolution */ s++; if (sscanf(s,"%d",&resolution) != 1) { fprintf(stderr,"%s: Bad resolution - %s\n", ProgName,s); argc = -1; } while (*s != '\0') s++; s--; break; default: fprintf(stderr,"%s: illegal option - %c\n", ProgName,*s); argc = -1; break; } } if (argc <= 0) { usage(); exit(1); } if (tex_output) { if (gotpages == 0) pagetbl[0][0].flag = 1; /* only first page for tex */ else { fprintf(stderr, "Cannot use -t and -p options at same time\n"); usage(); exit(1); } } else if (gotpages == 0) { for (v = 0; v < MAC_V_PAGES; v++) /* do all */ for (h = 0; h < MAC_H_PAGES; h++) pagetbl[v][h].flag = 1; } /* figure out what resolution and conversion factors to use */ i = 0; while (restbl[i].res > 0) { if (restbl[i].res == resolution) { md2im_num = restbl[i].num; md2im_den = restbl[i].den; break; } i++; } if (md2im_num == 0) { fprintf(stderr,"%s: Unknown resolution - %d\n", ProgName,resolution); exit(1); } /* calculate some things for doing arrows */ ar_angle = ARROW_ANGLE * 2 * 3.14159 / 360; for (i = 0; i <= 5; i++) { ar_radius[i] = md2im(ar_size[i]); ar_size2[i] = pow(ar_radius[i] * cos(ar_angle), (float) 2); } /* calculate some things for doing rectangle corners */ for (i = 1; i <= 6; i++) { corner_rad[i] = md2im(corner_rad[i]); } if (tex_output == 0) { printf("@document(language impress)"); impout(stdout); imP_set_abs_h(md2im(H_SHIFT)); /* shift origin */ imP_set_abs_v(md2im(V_SHIFT)); imP_set_hv_system(3,0,0); /* set new origin */ } while (argc-- > 0) { if ((infp = fopen(*argv,"r")) == NULL) { fprintf(stderr,"%s: can't open input file %s\n", ProgName,*argv); exit(1); } if (tex_output) { makename(*argv,filename); if ((outfp = fopen(filename,"w")) == NULL) { fprintf(stderr, "%s: can't open output file %s\n", ProgName,filename); exit(1); } fontfp = outfp; /* put font info at front */ } else { outfp = stdout; fontfp = stdout; } argv++; page_ptr = NULL; fread(fheader,1,HEADER_SIZE,infp); /* read header */ makelrect(fheader+214,&r); if (debug) { fprintf(stderr, "Drawing rectangle: t=%d, l=%d, b=%d, r=%d\n", r.top.i,r.left.i,r.bottom.i,r.right.i); } draw_top = draw_left = 0; if (tex_output != 0) cvtpnt(&r.top, &r.left, &draw_top, &draw_left); /* read the MacDraw objects and process them */ done = gdepth = 0; while (fread((char *)&rheader, sizeof(struct MDheader), 1, infp) == 1) { c = rheader.code; if (c >= 0 && c <= 10) (opfun[c])(); else { fprintf(stderr,"Unrecognized type - %d\n",c); break; } if (done) break; } fclose(infp); /* now output all the collected picture data */ impout(outfp); if (tex_output) imP_set_hv_system(3,0,0); /* set new origin */ for (v = 0; v < MAC_V_PAGES; v++) for (h = 0; h < MAC_H_PAGES; h++) { pp = &pagetbl[v][h]; if (pp->fp != NULL) { fseek(pp->fp,0L,0); while ((c = getc(pp->fp)) != EOF || feof(pp->fp) == 0) putc(c,outfp); fclose(pp->fp); pp->fp = NULL; unlink(pp->name); if (tex_output == 0) imP_endpage(); } } #ifndef NO_TEXT reset_text(); /* reset text for next file */ #endif if (tex_output) { #ifndef NO_TEXT reset_fonts(); /* set fonts as not downloaded yet */ #endif reset_textures(); /* same for texture glyphs */ fclose(outfp); } } /* finish the file off */ if (tex_output == 0) imP_eof(); } usage() { fprintf(stderr,"Usage: %s %s\n",ProgName, USAGE); } /*****************************************************************************/ terminal() { if (debug) fprintf(stderr, "Terminator: depth = %d\n",gdepth); if (gdepth > 0) gdepth--; else done = 1; } text() { int n, doit; int style, font, size, spacing, align, angle; int top, left, bottom, right; int v[5], h[5], tv, th; char *s, *s0; struct lrect r; fread(tmp,sizeof(struct MDtext),1,infp); style = makenum(1,tmp+4); font = makenum(1,tmp+5); size = makenum(1,tmp+6); spacing = makenum(1,tmp+7); align = makenum(1,tmp+8); angle = makenum(1,tmp+9); n = makenum(2,tmp+10); makelrect0(tmp+12,&r); doit = dopage(&r.top,&r.left) != 0; if (debug && doit) { fprintf(stderr, "Text: %d characters, rect: t=%d, l=%d, b=%d, r=%d\n", n,r.top.i,r.left.i,r.bottom.i,r.right.i); fprintf(stderr, "\tstyle=%d, font=%d, size=%d, spacing=%d\n", style, font, size, spacing); fprintf(stderr, "\talign=%d, angle=%d, fill=%d\n", align, angle, rheader.fill); } if ((s = s0 = malloc(n+1)) == 0) fprintf(stderr,"Unable to malloc %d byte\n",n+1); while (n--) *s++ = getc(infp); *s = '\0'; if (debug && doit) fprintf(stderr, "\"%s\"\n",s0); if (doit) { if (rheader.fill > 1) { cvtpnt(&r.top,&r.left,&top,&left); cvtpnt(&r.bottom,&r.right,&bottom,&right); h[0] = h[3] = h[4] = left; v[0] = v[1] = v[4] = top; h[1] = h[2] = right - 1; v[3] = v[2] = bottom - 1; imP_create_path(5,h,v); imP_fill_path(use_pattern(rheader.fill)); } cvtpnt(&r.top,&r.left,&tv,&th); #ifndef NO_TEXT mactext(s0,tv,th,style,font,size,spacing,align,angle); #endif } free(s0); } vector() { struct lpoint pnt1, pnt2; int h[2], v[2], ha[3], va[3]; int pat, ar, s; double dh, dv, t; fread(tmp,sizeof(struct MDvector),1,infp); makelpoint(tmp+0,&pnt1); makelpoint(tmp+8,&pnt2); if (dopage(&pnt1.v,&pnt1.h) == 0) return; if (debug) { fprintf(stderr, "Vector: From (%dv %dh) to (%dv %dh), ", pnt1.v.i,pnt1.h.i,pnt2.v.i,pnt2.h.i); fprintf(stderr, "line=%d, pen=%d, fill=%d, arrow=%d\n", rheader.line,rheader.pen,rheader.fill,rheader.special); } if (onpage(&pnt1.v,&pnt1.h) && onpage(&pnt2.v,&pnt2.h) && rheader.line > 1) { cvtpnt(&pnt1.v,&pnt1.h,v,h); cvtpnt(&pnt2.v,&pnt2.h,v+1,h+1); if (rheader.pen > 1) pat = use_pattern(rheader.pen); if ((ar = rheader.special) > 0) { dh = h[1] - h[0]; dv = v[1] - v[0]; s = rheader.line; if (dh*dh + dv*dv > ar_size2[s]) { t = atan2(dv,dh); if (ar == 1 || ar == 3) { make_arrow(h+1,v+1,t,s,ha,va); imP_create_path(3,ha,va); imP_fill_path(pat); } if (ar == 2 || ar == 3) { t += 3.14159; make_arrow(h,v,t,s,ha,va); imP_create_path(3,ha,va); imP_fill_path(pat); } } } imP_create_path(2,h,v); imP_set_pen(use_line(rheader.line)); imP_draw_path(pat); } } rectangle() { struct lrect r; int top, left, bottom, right; int h[5], v[5]; fread(tmp,sizeof(struct MDbox),1,infp); makelrect(tmp,&r); if (dopage(&r.top,&r.left) == 0) return; if (debug) { fprintf(stderr, "Rectangle: t=%d, l=%d, b=%d, r=%d, ", r.top.i,r.left.i,r.bottom.i,r.right.i); fprintf(stderr, "line=%d, pen=%d, fill=%d, corner=%d\n", rheader.line,rheader.pen,rheader.fill,rheader.special); } if (onpage(&r.top,&r.left) && onpage(&r.bottom,&r.right)) { cvtpnt(&r.top,&r.left,&top,&left); cvtpnt(&r.bottom,&r.right,&bottom,&right); h[0] = h[3] = h[4] = left; v[0] = v[1] = v[4] = top; h[1] = h[2] = right - 1; v[3] = v[2] = bottom - 1; if (h[0] >= h[1]) /* vertical line? */ imP_create_path(2,h+1,v+1); else if (v[1] >= v[2]) /* horizontal line? */ imP_create_path(2,h,v); else /* rectangle */ imP_create_path(5,h,v); if (rheader.fill > 1) imP_fill_path(use_pattern(rheader.fill)); if (rheader.line > 1) { imP_set_pen(use_line(rheader.line)); imP_draw_path(use_pattern(rheader.pen)); } } } roundrect() { struct lrect r; int top, left, bottom, right, ra, rb, rad, corner; int h[9], v[9]; fread(tmp,sizeof(struct MDbox),1,infp); makelrect(tmp,&r); if (dopage(&r.top,&r.left) == 0) return; if (debug) { fprintf(stderr, "RoundRect: t=%d, l=%d, b=%d, r=%d, ", r.top.i,r.left.i,r.bottom.i,r.right.i); fprintf(stderr, "line=%d, pen=%d, fill=%d, corner=%d\n", rheader.line,rheader.pen,rheader.fill,rheader.special); } if (onpage(&r.top,&r.left) && onpage(&r.bottom,&r.right)) { cvtpnt(&r.top,&r.left,&top,&left); cvtpnt(&r.bottom,&r.right,&bottom,&right); ra = (right-1 - left) / 2; rb = (bottom-1 - top) / 2; rad = corner_rad[rheader.special]; if (ra > rad) ra = rad; if (rb > rad) rb = rad; corner = (ra != 0) || (rb != 0); h[0] = h[5] = h[8] = left + ra; h[1] = h[4] = right-1 - ra; h[2] = h[3] = right-1; h[6] = h[7] = left; v[0] = v[1] = v[8] = top; v[2] = v[7] = top + rb; v[3] = v[6] = bottom-1 - rb; v[4] = v[5] = bottom-1; if (h[0] < h[1]) imP_create_path(2,h,v); imP_set_pum(1); if (corner) { imP_set_abs_h(h[1]); imP_set_abs_v(v[2]); imP_ellipse_arc(ra,rb,0,12288,16383); } if (v[2] < v[3]) imP_create_path(2,h+2,v+2); if (corner) { imP_set_abs_h(h[4]); imP_set_abs_v(v[3]); imP_ellipse_arc(ra,rb,0,0,4096); } if (h[5] < h[4]) imP_create_path(2,h+4,v+4); if (corner) { imP_set_abs_h(h[5]); imP_set_abs_v(v[6]); imP_ellipse_arc(ra,rb,0,4096,8192); } if (v[7] < v[6]) imP_create_path(2,h+6,v+6); if (corner) { imP_set_abs_h(h[0]); imP_set_abs_v(v[7]); imP_ellipse_arc(ra,rb,0,8192,12288); } if (rheader.fill > 1) imP_fill_path(use_pattern(rheader.fill)); if (rheader.line > 1) { imP_set_pen(use_line(rheader.line)); imP_draw_path(use_pattern(rheader.pen)); } imP_set_pum(0); } } ellipse() { struct lrect r; int top, left, bottom, right, ra, rb; fread(tmp,sizeof(struct MDbox),1,infp); makelrect(tmp, &r); if (dopage(&r.top,&r.left) == 0) return; if (debug) { fprintf(stderr, "Ellipse: t=%d, l=%d, b=%d, r=%d, ", r.top.i,r.left.i,r.bottom.i,r.right.i); fprintf(stderr, "line=%d, pen=%d, fill=%d\n", rheader.line,rheader.pen,rheader.fill,rheader.special); } if (onpage(&r.top,&r.left) && onpage(&r.bottom,&r.right)) { cvtpnt(&r.top,&r.left,&top,&left); cvtpnt(&r.bottom,&r.right,&bottom,&right); imP_set_abs_h((left + right-1) / 2); imP_set_abs_v((top + bottom-1) / 2); ra = (right-1 - left) / 2; rb = (bottom-1 - top) / 2; imP_ellipse_arc(ra,rb,0,0,16383); if (rheader.fill > 1) imP_fill_path(use_pattern(rheader.fill)); if (rheader.line > 1) { imP_set_pen(use_line(rheader.line)); imP_draw_path(use_pattern(rheader.pen)); } } } arc() { struct lrect r, r2; int top, left, bottom, right, ra, rb, ch, cv; int start, extent; int alpha0, alpha1; double fch, fcv, frh, frv, fa1, fa2, fh1, fh2, fv1, fv2; fread(tmp,sizeof(struct MDarc),1,infp); makelrect(tmp, &r); start = makenum(2,tmp+16); extent = makenum(2,tmp+18); left = r.left.i; if (left > 32767) left -= 65536; right = r.right.i; if (right > 32767) right -= 65536; top = r.top.i; if (top > 32767) top -= 65536; bottom = r.bottom.i; if (bottom > 32767) bottom -= 65536; fch = (double)(left + right) / 2.0; fcv = (double)(top + bottom) / 2.0; frh = (double)(right - left) / 2.0; frv = (double)(bottom - top) / 2.0; fa1 = (double)(start) * 3.14159 / 180.0; fa2 = (double)(start + extent) * 3.14159 / 180.0; /* fprintf(stderr,"fch=%f, fcv=%f, frh=%f, frv=%f\n",fch,fcv,frh,frv); fprintf(stderr,"fa1=%f, fa2=%f\n",fa1,fa2); */ fh1 = fch + frh * sin(fa1); fh2 = fch + frh * sin(fa2); fv1 = fcv - frv * cos(fa1); fv2 = fcv - frv * cos(fa2); /* fprintf(stderr,"fh1=%f, fh2=%f, fv1=%f, fv2=%f\n",fh1,fh2,fv1,fv2); */ if (fv1 > fv2) { r2.top.i = fv2; r2.bottom.i = fv1; } else { r2.top.i = fv1; r2.bottom.i = fv2; } if (fh1 > fh2) { r2.left.i = fh2; r2.right.i = fh1; } else { r2.left.i = fh1; r2.right.i = fh2; } r2.top.f = r2.left.f = r2.bottom.f = r2.right.f = 0; /* fprintf(stderr, "top=%d, left=%d, bottom=%d, right=%d\n", r2.top.i,r2.left.i,r2.bottom.i,r2.right.i); */ if (dopage(&r2.top,&r2.left) == 0) return; if (debug) { fprintf(stderr, "Arc: t=%d, l=%d, b=%d, r=%d, ", r2.top.i,r2.left.i,r2.bottom.i,r2.right.i); fprintf(stderr, "line=%d, pen=%d, fill=%d\n", rheader.line,rheader.pen,rheader.fill); fprintf(stderr, "\tstart = %d, extent = %d\n",start,extent); } if (onpage(&r2.top,&r2.left) && onpage(&r2.bottom,&r2.right)) { cvtpnt(&r.top,&r.left,&top,&left); cvtpnt(&r.bottom,&r.right,&bottom,&right); ch = (left + right-1) / 2; cv = (top + bottom-1) / 2; imP_set_abs_h(ch); imP_set_abs_v(cv); ra = (right-1 - left) / 2; rb = (bottom-1 - top) / 2; /* changed 8/22/85 by rhr - apparently MacDraw allows arcs to be traversed * in negative direction (Imagen does not)! Debug output gave extent=65446! * which for 16 bit 2's complement would be about -90! So, this fix assumes * all arcs are 90 degrees in extent, plus or minus, and adjusts start * accordingly */ /* changed again 11/4/85 by AGW to allow arcs of other than 90 degrees */ if (extent > 32768) { /* negative direction? */ extent = 65536 - extent; start = start - extent; } if (rb > ra) /* v axis = major axis */ start = (start + 270) % 360; alpha0 = ((start - 90) * 4096) / 90; if (alpha0 < 0) alpha0 += 16384; if (extent == 360) alpha1 = alpha0 + 16383; else alpha1 = alpha0 + ((extent * 4096) / 90); if (rheader.fill > 1) { imP_create_path(1, &ch, &cv); imP_set_pum(1); imP_ellipse_arc(ra,rb,0,alpha0,alpha1); imP_fill_path(use_pattern(rheader.fill)); imP_set_pum(0); } if (rheader.line > 1) { imP_ellipse_arc(ra,rb,0,alpha0,alpha1); imP_set_pen(use_line(rheader.line)); imP_draw_path(use_pattern(rheader.pen)); } } } curve() { int n, n0, dx, dy; struct lpoint pnt; int *h, *h0, *v, *v0; int doit; struct lrect r; fread(tmp,sizeof(struct MDcurve),1,infp); n = makenum(2,tmp+4); makelrect(tmp+6, &r); doit = dopage(&r.top,&r.left) != 0; if (debug && doit) { fprintf(stderr, "Curve: n=%d, t=%d, l=%d, b=%d, r=%d, ", n,r.top.i,r.left.i,r.bottom.i,r.right.i); fprintf(stderr, "line=%d, pen=%d, fill=%d\n", rheader.line,rheader.pen,rheader.fill); } makelpoint(tmp+24,&pnt); /* null point at end gets discarded which gives room in array for point to close region if needed */ h = h0 = (int *) malloc((unsigned) sizeof(int) * n); v = v0 = (int *) malloc((unsigned) sizeof(int) * n); n0 = 0; while (--n) { if (debug && doit) fprintf(stderr, "\t%d: (%dv %dh)\n", n0,pnt.v.i,pnt.h.i); cvtpnt(&pnt.v,&pnt.h,v++,h++); n0++; dx = getc(infp); dy = getc(infp); if (dx > 127) dx -= 256; if (dy > 127) dy -= 256; pnt.h.i += dx; pnt.v.i += dy; } if (debug && doit) fprintf(stderr, "\t%d: (%dv %dh)\n",n0,pnt.v.i,pnt.h.i); if (tmp[22] == 1) { /* check for closed curve */ *h = *h0; *v = *v0; n0++; } if (doit) { if (onpage(&r.top,&r.left) && onpage(&r.bottom,&r.right)) { imP_create_path(n0,h0,v0); if (rheader.fill > 1) imP_fill_path(use_pattern(rheader.fill)); if (rheader.line > 1) { imP_set_pen(use_line(rheader.line)); imP_draw_path(use_pattern(rheader.pen)); } } } free((char *) h0); free((char *) v0); } polygon() { int n, n0; struct lpoint pnt; int *h, *h0, *v, *v0; int doit; struct lrect r; fread(tmp,sizeof(struct MDpolygon),1,infp); n = makenum(2,tmp+4); makelrect(tmp+6, &r); doit = dopage(&r.top,&r.left) != 0; if (debug && doit) { fprintf(stderr, "Polygon: n=%d, t=%d, l=%d, b=%d, r=%d, ", n,r.top.i,r.left.i,r.bottom.i,r.right.i); fprintf(stderr, "line=%d, pen=%d, fill=%d\n", rheader.line,rheader.pen,rheader.fill); } h = h0 = (int *) malloc((unsigned) sizeof(int) * (n+1)); v = v0 = (int *) malloc((unsigned) sizeof(int) * (n+1)); n0 = 0; while (n--) { fread(tmp,1,8,infp); makelpoint(tmp,&pnt); if (debug && doit) fprintf(stderr, "\t%d: (%dv %dh)\n", n0,pnt.v.i,pnt.h.i); cvtpnt(&pnt.v,&pnt.h,v++,h++); n0++; } if (tmp[22] == 1) { /* check for closed polygon */ *h = *h0; *v = *v0; n0++; } if (doit) { if (onpage(&r.top,&r.left) && onpage(&r.bottom,&r.right)) { imP_create_path(n0,h0,v0); if (rheader.fill > 1) imP_fill_path(use_pattern(rheader.fill)); if (rheader.line > 1) { imP_set_pen(use_line(rheader.line)); imP_draw_path(use_pattern(rheader.pen)); } } } free((char *) h0); free((char *) v0); } group() { struct lrect r; fread(tmp,sizeof(struct MDgroup),1,infp); makelrect(tmp, &r); gdepth += 1; if (debug) { fprintf(stderr, "Group start: depth = %d, ", gdepth); fprintf(stderr, "rectangle: t=%d, l=%d, b=%d, r=%d\n", gdepth,r.top.i,r.left.i,r.bottom.i,r.right.i); } } /*****************************************************************************/ makenum(i,p) /* make a number from bytes in 68000 order */ int i; char *p; { int n = 0; while (i--) n = (n << 8) + (*p++ & 0xff); return(n); } makelpoint(cp, pp) /* swap bytes 4 times to make a lpoint struct */ char *cp; struct lpoint *pp; { swapbyte(cp, (char *)pp, 4); } makelrect(cp, rp) /* swap bytes 8 times to make a lrect struct */ char *cp; struct lrect *rp; { swapbyte(cp, (char *)rp, 8); } makelrect0(cp, rp) /* same as makelrect except fractional part = 0 */ char *cp; struct lrect *rp; { swapbyte(cp+0, (char *)&rp->top.i, 1); swapbyte(cp+2, (char *)&rp->left.i, 1); swapbyte(cp+4, (char *)&rp->bottom.i, 1); swapbyte(cp+6, (char *)&rp->right.i, 1); rp->top.f = rp->left.f = rp->bottom.f = rp->right.f = 0; } /* MacDraw binary numbers are in 68000 byte order which is opposite from VAXes. If we are running on a VAX, this routine copies n pairs of bytes from p1 to p2 swapping the order. If not on a VAX, it just copies n pairs of bytes from p1 to p2. Note: I have never tested drawimp on a non-VAX so there may be other things that need to be changed that I have forgotten about. - AGW */ swapbyte(p1, p2, n) register char *p1, *p2; register int n; { #ifdef vax while (n-- > 0) { *(p2+1) = *p1++; *p2 = *p1++; p2 += 2; } #else bcopy(p1, p2, n*2); #endif } cvtpnt(mv,mh,iv,ih) /* convert point from MacDraw to Imagen coord. */ struct lcoord *mv, *mh; int *iv, *ih; { int a,b; a = mv->i; b = mv->f; if (a > 32767) a -= 65536; a -= cur_page.top; *iv = (md2im((a << 8) + (b >> 8 & 0xff)) >> 8) - draw_top; a = mh->i; b = mh->f; if (a > 32767) a -= 65536; a -= cur_page.left; *ih = (md2im((a << 8) + (b >> 8 & 0xff)) >> 8) - draw_left; #ifdef DEBUG fprintf(stderr, "\tv.i=%d v.f=%d v=%d, h.i=%d h.f=%d h=%d\n", mv->i,mv->f,*iv,mh->i,mh->f,*ih); #endif } md2im(x) /* convert a value from MacDraw to Imagen */ int x; { return(x * md2im_num / md2im_den); } onpage(pv,ph) struct lcoord *pv, *ph; { return(pv->i >= cur_page.top && pv->i <= cur_page.bottom && ph->i >= cur_page.left && ph->i <= cur_page.right); } use_pattern(f) char f; { if (f == 2) /* white */ return(0); else if (f == 3) /* black */ return(15); else { /* something else */ load_texture(f); return(3); } } use_line(n) char n; { if (n < 1 || n > 5) return(1); else return(line_table[n]); } load_texture(n) int n; { FILE *oldfp; if (n < 1 || n > 36) return; if (texture_table[n] == 0) { oldfp = impout(fontfp); /* send textures out to font file */ imP_bgly(0,TEXTURE_FAMILY,n,32,32,0,32,32,pattern[n]); impout(oldfp); texture_table[n] = 1; } imP_set_texture(TEXTURE_FAMILY,n); } reset_textures() /* mark all textures as not yet loaded */ { int i; for (i = 1; i <= 36; i++) texture_table[i] = 0; } dopage(pv, ph) struct lcoord *pv, *ph; { struct page *pp; int r,c; char s[20]; r = pv->i / MAC_V_SIZE; c = ph->i / MAC_H_SIZE; pp = &pagetbl[r][c]; if (r > MAC_V_PAGES || c > MAC_H_PAGES) return(0); else if (pp->flag == 0) return(0); else { if (pp->fp == NULL) { strcpy(s,mktemp(TEMP_PREFIX)); sprintf(pp->name,"%s.%01d%02d",s,r+1,c+1); pp->fp = fopen(pp->name,"w+"); pp->font = -1; /* force a imP_set_family() */ } impout(pp->fp); #ifndef NO_TEXT if (page_ptr != NULL) page_ptr->font = ImFamily; /* font for last page */ ImFamily = pp->font; /* font in use on new page */ #endif page_ptr = pp; /* points to current page */ cur_page.bottom = (cur_page.top= r * MAC_V_SIZE) + MAC_V_SIZE; cur_page.right = (cur_page.left= c * MAC_H_SIZE) + MAC_H_SIZE; return(1); } } /* This routine parses a page select specification of the form n-m where n is the first one to do and m is the last one to do. If either is missing, the value in n or m is left unchanged. If only one number is given, m and n will both be set equal to it. The parameter s is a pointer to the string and the function returns an updated pointer to the next character in the string after doing the parsing. */ char * getpages(s,n,m) char *s; int *n,*m; { int x; if (isdigit(*s)) { x = 0; while (isdigit(*s)) x = x * 10 + (*s++ - '0'); *n = x; } if (*s == '-') { if (isdigit(*++s)) { x = 0; while (isdigit(*s)) x = x * 10 + (*s++ - '0'); *m = x; } } else *m = *n; return(s); } /* This routine take the endpoint of the vector (*h, *v), its angle (t), and the line size (n) as input and fills the ha[] and va[] arrays with the three points needed to draw the arrowhead. It also modifies the endpoint location to move it inside the arrowhead. If this isn't done, the line will show around the arrow tip when using wide line sizes. */ make_arrow(h,v,t,n,ha,va) int *h, *v, n, ha[3], va[3]; double t; { double tp, tm ,r; r = ar_radius[n]; tp = t + ar_angle; tm = t - ar_angle; ha[0] = *h; /* make triangle for the arrow */ va[0] = *v; ha[1] = *h - r * cos(tm); va[1] = *v - r * sin(tm); ha[2] = *h - r * cos(tp); va[2] = *v - r * sin(tp); *h -= r * cos(t) * 0.5; /* move endpoint of vector back */ *v -= r * sin(t) * 0.5; /* away from tip of arrowhead */ } /* Create a filename for storing output for later inclusion with a dvi file */ makename(s1, s2) char *s1, *s2; { int n; char *p; p = s1; while (*p != '\0') { /* get rid of leading path name */ if (*p == '/') s1 = p+1; p++; } p = s1 + strlen(s1); /* point to null byte */ while (p > s1 && *--p != '.') /* back up looking for a . */ ; if (*p == '.' && strcmp(p, MAC_EXT) == 0) { n = p - s1; strncpy(s2, s1, n); s2[n] = '\0'; strcat(s2, TEX_EXT); } else { /* wrong or no extension so just add to end */ strcpy(s2, s1); strcat(s2, TEX_EXT); } } SHAR_EOF fi # end of overwriting check if test -f 'drawimp.man' then echo shar: will not over-write existing file "'drawimp.man'" else cat << \SHAR_EOF > 'drawimp.man' .TH DRAWIMP LOCAL "17 December 1985" .SH NAME drawimp \- convert MacDraw files to imPRESS format .SH SYNOPSIS .B drawimp [ options ] files .SH DESCRIPTION .vs -1p .I Drawimp converts the named MacDraw format files into imPRESS format for printing on an Imagen laser printer. .I Drawimp can be run in two modes. In the normal mode, imPRESS output from all the files listed on the command line will be written to the standard output. The imPRESS output contains the required headers and should be ready to print with no changes or additions. If .I drawimp is run with the .B \-t option, the program will create a separate output file for each input file. These output files will be in the proper format for merging with .I LaTeX output files for putting figures in documents. .PP The following options may be used .TP .B \-d Write debugging information to standard error. This consists of a list of the objects in the file, their location in MacDraw coordinates, and various attributes. .TP .BI \-p list Print only pages whose row and column numbers appear in a comma-separated .I list of paired row and column numbers in the form .I r:c, or paired rows and columns ranges in the form .I r1-r2:c1-c2. A range .IB r1 \- r2 means rows .I r1 through .I r2 inclusive; an initial .I \-r2 means rows 1 though .I r2 inclusive; and a final .IR r1 \- means from .I r1 to the last row. The same applies for the column specifications. .TP .B \-t Write imPRESS output to separate output files (one for each input file) without a header or trailing .I Endpage or .I Eof bytes. This option should be used if the output is intended for combining with other imPRESS data. In this mode, the page select option .B \-p is not allowed and only the upper left page of the drawing will be processed. The picture on this page be shifted on the coordinate system as if it had been in the upper left corner of the 8x10 page. If the name of an input file ends with .I \.data then the output file will be the same name as the input file with the .I \.data replaced by .I \.imp. Otherwise, the output file name will be the input file name with .I \.imp appended to it. .TP .BI \-R resolution Sets assumed printer resolution (in dots per inch). .SH FILES /tmp/McD*.\c .I rcc - temporary file for imPRESS data for the page at row .I r and column .I cc .SH BUGS Multiple page objects, PICT objects (things from MacPaint via the clipboard), and smoothed polygons are not currently supported. .PP All MacDraw files containing pictures to be included in a single .I LaTeX document must be processed by .I drawimp (with the .B \-t option) at the same time. If this is not done, the fonts used for text in the pictures will get mixed up. .PP The program ignores any information in the file about paper size or orientation. It assumes a paper size of 8x10 inches and will ignore any object that crosses an 8x10 inch page boundary, Because of this, it is best to use that paper size when creating the drawing to better see how the output will be broken up. .PP The program is designed to convert MacDraw files which are in the format produced by \*(lqMacDraw Version 1.7 3/18/85\*(rq and may not be compatible with files produced by other versions of MacDraw. .SH AUTHOR Allan G. Weber (Weber%Brand@USC-ECL.ARPA), University of Southern California, Signal and Image Processing Institute SHAR_EOF fi # end of overwriting check if test -f 'error.c' then echo shar: will not over-write existing file "'error.c'" else cat << \SHAR_EOF > 'error.c' #ifndef lint static char rcsid[] = "$Header: error.c,v 1.1 84/05/20 23:11:37 chris Exp $"; #endif /* Error message routine */ #include <stdio.h> #ifdef lint /* VARARGS */ /* ARGSUSED */ error (quit, e, fmt) int quit, e; char *fmt; { } #else lint extern char *ProgName; extern char *sys_errlist[]; extern int sys_nerr; #ifdef pyr /* pyramid hacks */ #include <varargs.h> #endif pyr /* Print an error message with an optional system error number and optionally quit */ error (quit, e, fmt, arg) int quit, e; char *fmt; { #ifdef pyr va_buf _va; va_list l; fprintf (stderr, "%s: ", ProgName); _vastart (l = (va_list)_va, &arg); _doprnt (fmt, l, stderr); #else pyr fprintf (stderr, "%s: ", ProgName); _doprnt (fmt, &arg, stderr); #endif pyr if (e) { register char *s = e < sys_nerr ? sys_errlist[e] : "Unknown error"; fprintf (stderr, ": %s", s); } putc ('\n', stderr); fflush (stderr); /* just in case */ if (quit) exit (quit); } #endif lint SHAR_EOF fi # end of overwriting check if test -f 'impress.c' then echo shar: will not over-write existing file "'impress.c'" else cat << \SHAR_EOF > 'impress.c' /* This file contains functions for outputting Impress codes to a file. Not all functions have been implemented, only those needed so far. */ #include <stdio.h> /* The following #defines are copied from the Imagen supplied file "imPcodes.h" */ #define imP_SP 128 #define imP_SP1 129 #define imP_OLD_MMOVE 130 #define imP_MPLUS 131 #define imP_MMINUS 132 #define imP_MMOVE 133 #define imP_SMOVE 134 #define imP_SET_ABS_H 135 #define imP_SET_REL_H 136 #define imP_SET_ABS_V 137 #define imP_SET_REL_V 138 #define imP_SRULE 192 #define imP_BRULE 193 #define imP_SET_HPOS 195 #define imP_SET_VPOS 196 #define imP_CRLF 197 #define imP_SGLY 198 #define imP_BGLY 199 #define imP_DELG 200 #define imP_DELC 201 #define imP_DELF 202 #define imP_MAKE_TEXTURE 203 #define imP_SET_HV_SYSTEM 205 #define imP_SET_ADV_DIRS 206 #define imP_SET_FAMILY 207 #define imP_SET_IL 208 #define imP_SET_BOL 209 #define imP_SET_SP 210 #define imP_PUSH 211 #define imP_POP 212 #define imP_PAGE 213 #define imP_SET_PUSH_MASK 214 #define imP_ENDPAGE 219 #define imP_CREATE_FAMILY_TABLE 221 #define imP_CREATE_MAP 222 #define imP_SET_PUM 225 #define imP_CIRC_ARC 150 #define imP_ELLIPSE_ARC 151 #define imP_CIRC_SEGM 160 #define imP_CREATE_PATH 230 #define imP_SET_TEXTURE 231 #define imP_SET_PEN 232 #define imP_FILL_PATH 233 #define imP_DRAW_PATH 234 #define imP_BITMAP 235 #define imP_SET_MAGN 236 #define imP_FORCE_GLY_DEL 240 #define imP_DEFINE_MACRO 242 #define imP_EXEC_MACRO 243 #define imP_DEFINE_FILE 244 #define imP_EXEC_FILE 245 #define imP_NOOP 254 #define imP_EOF 255 static FILE *impfp; FILE *impout(fp) FILE *fp; { FILE *oldfp; oldfp = impfp; impfp = fp; return(oldfp); } static outb(x) int x; { putc(x & 0xff, impfp); } static outw(x) int x; { outb(x >> 8); outb(x); } static outs(s,n) char *s; int n; { fwrite(s,1,n,impfp); } /****************************************************************************/ imP_bitmap(op_type, hsize, vsize, bits) int op_type, hsize, vsize; char *bits; { outb(imP_BITMAP); outb(op_type); outb(hsize); outb(vsize); if (bits != NULL) outs(bits, hsize * vsize * 128); } imP_bgly(rotation,family,member,adv_wid,width,left_off,height,top_off,mask) int rotation,family,member,adv_wid,width,left_off,height,top_off; char *mask; { int n; outb(imP_BGLY); outw(((rotation&0x03) << 14) + ((family&0x7f) << 7) + (member&0x7f)); outw(adv_wid); outw(width); outw(left_off); outw(height); outw(top_off); if (mask != NULL) { n = height * ((width + 7) / 8); while (n--) outb(*mask++); } } imP_create_path(vertex_count, h, v) int vertex_count, *h, *v; { outb(imP_CREATE_PATH); outw(vertex_count); while (vertex_count--) { outw(*h++); outw(*v++); } } imP_crlf() { outb(imP_CRLF); } imP_draw_path(operation_type) int operation_type; { outb(imP_DRAW_PATH); outb(operation_type); } imP_ellipse_arc(radiusa,radiusb,alphaoff,alpha0,alpha1) int radiusa,radiusb,alphaoff,alpha0,alpha1; { outb(imP_ELLIPSE_ARC); outw(radiusa); outw(radiusb); outw(alphaoff); outw(alpha0); outw(alpha1); } imP_endpage() { outb(imP_ENDPAGE); } imP_eof() { outb(imP_EOF); } imP_fill_path(operation_type) int operation_type; { outb(imP_FILL_PATH); outb(operation_type); } imP_member(code) int code; { outb(code); } imP_mminus() { outb(imP_MMINUS); } imP_mmove(deltam) { outb(imP_MMOVE); outw(deltam); } imP_mplus() { outb(imP_MPLUS); } imP_noop() { outb(imP_NOOP); } imP_set_abs_h(new_h) int new_h; { outb(imP_SET_ABS_H); outw(new_h); } imP_set_abs_v(new_v) int new_v; { outb(imP_SET_ABS_V); outw(new_v); } imP_set_bol(line_begin) int line_begin; { outb(imP_SET_BOL); outw(line_begin); } imP_set_family(family) int family; { outb(imP_SET_FAMILY); outb(family); } imP_set_hv_system(origin,axes,orientation) int origin, axes, orientation; { int x; x = ((origin & 3) << 5) + ((axes & 3) << 3) + (orientation & 1); outb(imP_SET_HV_SYSTEM); outb(x); } imP_set_il(inter_line) int inter_line; { outb(imP_SET_IL); outw(inter_line); } imP_page() { outb(imP_PAGE); } imP_set_pen(diameter) int diameter; { outb(imP_SET_PEN); outb(diameter); } imP_set_pum(mode) int mode; { outb(imP_SET_PUM); outb(mode & 1); } imP_set_rel_h(delta_h) int delta_h; { outb(imP_SET_REL_H); outw(delta_h); } imP_set_rel_v(delta_v) int delta_v; { outb(imP_SET_REL_V); outw(delta_v); } imP_set_texture(family,member) int family, member; { outb(imP_SET_TEXTURE); outw(((family & 0x7f) << 7) + (member & 0x7f)); } imP_set_sp(space_size) int space_size; { outb(imP_SET_SP); outw(space_size); } imP_smove(deltas) int deltas; { outb(imP_SMOVE); outw(deltas); } imP_sp() { outb(imP_SP); } SHAR_EOF fi # end of overwriting check if test -f 'pxl.c' then echo shar: will not over-write existing file "'pxl.c'" else cat << \SHAR_EOF > 'pxl.c' #ifndef lint static char rcsid[] = "$Header: pxl.c,v 1.9 85/10/15 18:19:05 chris Exp $"; #endif /* Routines for manipulating PXL files---Vax version */ /* The functions DMagFactor, GenPXLFileName, and ReadPXLFile could go in separate files, but it's likely that any program that uses any one function uses all three. */ #include "pxl.h" #include <errno.h> #include <sys/types.h> #include <sys/stat.h> extern int errno; char *malloc (), *sprintf (), *getenv (); long lseek (); /* Convert a magnification factor to floating point. This is used in conjunction with the FONT_SLOP stuff to try to get the file names right, and may also be used by DVI reading programs to get slightly more accurate values for (mag/1000.0). */ double DMagFactor (mag) int mag; { if (mag == 1095) return 1.095445; /* stephalf */ if (mag == 1315) return 1.314534; /* stepihalf */ if (mag == 2074) return 2.0736; /* stepiv */ if (mag == 2488) return 2.48832; /* stepv */ if (mag == 2986) return 2.985984; /* stepiv */ /* remaining mags have been ok */ return (double) mag / 1000.; } /* Generate the name of a PXL font file, given the partial name `nm', at the magnification `magfactor', with design size `designsize', a global mag factor of `globalmag' (default 1000), and a fontname path of `path' (default PXLPATH). Paths are defined as colon- separated strings (eg, "/usr/foo:/usr/bar"). Font directories either contain all the fonts directly, or else each font is in its own subdirectory. For example, amti10.* would be found in the `amti10' directory; ambx7.* in `ambx7', and so forth. The latter method is used iff there is a file in the main directory called `SUBDIR'. */ char * GenPXLFileName (nm, magfactor, designsize, globalmag, path) char *nm; int magfactor, designsize, globalmag; char *path; { double dmag; register char *s, *p; register int mag, /* expected magnification */ slop; /* current slop index */ char *slash; /* path name separator */ char *fmt; /* either oldfmt or newfmt */ char pbuf[256]; /* expansion area for path components */ static char oldfmt[] = "%s%s%s%0.0s.%dpxl"; static char newfmt[] = "%s%s%s/%s.%dpxl"; /* the formats for generating names */ /* arguments are path, /, nm, nm, sz */ static char rv[256]; /* the generated name (and other uses) */ if (globalmag == 0) globalmag = 1000; mag = (int) ((double) magfactor / (double) designsize * 1000.0 + .5); dmag = DMagFactor (mag); mag = (int) (DMagFactor (globalmag) * 1000.0 * dmag + .5); if (mag > 9999) mag = 9999; else if (mag < 0) mag = 0; /* For some reason I used to look for slashes in `nm', and suppress path expansion if there were any. This seems awfully bogus, so I've changed it to suppress path expansion iff the font name starts with '/'. Also, we no longer choke on font names with percent signs in them. */ if (*nm == '/') slash = s = ""; else { s = path; if (s == 0 || *s == 0) s = PXLPATH; slash = "/"; } /* Tread the path in s, trying for the file, and testing "nearby" names */ while (s) { p = pbuf; while (*s) { if ((*p = *s++) == ':') break; p++; } *p = 0; if (*s == 0) s = 0; /* choose new format if SUBDIR file exists, old format otherwise */ /* but always use old format for names starting with / */ if (*nm == '/') fmt = oldfmt; else { (void) sprintf (rv, "%s%sSUBDIR", pbuf, slash); fmt = access (rv, 0) == 0 ? newfmt : oldfmt; } for (slop = 0; slop < FONT_SLOP; slop++) { (void) sprintf (rv, fmt, pbuf, slash, nm, nm, mag + slop); if (access (rv, 4) == 0) return rv; if (slop) { (void) sprintf (rv, fmt, pbuf, slash, nm, nm, mag - slop); if (access (rv, 4) == 0) return rv; } } } /* Not found - give up and return expected name anyway */ /* Someday, we may actually generate the PXL (or GF) file here. */ (void) sprintf (rv, "%s.%dpxl", nm, mag);/* note: no path! */ return rv; } /* Read in a PXL font file, performing all the necessary byte swapping. Return a pointer to a struct pxltail. If 'getrast' is true, get the raster too. */ #define TAILSIZE (517 * 4) /* size of pxl tail info */ struct pxltail * ReadPXLFile (nm, getrast) char *nm; int getrast; { register char *p; register int f; struct stat stat; #define px ((struct pxltail *) p) /* First open the file, and read the pxltail part */ if ((f = open (nm, 0)) < 0) return 0; (void) fstat (f, &stat); /* There should be 4n bytes, with an absolute minimum of TAILSIZE + 4 (+4 for the initial PXLID) */ if (stat.st_size & 3 || stat.st_size < (TAILSIZE + 4)) { errno = EINVAL; return 0; } (void) lseek (f, (long) (-TAILSIZE), 2); p = malloc ((unsigned) TAILSIZE); if (p == 0) return 0; if (read (f, p, TAILSIZE) != TAILSIZE) { int saverr = errno; free (p); errno = saverr; return 0; } #ifdef vax /* Next, byte swap, since PXL file byte order is the opposite of VAX byte order */ machint ((int *) p, TAILSIZE / 4); #endif /* Finally, check the PXLID part, and if desired, read the character rasters */ if (px -> px_pxlid != PXLID) error (0, 0, "Warning: strange PXL id (%d) in \"%s\"", px -> px_pxlid, nm); if (getrast) { int rastsize = stat.st_size - (TAILSIZE + 4); if (ReadRasters (px -> px_info, f, rastsize, nm)) { int saverr = errno; free (p); errno = saverr; return 0; } } (void) close (f); return px; #undef px } /* Round n up to the nearest multiple of r (r must be a power of two) */ #define ROUND(n,r) (((n) + ((r) - 1)) & ~((r) - 1)) /* Read the raster info from a PXL file. To avoid system call overhead, we read the entire thing into core, then break up the glyphs for the chinfo array. NOTE: if malloc fails, we don't try very hard to clean up---most programs will die anyway if they fail to find a font. The reason for breaking up the characters in the first place is so that the storage allocated to any particular glyph may be freed. The rotation code uses this to get rid of bits it no longer needs. If they are not released, it is possible to run out of core when using many fonts. */ static ReadRasters (ch, fd, sz, nm) register struct chinfo *ch; int fd, sz; char *nm; { register int i; if (i = sz) { register char *p, /* glyph storage area */ *rp; /* raster pointer */ register int rs; /* raster size, in bytes */ /* First, read all the glyph bits */ if ((p = malloc ((unsigned) i)) == 0) return -1; (void) lseek (fd, 4L, 0); if (read (fd, p, i) != i) return -1; /* Next, break them up into the 128 characters */ p -= 4; /* to account for the initial PXLID */ for (i = 128; --i >= 0; ch++) { if (ch -> ch_rastoff) { rs = ch -> ch_height * (ROUND (ch -> ch_width, 32) >> 3); if ((rp = malloc ((unsigned) rs)) == 0) return -1; /* the << 2 accounts for the fact that ch_rastoff is for 32 bit things, and we are using 8 bits (32/8 = 4 = 1<<2) */ bcopy (&p[ch -> ch_rastoff << 2], rp, rs); ch -> ch_raster = rp; } } /* Finally, release the temporary copy */ free (p + 4); } else { /* should be 'totally white' */ for (i = 128; --i >= 0; ch++) if (ch -> ch_rastoff || ch -> ch_height || ch -> ch_width || ch -> ch_yoffset || ch -> ch_xoffset) error (1, 0, "bad pxl file \"%s\"...help!", nm); } return 0; } SHAR_EOF fi # end of overwriting check # End of shell archive exit 0 ---
macintosh@felix.UUCP (02/26/87)
This is part 2 of 3 of "drawimp", a program that runs on Unix to convert MacDraw files into Impress commands for printing on Imagen laser printers. Allan Weber USC Signal and Image Processing Institute (213) 743-5519 Arpa: Weber%Brand@USC-Oberon.ARPA UUCP: ...sdcrdcf!usc-oberon!brand!weber --- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # machint.s # mactext.c # patterns.c # pxl.h # scaletfm.c # textimp.c # types.h # This archive created: Mon Feb 2 11:06:53 1987 export PATH; PATH=/bin:$PATH if test -f 'machint.s' then echo shar: will not over-write existing file "'machint.s'" else cat << \SHAR_EOF > 'machint.s' rcsid: .asciz "$Header: /ful/chris/ctex/lib/RCS/machint.s,v 1.1 84/05/26 01:53:01 chris Exp $" # machint (addr, count) # char *addr; int count; # # Convert "count" 4-byte PXL-style integers at address "addr" # to and from machine integers. (Note that calling machint # twice is effectively a no-op.) .align 2 .globl _machint _machint: .word 0 movl 4(ap),r1 # r1 = addr ashl $2,8(ap),r2 addl2 r1,r2 # r2 = &addr[count] 1: cmpl r1,r2 # is addr >= end? blss 2f ret # return if r1 >= r2 2: movl (r1)+,r0 # r0 = *r1++ movb r0,-1(r1) # byte 0 to byte 3 ashl $-8,r0,r0 # r0 >>= 8 movb r0,-2(r1) # byte 1 to byte 2 ashl $-8,r0,r0 # etc movb r0,-3(r1) ashl $-8,r0,r0 movb r0,-4(r1) brb 1b # and repeat SHAR_EOF fi # end of overwriting check if test -f 'mactext.c' then echo shar: will not over-write existing file "'mactext.c'" else cat << \SHAR_EOF > 'mactext.c' /* This routine is meant to act as an interface between drawimp (which knows nothing about how text is done on the Imagen or the format of a font file) and the textimp routine (which knows nothing about Macintoshs or MacDraw. It translates MacDraw font and style numbers into font specifications and also does ajustments for the weird way that the MacDraw text is placed in the object rectangles. */ #include <stdio.h> #include "drawimp.h" /* This table and the following constants are used to specify the font file names. The constants should correspond to the strings in "fontname". In other words, fontname[AMR] should be "amr". */ /* We have since changed over to the CM fonts. Only the names in this array have been changed, the constants like AMR have been left as is. */ static char *fontname[] = { "cmr", "cmbx", "cmti", "cmsy", "cmbsy", "cmmi", "cmmib" }; #define ANY -2 #define NONE -1 #define AMR 0 #define AMBX 1 #define AMTI 2 #define AMSY 3 #define AMBSY 4 #define AMMI 5 #define AMBI 6 #define DEF_FONT AMR #define MAX_SIZES 8 /* The following table maps the Mac font sizes into TeX font sizes. The value of "f_size" is combined with the font name from the "fontname" array to make a string like "amr10". The "d_size" and "a_size" fields are the "design size" and "at size" for the font in TeX sp units (65536 sp's to a point) and are used to select the size of font to be used. The d_size is just the f_size * 65536. The a_size is selected to match one of the fonts available on the system. The routines which find the font file will look for a file with a name like "amr10.nnnnpxl", where nnnn is the integer result of (a_size / d_size) * (printer_resolution_in_DPI / 200) * 1000. The a_size values should be changed to cause the above equation to give a result that matches whatever font size is desired for that size of Mac font. The values in the table below were selected to produce characters of about the right size on a 300DPI Imagen given the available font files. Since I don't know what fonts are usually around for 240DPI devices so I can't tell if any of these values will map to the fonts that would be available for that resolution printer. TeX does all this in a much cleaner way, but this will do for now. */ static struct fontsize { int f_size, d_size, a_size; int il_size, sp_size, tab_size; int shift_down, shift_right; } fontsize[MAX_SIZES] = { 0, 0, 0, 0, 0, 0, 0, 0, 9, 589824, 589824, 12, 3, 6, 9, 1, /* 9 */ 10, 655360, 655360, 12, 3, 6, 9, 1, /* 10 */ 10, 655360, 786432, 16, 4, 8, 11, 1, /* 12 */ 10, 655360, 943718, 19, 4, 8, 13, 1, /* 14 */ 10, 655360, 1132462, 23, 6, 12, 16, 2, /* 18 */ 10, 655360, 1630745, 29, 8, 16, 20, 2, /* 24 */ 10, 655360, 2174485, 46, 12, 24, 33, 2 /* 36 */ }; /* This table maps Mac font and character codes to TeX font and character codes. The table contains three entries for each Mac character code. The entries give the TeX font and character for plain, bold, italic. Control characters such as carriage return, tab, and space are in the table with a 0x80 added to the ASCII code to flag them so textimp can handle them differently. */ static struct fontcode { short font; short code; } fontcode[224][3] = { /* order is: plain, bold, italic */ NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, ANY, 0x89, ANY, 0x89, ANY, 0x89, /* 09 tab */ NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, ANY, 0x8D, ANY, 0x8D, ANY, 0x8D, /* 0D carriage ret */ NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, ANY, 0xA0, ANY, 0xA0, ANY, 0xA0, /* 20 space */ AMR, 0041, AMBX, 0041, AMTI, 0041, /* 21 ! */ AMR, 0175, AMBX, 0175, AMTI, 0175, /* 22 " */ AMR, 0043, AMBX, 0043, AMTI, 0043, /* 23 # */ AMR, 0044, AMBX, 0044, AMTI, 0044, /* 24 $ */ AMR, 0045, AMBX, 0045, AMTI, 0045, /* 25 % */ AMR, 0046, AMBX, 0046, AMTI, 0046, /* 26 & */ AMR, 0023, AMBX, 0023, AMTI, 0023, /* 27 ' */ AMR, 0050, AMBX, 0050, AMTI, 0050, /* 28 ( */ AMR, 0051, AMBX, 0051, AMTI, 0051, /* 29 ) */ AMR, 0052, AMBX, 0052, AMTI, 0052, /* 2A * */ AMR, 0053, AMBX, 0053, AMTI, 0053, /* 2B + */ AMR, 0054, AMBX, 0054, AMTI, 0054, /* 2C , */ AMR, 0055, AMBX, 0055, AMTI, 0055, /* 2D - */ AMR, 0056, AMBX, 0056, AMTI, 0056, /* 2E . */ AMR, 0057, AMBX, 0057, AMTI, 0057, /* 2F / */ AMR, 0060, AMBX, 0060, AMTI, 0060, /* 30 0 */ AMR, 0061, AMBX, 0061, AMTI, 0061, /* 31 1 */ AMR, 0062, AMBX, 0062, AMTI, 0062, /* 32 2 */ AMR, 0063, AMBX, 0063, AMTI, 0063, /* 33 3 */ AMR, 0064, AMBX, 0064, AMTI, 0064, /* 34 4 */ AMR, 0065, AMBX, 0065, AMTI, 0065, /* 35 5 */ AMR, 0066, AMBX, 0066, AMTI, 0066, /* 36 6 */ AMR, 0067, AMBX, 0067, AMTI, 0067, /* 37 7 */ AMR, 0070, AMBX, 0070, AMTI, 0070, /* 38 8 */ AMR, 0071, AMBX, 0071, AMTI, 0071, /* 39 9 */ AMR, 0072, AMBX, 0072, AMTI, 0072, /* 3A : */ AMR, 0073, AMBX, 0073, AMTI, 0073, /* 3B ; */ AMMI, 0074, AMBI, 0074, AMMI, 0074, /* 3C < */ AMR, 0075, AMBX, 0075, AMTI, 0075, /* 3D = */ AMMI, 0076, AMBI, 0076, AMMI, 0076, /* 3E > */ AMR, 0077, AMBX, 0077, AMTI, 0077, /* 3F ? */ AMR, 0100, AMBX, 0100, AMTI, 0100, /* 40 @ */ AMR, 0101, AMBX, 0101, AMTI, 0101, /* 41 A */ AMR, 0102, AMBX, 0102, AMTI, 0102, /* 42 B */ AMR, 0103, AMBX, 0103, AMTI, 0103, /* 43 C */ AMR, 0104, AMBX, 0104, AMTI, 0104, /* 44 D */ AMR, 0105, AMBX, 0105, AMTI, 0105, /* 45 E */ AMR, 0106, AMBX, 0106, AMTI, 0106, /* 46 F */ AMR, 0107, AMBX, 0107, AMTI, 0107, /* 47 G */ AMR, 0110, AMBX, 0110, AMTI, 0110, /* 48 H */ AMR, 0111, AMBX, 0111, AMTI, 0111, /* 49 I */ AMR, 0112, AMBX, 0112, AMTI, 0112, /* 4A J */ AMR, 0113, AMBX, 0113, AMTI, 0113, /* 4B K */ AMR, 0114, AMBX, 0114, AMTI, 0114, /* 4C L */ AMR, 0115, AMBX, 0115, AMTI, 0115, /* 4D M */ AMR, 0116, AMBX, 0116, AMTI, 0116, /* 4E N */ AMR, 0117, AMBX, 0117, AMTI, 0117, /* 4F O */ AMR, 0120, AMBX, 0120, AMTI, 0120, /* 50 P */ AMR, 0121, AMBX, 0121, AMTI, 0121, /* 51 Q */ AMR, 0122, AMBX, 0122, AMTI, 0122, /* 52 R */ AMR, 0123, AMBX, 0123, AMTI, 0123, /* 53 S */ AMR, 0124, AMBX, 0124, AMTI, 0124, /* 54 T */ AMR, 0125, AMBX, 0125, AMTI, 0125, /* 55 U */ AMR, 0126, AMBX, 0126, AMTI, 0126, /* 56 V */ AMR, 0127, AMBX, 0127, AMTI, 0127, /* 57 W */ AMR, 0130, AMBX, 0130, AMTI, 0130, /* 58 X */ AMR, 0131, AMBX, 0131, AMTI, 0131, /* 59 Y */ AMR, 0132, AMBX, 0132, AMTI, 0132, /* 5A Z */ AMR, 0133, AMBX, 0133, AMTI, 0133, /* 5B [ */ AMSY, 0156, AMBSY, 0156, AMSY, 0156, /* 5C \ */ AMR, 0135, AMBX, 0135, AMTI, 0135, /* 5D ] */ AMR, 0136, AMBX, 0136, AMTI, 0136, /* 5E ^ */ NONE, 0, NONE, 0, NONE, 0, /* 5F _ */ AMR, 0022, AMBX, 0022, AMTI, 0022, /* 60 ` */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 61 a */ AMR, 0142, AMBX, 0142, AMTI, 0142, /* 62 b */ AMR, 0143, AMBX, 0143, AMTI, 0143, /* 63 c */ AMR, 0144, AMBX, 0144, AMTI, 0144, /* 64 d */ AMR, 0145, AMBX, 0145, AMTI, 0145, /* 65 e */ AMR, 0146, AMBX, 0146, AMTI, 0146, /* 66 f */ AMR, 0147, AMBX, 0147, AMTI, 0147, /* 67 g */ AMR, 0150, AMBX, 0150, AMTI, 0150, /* 68 h */ AMR, 0151, AMBX, 0151, AMTI, 0151, /* 69 i */ AMR, 0152, AMBX, 0152, AMTI, 0152, /* 6A j */ AMR, 0153, AMBX, 0153, AMTI, 0153, /* 6B k */ AMR, 0154, AMBX, 0154, AMTI, 0154, /* 6C l */ AMR, 0155, AMBX, 0155, AMTI, 0155, /* 6D m */ AMR, 0156, AMBX, 0156, AMTI, 0156, /* 6E n */ AMR, 0157, AMBX, 0157, AMTI, 0157, /* 6F o */ AMR, 0160, AMBX, 0160, AMTI, 0160, /* 70 p */ AMR, 0161, AMBX, 0161, AMTI, 0161, /* 71 q */ AMR, 0162, AMBX, 0162, AMTI, 0162, /* 72 r */ AMR, 0163, AMBX, 0163, AMTI, 0163, /* 73 s */ AMR, 0164, AMBX, 0164, AMTI, 0164, /* 74 t */ AMR, 0165, AMBX, 0165, AMTI, 0165, /* 75 u */ AMR, 0166, AMBX, 0166, AMTI, 0166, /* 76 v */ AMR, 0167, AMBX, 0167, AMTI, 0167, /* 77 w */ AMR, 0170, AMBX, 0170, AMTI, 0170, /* 78 x */ AMR, 0171, AMBX, 0171, AMTI, 0171, /* 79 y */ AMR, 0172, AMBX, 0172, AMTI, 0172, /* 7A z */ AMSY, 0146, AMBSY, 0146, AMSY, 0146, /* 7B { */ AMSY, 0152, AMBSY, 0152, AMSY, 0152, /* 7C | */ AMSY, 0147, AMBSY, 0147, AMSY, 0147, /* 7D } */ AMR, 0176, AMBX, 0176, AMTI, 0176, /* 7E ~ */ NONE, 0, NONE, 0, NONE, 0, /* 7F */ /* the next two groups (0x8* and 0x9*) are letters with things above or below them, like accent marks. For now, just output the letter without the extra mark */ AMR, 0101, AMBX, 0101, AMTI, 0101, /* 80 A */ AMR, 0101, AMBX, 0101, AMTI, 0101, /* 81 A */ AMR, 0103, AMBX, 0103, AMTI, 0103, /* 82 C */ AMR, 0105, AMBX, 0105, AMTI, 0105, /* 83 E */ AMR, 0116, AMBX, 0116, AMTI, 0116, /* 84 N */ AMR, 0117, AMBX, 0117, AMTI, 0117, /* 85 O */ AMR, 0125, AMBX, 0125, AMTI, 0125, /* 86 U */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 87 a */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 88 a */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 89 a */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 8A a */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 8B a */ AMR, 0141, AMBX, 0141, AMTI, 0141, /* 8C a */ AMR, 0143, AMBX, 0143, AMTI, 0143, /* 8D c */ AMR, 0145, AMBX, 0145, AMTI, 0145, /* 8E e */ AMR, 0145, AMBX, 0145, AMTI, 0145, /* 8F e */ AMR, 0145, AMBX, 0145, AMTI, 0145, /* 90 e */ AMR, 0145, AMBX, 0145, AMTI, 0145, /* 91 e */ AMR, 0151, AMBX, 0151, AMTI, 0151, /* 92 i */ AMR, 0151, AMBX, 0151, AMTI, 0151, /* 93 i */ AMR, 0151, AMBX, 0151, AMTI, 0151, /* 94 i */ AMR, 0151, AMBX, 0151, AMTI, 0151, /* 95 i */ AMR, 0156, AMBX, 0156, AMTI, 0156, /* 96 n */ AMR, 0157, AMBX, 0157, AMTI, 0157, /* 97 o */ AMR, 0157, AMBX, 0157, AMTI, 0157, /* 98 o */ AMR, 0157, AMBX, 0157, AMTI, 0157, /* 99 o */ AMR, 0157, AMBX, 0157, AMTI, 0157, /* 9A o */ AMR, 0157, AMBX, 0157, AMTI, 0157, /* 9B o */ AMR, 0165, AMBX, 0165, AMTI, 0165, /* 9C u */ AMR, 0165, AMBX, 0165, AMTI, 0165, /* 9D u */ AMR, 0165, AMBX, 0165, AMTI, 0165, /* 9E u */ AMR, 0165, AMBX, 0165, AMTI, 0165, /* 9F u */ AMSY, 0171, AMBSY, 0171, AMSY, 0171, /* A0 dagger */ AMR, 0027, AMBX, 0027, AMTI, 0027, /* A1 degree */ NONE, 0, NONE, 0, NONE, 0, /* A2 cents */ AMTI, 0044, AMTI, 0044, AMTI, 0044, /* A3 British pound */ AMSY, 0170, AMBSY, 0170, AMSY, 0170, /* A4 ?? */ AMSY, 0017, AMBSY, 0017, AMSY, 0017, /* A5 filled dot */ AMSY, 0173, AMBSY, 0173, AMSY, 0173, /* A6 paragraph */ AMR, 0031, AMBX, 0031, AMTI, 0031, /* A7 ?? */ NONE, 0, NONE, 0, NONE, 0, /* A8 registered */ NONE, 0, NONE, 0, NONE, 0, /* A9 copyright */ NONE, 0, NONE, 0, NONE, 0, /* AA trademark */ AMR, 0023, AMBX, 0023, AMTI, 0023, /* AB accent */ AMR, 0177, AMBX, 0177, AMTI, 0177, /* AC two dots */ NONE, 0, NONE, 0, NONE, 0, /* AD not equal */ AMR, 0035, AMBX, 0035, AMTI, 0035, /* AE AE */ AMR, 0037, AMBX, 0037, AMTI, 0037, /* AF O with slash */ AMSY, 0061, AMBSY, 0061, AMSY, 0061, /* B0 infinity */ AMSY, 0006, AMBSY, 0006, AMSY, 0006, /* B1 plus-minus */ AMSY, 0024, AMBSY, 0024, AMSY, 0024, /* B2 <= */ AMSY, 0025, AMBSY, 0025, AMSY, 0025, /* B3 >= */ AMMI, 0022, AMBI, 0022, AMMI, 0022, /* B4 theta (??) Yen */ AMMI, 0026, AMBI, 0026, AMMI, 0026, /* B5 mu */ AMMI, 0100, AMBI, 0100, AMMI, 0100, /* B6 partial */ AMR, 0006, AMBX, 0006, AMTI, 0006, /* B7 Sigma */ AMR, 0005, AMBX, 0005, AMTI, 0005, /* B8 Pi */ AMMI, 0031, AMBI, 0031, AMMI, 0031, /* B9 pi */ AMSY, 0163, AMBSY, 0163, AMSY, 0163, /* BA integral */ AMMI, 0013, AMBI, 0013, AMMI, 0013, /* BB alpha (??) a underbar */ AMMI, 0041, AMBI, 0041, AMMI, 0041, /* BC omega (??) o underbar */ AMR, 0012, AMBX, 0012, AMTI, 0012, /* BD Omega */ AMR, 0032, AMBX, 0032, AMTI, 0032, /* BE ae */ AMMI, 0014, AMBI, 0014, AMMI, 0014, /* BF beta (??) o with slash) */ AMR, 0076, AMBX, 0076, AMTI, 0076, /* C0 ? upside down */ AMR, 0074, AMBX, 0074, AMTI, 0074, /* C1 ! upside down */ AMSY, 0072, AMBSY, 0072, AMSY, 0072, /* C2 not */ AMSY, 0160, AMBSY, 0160, AMSY, 0160, /* C3 radical */ NONE, 0, NONE, 0, NONE, 0, /* C4 ?? */ AMSY, 0031, AMBSY, 0031, AMSY, 0031, /* C5 approx. equal */ AMSY, 0064, AMBSY, 0064, AMSY, 0064, /* C6 triangle */ AMSY, 0034, AMBSY, 0034, AMSY, 0034, /* C7 << */ AMSY, 0035, AMBSY, 0035, AMSY, 0035, /* C8 >> */ NONE, 0, NONE, 0, NONE, 0, /* C9 ellipsis */ NONE, 0, NONE, 0, NONE, 0, /* CA non-brea. sp. */ AMR, 0101, AMBX, 0101, AMTI, 0101, /* CB A with accent */ AMR, 0101, AMBX, 0101, AMTI, 0101, /* CC A with tilde */ AMR, 0117, AMBX, 0117, AMTI, 0117, /* CD O with tilde */ AMR, 0036, AMBX, 0036, AMTI, 0036, /* CE OE */ AMR, 0033, AMBX, 0033, AMTI, 0033, /* CF oe */ AMR, 0173, AMBX, 0173, AMTI, 0173, /* D0 n-dash */ AMR, 0174, AMBX, 0174, AMTI, 0174, /* D1 m-dash */ AMR, 0134, AMBX, 0134, AMTI, 0134, /* D2 open quotes */ AMR, 0042, AMBX, 0042, AMTI, 0042, /* D3 close quotes */ AMR, 0140, AMBX, 0140, AMTI, 0140, /* D4 open quote */ AMR, 0047, AMBX, 0047, AMTI, 0047, /* D5 close quote */ AMSY, 0004, AMBSY, 0004, AMSY, 0004, /* D6 divide */ AMSY, 0005, AMBSY, 0005, AMSY, 0005, /* D7 diamond */ AMR, 0171, AMBX, 0171, AMTI, 0171, /* D8 y with umlaut */ NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, NONE, 0, }; #define MAX_CHAR (sizeof(fontcode) / sizeof(struct fontcode)) int il_size, sp_size, tab_size; static init = 0; static char fontspec[40]; extern char *malloc(); mactext(s,startv,starth,style,font,size,spacing,align,angle) char *s; int startv,starth,style,font,size,spacing,align,angle; { int id, i, v, h, cur_font, new_line; struct fontsize *fs; struct fontcode *fc; char *p, *b; if (init == 0) { fs = fontsize; /* change things to Imagen units */ for (i = 0; i <= MAX_SIZES; i++) { fs->il_size = md2im(fs->il_size); fs->sp_size = md2im(fs->sp_size); fs->tab_size = md2im(fs->tab_size); fs->shift_down = md2im(fs->shift_down); fs->shift_right = md2im(fs->shift_right); fs++; } init = 1; } if (size > 7) size = 7; fs = &fontsize[size]; il_size = fs->il_size; sp_size = fs->sp_size; tab_size= fs->tab_size; v = startv + fs->shift_down; h = starth + fs->shift_right; /* fprintf(stderr,"startv=%d, starth=%d, size=%d, v=%d, h=%d\n", startv, starth, size, v, h); */ if (style > 2) /* only plain, bold, and italic */ style = 0; /* anything else is plain */ b = malloc(strlen(s) + 1); new_line = 1; while (*s != '\0') { p = b; cur_font = NONE; while (*s != '\0') { i = *s & 0377; if (i >= MAX_CHAR) i = 0; fc = &fontcode[i][style]; if (cur_font == NONE && fc->font != ANY) cur_font = fc->font; if (fc->font != ANY && fc->font != NONE && cur_font != fc->font) break; /* changed fonts */ if (fc->font != NONE) *p++ = fc->code; s++; } *p = '\0'; if (cur_font == NONE) cur_font = DEF_FONT; sprintf(fontspec,"%s%d",fontname[cur_font],fs->f_size); /* fprintf(stderr,"%s %s\n",fontspec,b); */ id = selectfont(fontspec, fs->a_size, fs->d_size); textimp(b,v,h,new_line); new_line = 0; /* make textimp leave position as is */ } } SHAR_EOF fi # end of overwriting check if test -f 'patterns.c' then echo shar: will not over-write existing file "'patterns.c'" else cat << \SHAR_EOF > 'patterns.c' char pattern[37][128] = { { /* 00 (not used) */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 01 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 02 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 03 */ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }, { /* 04 */ 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77, 0xdd,0xdd,0xdd,0xdd,0x77,0x77,0x77,0x77 }, { /* 05 */ 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55 }, { /* 06 */ 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88,0x22,0x22,0x22,0x22 }, { /* 07 */ 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00 }, { /* 08 */ 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00 }, { /* 09 */ 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 10 */ 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x40,0x00,0x00,0x01,0x40,0x00,0x00,0x01, 0x40,0x00,0x00,0x01,0x20,0x00,0x00,0x02, 0x20,0x00,0x00,0x02,0x10,0x00,0x00,0x04, 0x10,0x00,0x00,0x04,0x08,0x00,0x00,0x08, 0x06,0x00,0x00,0x30,0x01,0x80,0x00,0xC0, 0x00,0x70,0x07,0x00,0x00,0x0F,0xF8,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x01,0x40,0x00,0x00,0x01,0x40,0x00, 0x00,0x01,0x40,0x00,0x00,0x02,0x20,0x00, 0x00,0x02,0x20,0x00,0x00,0x04,0x10,0x00, 0x00,0x04,0x10,0x00,0x00,0x08,0x08,0x00, 0x00,0x30,0x06,0x00,0x00,0xC0,0x01,0x80, 0x07,0x00,0x00,0x70,0xF8,0x00,0x00,0x0F }, { /* 11 */ 0xff,0xff,0xff,0xff,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00 }, { /* 12 */ 0x00,0x01,0x80,0x00,0x00,0x02,0x40,0x00, 0x00,0x04,0x20,0x00,0x00,0x08,0x10,0x00, 0x00,0x10,0x08,0x00,0x00,0x20,0x04,0x00, 0x00,0x40,0x02,0x00,0x00,0x80,0x01,0x00, 0x01,0x00,0x00,0x80,0x02,0x00,0x00,0x40, 0x04,0x00,0x00,0x20,0x08,0x00,0x00,0x10, 0x10,0x00,0x00,0x08,0x20,0x00,0x00,0x04, 0x40,0x00,0x00,0x02,0x80,0x00,0x00,0x01, 0x00,0x01,0x80,0x00,0x00,0x02,0x40,0x00, 0x00,0x04,0x20,0x00,0x00,0x08,0x10,0x00, 0x00,0x10,0x08,0x00,0x00,0x20,0x04,0x00, 0x00,0x40,0x02,0x00,0x00,0x80,0x01,0x00, 0x01,0x00,0x00,0x80,0x02,0x00,0x00,0x40, 0x04,0x00,0x00,0x20,0x08,0x00,0x00,0x10, 0x10,0x00,0x00,0x08,0x20,0x00,0x00,0x04, 0x40,0x00,0x00,0x02,0x80,0x00,0x00,0x01 }, { /* 13 */ 0x80,0x00,0x00,0x00,0x40,0x00,0x00,0x00, 0x20,0x00,0x00,0x00,0x10,0x00,0x00,0x00, 0x08,0x00,0x00,0x00,0x04,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x80,0x00,0x00,0x00,0x40,0x00,0x00, 0x00,0x20,0x00,0x00,0x00,0x10,0x00,0x00, 0x00,0x08,0x00,0x00,0x00,0x04,0x00,0x00, 0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x40,0x00, 0x00,0x00,0x20,0x00,0x00,0x00,0x10,0x00, 0x00,0x00,0x08,0x00,0x00,0x00,0x04,0x00, 0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00, 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x40, 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x04, 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01 }, { /* 14 */ 0xff,0xf0,0x00,0x00,0x7f,0xf8,0x00,0x00, 0x3f,0xfc,0x00,0x00,0x1f,0xfe,0x00,0x00, 0x0f,0xff,0x00,0x00,0x07,0xff,0x80,0x00, 0x03,0xff,0xc0,0x00,0x01,0xff,0xe0,0x00, 0x00,0xff,0xf0,0x00,0x00,0x7f,0xf8,0x00, 0x00,0x3f,0xfc,0x00,0x00,0x1f,0xfe,0x00, 0x00,0x0f,0xff,0x00,0x00,0x07,0xff,0x80, 0x00,0x03,0xff,0xc0,0x00,0x01,0xff,0xe0, 0x00,0x00,0xff,0xf0,0x00,0x00,0x7f,0xf8, 0x00,0x00,0x3f,0xfc,0x00,0x00,0x1f,0xfe, 0x00,0x00,0x0f,0xff,0x80,0x00,0x07,0xff, 0xc0,0x00,0x03,0xff,0xe0,0x00,0x01,0xfd, 0xf0,0x00,0x00,0xff,0xf8,0x00,0x00,0x7f, 0xfc,0x00,0x00,0x3f,0xfe,0x00,0x00,0x1f, 0xff,0x00,0x00,0x0f,0xff,0x80,0x00,0x07, 0xff,0xc0,0x00,0x03,0xff,0xe0,0x00,0x01 }, { /* 15 */ 0xff,0xf0,0xff,0xf0,0x7f,0xf8,0x7f,0xf8, 0x3f,0xfc,0x3f,0xfc,0x1f,0xfe,0x1f,0xfe, 0x0f,0xff,0x0f,0xff,0x87,0xff,0x87,0xff, 0xc3,0xff,0xc3,0xff,0xe1,0xff,0xe1,0xff, 0xf0,0xff,0xf0,0xff,0xf8,0x7f,0xf8,0x7f, 0xfc,0x3f,0xfc,0x3f,0xfe,0x1f,0xfe,0x1f, 0xff,0x0f,0xff,0x0f,0xff,0x87,0xff,0x87, 0xff,0xc3,0xff,0xc3,0xff,0xe1,0xff,0xe1, 0xff,0xf0,0xff,0xf0,0x7f,0xf8,0x7f,0xf8, 0x3f,0xfc,0x3f,0xfc,0x1f,0xfe,0x1f,0xfe, 0x0f,0xff,0x0f,0xff,0x87,0xff,0x87,0xff, 0xc3,0xff,0xc3,0xff,0xe1,0xff,0xe1,0xff, 0xf0,0xff,0xf0,0xff,0xf8,0x7f,0xf8,0x7f, 0xfc,0x3f,0xfc,0x3f,0xfe,0x1f,0xfe,0x1f, 0xff,0x0f,0xff,0x0f,0xff,0x87,0xff,0x87, 0xff,0xc3,0xff,0xc3,0xff,0xe1,0xff,0xe1 }, { /* 16 */ 0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00, 0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00, 0x08,0x00,0x08,0x00,0x04,0x00,0x04,0x00, 0x02,0x00,0x02,0x00,0x01,0x00,0x01,0x00, 0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40, 0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10, 0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x04, 0x00,0x02,0x00,0x02,0x00,0x01,0x00,0x01, 0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00, 0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00, 0x08,0x00,0x08,0x00,0x04,0x00,0x04,0x00, 0x02,0x00,0x02,0x00,0x01,0x00,0x01,0x00, 0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40, 0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10, 0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x04, 0x00,0x02,0x00,0x02,0x00,0x01,0x00,0x01 }, { /* 17 */ 0xff,0x00,0xff,0x00,0x7f,0x80,0x7f,0x80, 0x3f,0xc0,0x3f,0xc0,0x1f,0xe0,0x1f,0xe0, 0x0f,0xf0,0x0f,0xf0,0x07,0xf8,0x07,0xf8, 0x03,0xfc,0x03,0xfc,0x01,0xfe,0x01,0xfe, 0x00,0xff,0x00,0xff,0x80,0x7f,0x80,0x7f, 0xc0,0x3f,0xc0,0x3f,0xe0,0x1f,0xe0,0x1f, 0xf0,0x0f,0xf0,0x0f,0xf8,0x07,0xf8,0x07, 0xfc,0x03,0xfc,0x03,0xfe,0x01,0xfe,0x01, 0xff,0x00,0xff,0x00,0x7f,0x80,0x7f,0x80, 0x3f,0xc0,0x3f,0xc0,0x1f,0xe0,0x1f,0xe0, 0x0f,0xf0,0x0f,0xf0,0x07,0xf8,0x07,0xf8, 0x03,0xfc,0x03,0xfc,0x01,0xfe,0x01,0xfe, 0x00,0xff,0x00,0xff,0x80,0x7f,0x80,0x7f, 0xc0,0x3f,0xc0,0x3f,0xe0,0x1f,0xe0,0x1f, 0xf0,0x0f,0xf0,0x0f,0xf8,0x07,0xf8,0x07, 0xfc,0x03,0xfc,0x03,0xfe,0x01,0xfe,0x01 }, { /* 18 */ 0x80,0x00,0x00,0x00,0x40,0x00,0x00,0x00, 0x20,0x00,0x00,0x00,0x10,0x00,0x00,0x00, 0x08,0x00,0x00,0x00,0x04,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x80,0x00,0x00,0x00,0x40,0x00,0x00, 0x00,0x20,0x00,0x00,0x00,0x10,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x20, 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80, 0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00, 0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00, 0x00,0x00,0x10,0x00,0x00,0x00,0x20,0x00, 0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 19 */ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 20 */ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 21 */ 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 22 */ 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff }, { /* 23 */ 0xff,0xff,0xff,0xff,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0xff,0xff,0xff,0xff,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00 }, { /* 24 */ 0x00,0x01,0x00,0x01,0x80,0x02,0x80,0x02, 0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x08, 0x10,0x10,0x10,0x10,0x08,0x20,0x08,0x20, 0x04,0x40,0x04,0x40,0x02,0x80,0x02,0x80, 0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80, 0x04,0x40,0x04,0x40,0x08,0x20,0x08,0x20, 0x10,0x10,0x10,0x10,0x20,0x08,0x20,0x08, 0x40,0x04,0x40,0x04,0x80,0x02,0x80,0x02, 0x00,0x01,0x00,0x01,0x80,0x02,0x80,0x02, 0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x08, 0x10,0x10,0x10,0x10,0x08,0x20,0x08,0x20, 0x04,0x40,0x04,0x40,0x02,0x80,0x02,0x80, 0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80, 0x04,0x40,0x04,0x40,0x08,0x20,0x08,0x20, 0x10,0x10,0x10,0x10,0x20,0x08,0x20,0x08, 0x40,0x04,0x40,0x04,0x80,0x02,0x80,0x02 }, { /* 25 */ 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02, 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08, 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x20, 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80, 0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00, 0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00, 0x00,0x00,0x10,0x00,0x00,0x00,0x20,0x00, 0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x00, 0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00, 0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00, 0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00, 0x00,0x40,0x00,0x00,0x00,0x80,0x00,0x00, 0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00, 0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00, 0x40,0x00,0x00,0x00,0x80,0x00,0x00,0x00 }, { /* 26 */ 0x00,0x00,0x0f,0xff,0x00,0x00,0x1f,0xfe, 0x00,0x00,0x3f,0xfc,0x00,0x00,0x7f,0xf8, 0x00,0x00,0xff,0xf0,0x00,0x01,0xff,0xe0, 0x00,0x03,0xff,0xc0,0x00,0x07,0xff,0x80, 0x00,0x0f,0xff,0x00,0x00,0x1f,0xfe,0x00, 0x00,0x3f,0xfc,0x00,0x00,0x7f,0xf8,0x00, 0x00,0xff,0xf0,0x00,0x01,0xff,0xe0,0x00, 0x03,0xff,0xc0,0x00,0x07,0xff,0x80,0x00, 0x0f,0xff,0x00,0x00,0x1f,0xfe,0x00,0x00, 0x3f,0xfc,0x00,0x00,0x7f,0xf8,0x00,0x00, 0xff,0xf0,0x00,0x00,0xff,0xe0,0x00,0x01, 0xff,0xc0,0x00,0x03,0xff,0x80,0x00,0x07, 0xff,0x00,0x00,0x0f,0xfe,0x00,0x00,0x1f, 0xfc,0x00,0x00,0x3f,0xf8,0x00,0x00,0x7f, 0xf0,0x00,0x00,0xff,0xe0,0x00,0x01,0xff, 0xc0,0x00,0x03,0xff,0x80,0x00,0x07,0xff }, { /* 27 */ 0x0f,0xff,0x0f,0xff,0x1f,0xfe,0x1f,0xfe, 0x3f,0xfc,0x3f,0xfc,0x7f,0xf8,0x7f,0xf8, 0xff,0xf0,0xff,0xf0,0xff,0xe1,0xff,0xe1, 0xff,0xc3,0xff,0xc3,0xff,0x87,0xff,0x87, 0xff,0x0f,0xff,0x0f,0xfe,0x1f,0xfe,0x1f, 0xfc,0x3f,0xfc,0x3f,0xf8,0x7f,0xf8,0x7f, 0xf0,0xff,0xf0,0xff,0xe1,0xff,0xe1,0xff, 0xc3,0xff,0xc3,0xff,0x87,0xff,0x87,0xff, 0x0f,0xff,0x0f,0xff,0x1f,0xfe,0x1f,0xfe, 0x3f,0xfc,0x3f,0xfc,0x7f,0xf8,0x7f,0xf8, 0xff,0xf0,0xff,0xf0,0xff,0xe1,0xff,0xe1, 0xff,0xc3,0xff,0xc3,0xff,0x87,0xff,0x87, 0xff,0x0f,0xff,0x0f,0xfe,0x1f,0xfe,0x1f, 0xfc,0x3f,0xfc,0x3f,0xf8,0x7f,0xf8,0x7f, 0xf0,0xff,0xf0,0xff,0xe1,0xff,0xe1,0xff, 0xc3,0xff,0xc3,0xff,0x87,0xff,0x87,0xff }, { /* 28 */ 0x00,0x01,0x00,0x01,0x00,0x02,0x00,0x02, 0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x08, 0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20, 0x00,0x40,0x00,0x40,0x00,0x80,0x00,0x80, 0x01,0x00,0x01,0x00,0x02,0x00,0x02,0x00, 0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00, 0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00, 0x40,0x00,0x40,0x00,0x80,0x00,0x80,0x00, 0x00,0x01,0x00,0x01,0x00,0x02,0x00,0x02, 0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x08, 0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20, 0x00,0x40,0x00,0x40,0x00,0x80,0x00,0x80, 0x01,0x00,0x01,0x00,0x02,0x00,0x02,0x00, 0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00, 0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00, 0x40,0x00,0x40,0x00,0x80,0x00,0x80,0x00 }, { /* 29 */ 0x00,0xff,0x00,0xff,0x01,0xfe,0x01,0xfe, 0x03,0xfc,0x03,0xfc,0x07,0xf8,0x07,0xf8, 0x0f,0xf0,0x0f,0xf0,0x1f,0xe0,0x1f,0xe0, 0x3f,0xc0,0x3f,0xc0,0x7f,0x80,0x7f,0x80, 0xff,0x00,0xff,0x00,0xfe,0x01,0xfe,0x01, 0xfc,0x03,0xfc,0x03,0xf8,0x07,0xf8,0x07, 0xf0,0x0f,0xf0,0x0f,0xe0,0x1f,0xe0,0x1f, 0xc0,0x3f,0xc0,0x3f,0x80,0x7f,0x80,0x7f, 0x00,0xff,0x00,0xff,0x01,0xfe,0x01,0xfe, 0x03,0xfc,0x03,0xfc,0x07,0xf8,0x07,0xf8, 0x0f,0xf0,0x0f,0xf0,0x1f,0xe0,0x1f,0xe0, 0x3f,0xc0,0x3f,0xc0,0x7f,0x80,0x7f,0x80, 0xff,0x00,0xff,0x00,0xfe,0x01,0xfe,0x01, 0xfc,0x03,0xfc,0x03,0xf8,0x07,0xf8,0x07, 0xf0,0x0f,0xf0,0x0f,0xe0,0x1f,0xe0,0x1f, 0xc0,0x3f,0xc0,0x3f,0x80,0x7f,0x80,0x7f }, { /* 30 */ 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x05,0x00,0x00,0x00,0x08,0x80,0x00,0x00, 0x10,0x40,0x00,0x00,0x20,0x20,0x00,0x00, 0x40,0x10,0x00,0x00,0x80,0x08,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00, 0x00,0x00,0x05,0x00,0x00,0x00,0x08,0x80, 0x00,0x00,0x10,0x40,0x00,0x00,0x20,0x20, 0x00,0x00,0x40,0x10,0x00,0x00,0x80,0x08, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { /* 31 */ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 }, { /* 32 */ 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00 }, { /* 33 */ 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00 }, { /* 34 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x20,0x00, 0x00,0x00,0x80,0x00,0x00,0x02,0x20,0x00, 0x00,0x08,0x88,0x00,0x00,0x02,0x22,0x00, 0x00,0x08,0x88,0x00,0x00,0x22,0x22,0x00, 0x00,0x88,0x88,0x80,0x00,0x22,0x22,0x20, 0x00,0x88,0x88,0x80,0x02,0x22,0x22,0x20, 0x08,0x88,0x88,0x88,0x02,0x22,0x22,0x22, 0x08,0x88,0x88,0x88,0x02,0x22,0x22,0x22, 0x00,0x88,0x88,0x88,0x00,0x22,0x22,0x20, 0x00,0x88,0x88,0x80,0x00,0x22,0x22,0x20, 0x00,0x08,0x88,0x80,0x00,0x02,0x22,0x00, 0x00,0x08,0x88,0x00,0x00,0x02,0x22,0x00, 0x00,0x00,0x88,0x00,0x00,0x00,0x20,0x00, 0x00,0x00,0x80,0x00,0x00,0x00,0x20,0x00 }, { /* 35 */ 0xff,0xff,0xff,0xff,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00 }, { /* 36 */ 0x00,0x00,0x80,0x00,0x00,0x01,0x40,0x00, 0x00,0x02,0x20,0x00,0x00,0x04,0x10,0x00, 0x00,0x08,0x08,0x00,0x00,0x10,0x04,0x00, 0x00,0x20,0x02,0x00,0x00,0x40,0x01,0x00, 0x00,0x80,0x00,0x80,0x01,0x00,0x00,0x40, 0x02,0x00,0x00,0x20,0x04,0x00,0x00,0x10, 0x08,0x00,0x00,0x08,0x10,0x00,0x00,0x04, 0x20,0x00,0x00,0x02,0x40,0x00,0x00,0x01, 0x80,0x00,0x00,0x00,0x40,0x00,0x00,0x01, 0x20,0x00,0x00,0x02,0x10,0x00,0x00,0x04, 0x08,0x00,0x00,0x08,0x04,0x00,0x00,0x10, 0x02,0x00,0x00,0x20,0x01,0x00,0x00,0x40, 0x00,0x80,0x00,0x80,0x00,0x40,0x01,0x00, 0x00,0x20,0x02,0x00,0x00,0x10,0x04,0x00, 0x00,0x08,0x08,0x00,0x00,0x04,0x10,0x00, 0x00,0x02,0x20,0x00,0x00,0x01,0x40,0x00 } }; SHAR_EOF fi # end of overwriting check if test -f 'pxl.h' then echo shar: will not over-write existing file "'pxl.h'" else cat << \SHAR_EOF > 'pxl.h' /* PXL file format */ /* Note: PXL files are stored in the opposite of VAX byte order, which means each group of 4 bytes must be reversed before using the info. */ #define PXLID 1001 /* PXL file ID number */ #ifndef PXLPATH #define PXLPATH "/usr/lib/tex/fonts" /* path to PXL font files. The shell's convention of colon-separated names is honoured. */ #endif PXLPATH #define FONT_SLOP 5 /* how much "slop" from the given magnification is permitted when looking for a font (e.g., if the computed size is 999, will try up to 999 +- FONT_SLOP, until something is found) */ /* chinfo is called the "font directory" by the PXL file description, but I think that "character info" is a more accurate description. Each group of 4 "words" is one of these things, and there are 128 such groups, one for each character. Note that for empty characters ch_un.un_rastoff will be zero. The "#if vax" is for vax-dependent byte order stuff (I know, it's ugly). */ struct chinfo { #if vax || ns32000 /* little-endian order */ short ch_height; short ch_width; short ch_yoffset; short ch_xoffset; #else /* big-endian order */ short ch_width; /* character width */ short ch_height; /* character height */ short ch_xoffset; /* X offset of ref point */ short ch_yoffset; /* Y offset of ref point */ #endif union { int un_rastoff; /* raster offset from word 0 */ char *un_raster; /* pointer to actual raster */ } ch_un; int ch_TFMwidth; /* TFM width (in FIXes) */ }; /* shorthand */ #define ch_rastoff ch_un.un_rastoff #define ch_raster ch_un.un_raster /* The end of the PXL file looks like this */ struct pxltail { struct chinfo px_info[128]; /* "font directory" info */ int px_checksum; /* checksum */ int px_magnification; /* magnification factor */ int px_designsize; /* font design size (FIXes) */ int px_dirpointer; /* directory pointer */ int px_pxlid; /* pxlid, should be == PXLID */ }; /* Function types */ double DMagFactor (); char *GenPXLFileName (); struct pxltail *ReadPXLFile (); SHAR_EOF fi # end of overwriting check if test -f 'scaletfm.c' then echo shar: will not over-write existing file "'scaletfm.c'" else cat << \SHAR_EOF > 'scaletfm.c' #ifndef lint static char rcsid[] = "$Header: scaletfm.c,v 1.3 85/09/12 08:51:10 chris Exp $"; #endif #include "types.h" #include "pxl.h" /* From DVITYPE.WEB: ``The most important part of in_TFM is the width computation, which involvles multiplying the relative widths in the TFM file by the scaling factor in the DVI file. This fixed-point multiplication must be done with precisely the same accuracy by all DVI-reading programs, in order to validate the assumptions made by DVI-writing programs like \TeX 82. Let us therefore summarize what needs to be done. Each width in a TFM file appears as a four-byte quantity called a fix_word. A fix_word whose respective bytes are (a,b,c,d) represents the number {{ b * 2^{-4} + c * 2^{-12} + d * 2^{-20}, if a = 0; x = {{ {{ -16 + b * 2^{-4} + c * 2^{-12} + d * 2^{-20}, if a = 255. (No other choices of a are allowed, since the magnitude of a TFM dimension must be less than 16.) We want to multiply this quantity by the integer z, which is known to be less than 2^{27}. Let \alpha = 16z. If z < 2^{23}, the individual multiplications b * z, c * z, d * z cannot overflow; otherwise we will divide z by 2, 4, 8, or 16, to obtain a multiplier less than 2^{23}, and we can compensate for this later. If z has thereby been replaced by z' = z/2^e, let \beta = 2^{4-e}; we shall compute \lfloor (b + c * 2^{-8} + d * 2^{-16})z' / \beta \rfloor if a = 0, or the same quantity minus \alpha if a = 255. This calculation must be done exactly, for the reasons stated above; the following program does the job in a system-independent way, assuming that arithmetic is exact on numbers less than 2^{31} in magnitude.'' */ /* In other words, we are assuming 32-bit (minimum) arithmetic, and take pains to ensure that each intermediate result fits within 32 bits. This routine converts the TFM widths in the px_info part of a pxltail pointer 'px' given the scale factor 'z'. */ ScaleTFMWidths (px, z) struct pxltail *px; register i32 z; { register i32 alpha, log2beta, t; register struct chinfo *ch; register int i; /* First compute \alpha, \beta, and z': */ alpha = 16 * z; log2beta = 4; while (z >= (1 << 23)) { z >>= 1; log2beta--; } /* The four values 'a', 'b', 'c', and 'd' are fields within t: */ #define a (UnSign8 (t >> 24)) #define b (UnSign8 (t >> 16)) #define c (UnSign8 (t >> 8)) #define d (UnSign8 (t)) ch = px -> px_info; for (i = 0; i < 128; i++) { if (t = ch -> ch_TFMwidth) { t = (((((d * z) >> 8) + c * z) >> 8) + b * z) >> log2beta; if (a) { if (a != 255) error (0, 0, "bad TFM width!"); t -= alpha; } ch -> ch_TFMwidth = t; } ch++; } } /* Provided in case anyone is not using the standard PXL file formats: scale the single TFM width 't' by 'z' */ i32 ScaleOneWidth (t, z) register i32 t, z; { register i32 alpha, log2beta; alpha = 16 * z; log2beta = 4; while (z >= (1 << 23)) { z >>= 1; log2beta--; } if (t) { t = (((((d * z) >> 8) + c * z) >> 8) + b * z) >> log2beta; if (a) { if (a != 255) error (0, 0, "bad TFM width! [ScaleOneWidth]"); t -= alpha; } } return t; } SHAR_EOF fi # end of overwriting check if test -f 'textimp.c' then echo shar: will not over-write existing file "'textimp.c'" else cat << \SHAR_EOF > 'textimp.c' /* #define DEBUG */ /* #define DEBUG2 */ #include "types.h" #include "pxl.h" #include <stdio.h> #include "drawimp.h" #define NFONTS 128 /* max number of fonts */ extern int errno; /* Globals */ struct fontinfo { struct pxltail *px; /* pxl file info */ int family; /* Imagen family number (we pick one) */ int cwidth[128]; /* width (in DEVs) of each char */ char cload[128]; /* flag for ``char loaded into Imagen'' */ }; struct fontinfo FontInfo[NFONTS];/* the fonts themselves */ struct fontinfo *CurrentFont; /* the current font (if any) */ int NextFamilyNumber = FONT_FAMILY_TOP; /* next available Imagen glyph-family index */ int numfonts; /* number of fonts read in so far */ char *TeXfonts; /* getenv("TEXFONTS") */ int hh; /* current horizontal position, in DEVs */ int vv; /* current vertical position, in DEVs */ int ImHH; /* Imagen horizontal position */ int ImVV; /* Imagen vertical position */ int ImFamily; /* Imagen current-font number */ double UserMag; /* user specified magnification */ double GlobalMag; /* overall magnification (UserMag*DVIMag) */ int IntGlobalMag; /* ROUND (GlobalMag * 1000.0) */ double conv; /* conversion factor for magnified DVI units */ double OneHalf = 0.5; /* .5, so compiler can generate constant only once */ char *getenv (), *malloc (); /* Round a floating point number to integer */ #define ROUND(f) ((int) ((f) + OneHalf)) /* Convert a value in sp's to dev's, and vice versa */ #define SPtoDEV(sp) (ROUND ((sp) * conv)) #define DEVtoSP(dev) (ROUND ((dev) / conv)) static int text_init, sp_size_set, il_size_set; extern int resolution; extern int sp_size, tab_size, il_size; extern FILE *fontfp, *impout(); /***********************************************************************/ textimp(s,startv,starth,setpos) char *s; int startv,starth,setpos; { char ch; if (text_init == 0) initialize(); if (setpos) { /* setpos != 0 to set h,v position and mark BOL */ hh = starth; vv = startv; imP_set_bol(hh); } while ((ch = *s++) != '\0') { if (ch & 0x80) { /* something special */ ch &= 0x7f; if (ch == '\r') { if (il_size != il_size_set) imP_set_il(il_size_set = il_size); imP_crlf(); ImVV += il_size; vv += il_size; } else if (ch == ' ') { if (sp_size != sp_size_set) imP_set_sp(sp_size_set = sp_size); imP_sp(); ImHH += sp_size; hh += sp_size; } else if (ch == '\t') { if (tab_size != sp_size_set) imP_set_sp(sp_size_set = tab_size); imP_sp(); ImHH += sp_size; hh += sp_size; } } else { DoChar(ch, 1); } } } static initialize() { reset_text(); TeXfonts = getenv ("TEXFONTS"); if (TeXfonts == 0) TeXfonts = ""; UserMag = ((double) resolution) / 200; GlobalMag = UserMag; IntGlobalMag = ROUND (GlobalMag * 1000.0); conv = (100.0) * (200.0 / 473628672) * GlobalMag; #ifdef DEBUG fprintf(stderr,"TeXfonts=%s\n",TeXfonts); fprintf(stderr,"UserMag=%g, GlobalMag=%g, IntGlobalMag=%d\n", UserMag, GlobalMag, IntGlobalMag); fprintf(stderr,"conv=%g\n",conv); #endif text_init = 1; } /* This should be called after each output file is complete to make sure things get set right for the next file. */ reset_text() { sp_size_set = 0; il_size_set = 0; ImHH = ImVV = ImFamily = -1; } /* Resets all fonts to show as not downloaded yet. */ reset_fonts() { int i, j; char *cl; for (i = 0; i < numfonts; i++) { cl = FontInfo[i].cload; for (j = 128; j > 0; j--) *cl++ = 0; } } /* Given a font file name, find the font table entry for it. If 'define' is nonzero, make an entry for it. */ selectfont(name,at_size,design_size) char *name; int at_size, design_size; { char *font; struct finder { char *name; /* the font file name */ struct fontinfo *f; /* the font info defined for it */ }; register struct finder *f, *f1, *f2; static struct finder finder[NFONTS]; if (text_init == 0) initialize(); font = GenPXLFileName(name, at_size, design_size, IntGlobalMag, TeXfonts); #ifdef DEBUG fprintf(stderr,"\nLooking for font \"%s\", numfonts=%d\n", font,numfonts); #endif /* If there are fonts defined, look around for the given font */ if (numfonts) { register int h, l, m, x; h = numfonts - 1; l = 0; #ifdef DEBUG for (x = 0; x < numfonts; x++) { fprintf(stderr,"%d: id=%d, \"%s\"\n",x, (finder[x].f)->family, finder[x].name); } #endif while (l <= h) { f = &finder[m = (l + h) >> 1]; if ((x = strcmp(f->name, font)) > 0) h = m - 1; else if (x < 0) l = m + 1; else { CurrentFont = f->f; #ifdef DEBUG fprintf(stderr,"Found it, id=%d\n", CurrentFont->family); #endif return(CurrentFont->family); } } if (l == numfonts) f = &finder[numfonts]; } else f = finder; /* f is now where the font should have been found, if anywhere */ f1 = &finder[numfonts]; if (numfonts > NFONTS) error (1, 0, "too many fonts used (%d)", numfonts); while (f1 > f) { *f1 = *(f2 = f1 - 1); f1 = f2; } f->name = malloc(strlen(font) + 1); strcpy(f->name, font); CurrentFont = f->f = &FontInfo[numfonts]; if ((CurrentFont->px = ReadPXLFile(font, 1)) == 0) error(1, errno, "can't find font \"%s\"",font); ScaleTFMWidths(CurrentFont->px, at_size); ComputeCWidths(CurrentFont); CurrentFont->family = NextFamilyNumber--; numfonts++; #ifdef DEBUG fprintf(stderr,"Font file now loaded, id=%d\n",CurrentFont->family); #endif #ifdef DEBUG2 printwidths(CurrentFont,stderr); #endif return(CurrentFont->family); } /* Compute the DEV widths of the characters in the given font */ static ComputeCWidths (fi) struct fontinfo *fi; { register int i; register struct chinfo *ch; register int *cw; ch = fi -> px -> px_info; cw = fi -> cwidth; i = 128; while (--i >= 0) { *cw++ = SPtoDEV (ch -> ch_TFMwidth); ch++; } } static DoChar(c, advance) char c; int advance; { register struct chinfo *ch; register struct fontinfo *cf; cf = CurrentFont; ch = &cf -> px -> px_info[c]; if (ch -> ch_width != 0) { if (!cf -> cload[c]) DownLoadGlyph (c, ch, cf); ImSetPosition(hh, vv); if (ImFamily != cf->family) { ImFamily = cf->family; imP_set_family(ImFamily); } imP_member(c); ImHH += cf -> cwidth[c]; /* where the Imagen thinks we are */ } if (advance) { hh += cf -> cwidth[c]; /* where we want to be */ } } #define RoundUp(n,r) (((n) + ((r) - 1)) & ~((r) - 1)) /* Download the character c/ch/cf (also, do rotation if needed) */ static DownLoadGlyph (c, ch, cf) int c; /* ordinal value */ register struct chinfo *ch; /* chinfo for c */ register struct fontinfo *cf; /* advance amount */ { register char *p; register int i, j, o, w; FILE *fp; /* if (!LFlag) w = 0; else { PerformRotation (ch, -90); w = 1; } */ w = 0; fp = impout(fontfp); /* switch to font file */ /* Define the character */ imP_bgly(w, cf->family, c, cf->cwidth[c], ch->ch_width, ch->ch_xoffset, ch->ch_height, ch->ch_yoffset, NULL); /* Now put out the bitmap. We have to drop any extra ``all blank'' bytes that are implied by the definition of the PXL fonts, since the Imagen doesn't need (nor want) them. */ w = (RoundUp (ch -> ch_width, 8) >> 3); o = (RoundUp (ch -> ch_width, 32) >> 3) - w; p = ch -> ch_raster; for (i = ch -> ch_height; --i >= 0;) { for (j = w; --j >= 0;) imP_member(*p++); p += o; } cf -> cload[c] = 1; /* it's now loaded */ impout(fp); } /* Set the Imagen's h & v positions. (It's currently at ImHH, ImVV.) */ static ImSetPosition (h, v) register int h, v; { if (ImHH != h) { if (ImHH == h - 1) imP_mplus(); else if (ImHH == h + 1) imP_mminus(); else imP_set_abs_h(h); ImHH = h; } if (ImVV != v) { imP_set_abs_v(v); ImVV = v; } } #ifdef DEBUG2 /* Print out the DEV widths of the characters in the given font */ static printwidths (fi, fp) struct fontinfo *fi; FILE *fp; { register int i, j, k; register struct chinfo *ch; register int *cw; ch = fi -> px -> px_info; cw = fi -> cwidth; i = 0; k = 32; while (--k >= 0) { j = 4; while (--j >= 0) { fprintf(fp,"%d: %d %d ",i++,ch->ch_TFMwidth,*cw); cw++; ch++; } fprintf(fp,"\n"); } } #endif SHAR_EOF fi # end of overwriting check if test -f 'types.h' then echo shar: will not over-write existing file "'types.h'" else cat << \SHAR_EOF > 'types.h' /* a 32 (or more) bit integer (signed) */ typedef int i32; /* macros to sign extend quantities that are less than 32 bits long */ /* Sun mishandles (int)(char)(constant) */ #ifndef sun #define Sign8(n) ((int)(char)(n)) #else #define Sign8(n) (((n) << 24) >> 24) #endif #define Sign16(n) ((int)(short)(n)) /* #define Sign24(n) ((n) & (1<<23) ? ((n)|0xff000000) : (n)) */ #define Sign24(n) (((n) << 8) >> 8) /* macros to truncate quantites that are signed but shouldn't be */ #define UnSign8(n) ((n) & 0xff) #define UnSign16(n) ((n) & 0xffff) #define UnSign24(n) ((n) & 0xffffff) /* note that we never have unsigned 32 bit integers */ SHAR_EOF fi # end of overwriting check # End of shell archive exit 0 ---
macintosh@felix.UUCP (02/27/87)
This is part 3 of 3 of "drawimp", a program that runs on Unix to convert MacDraw files into Impress commands for printing on Imagen laser printers. Allan Weber USC Signal and Image Processing Institute (213) 743-5519 Arpa: Weber%Brand@USC-Oberon.ARPA UUCP: ...sdcrdcf!usc-oberon!brand!weber --- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # README.SPCL # special.c # PicMacros.tex # This archive created: Mon Feb 2 11:06:56 1987 export PATH; PATH=/bin:$PATH if test -f 'README.SPCL' then echo shar: will not over-write existing file "'README.SPCL'" else cat << \SHAR_EOF > 'README.SPCL' Instruction for using putting MacDraw files in LaTeX documents The following files are needed to use the TeX/LaTeX option of drawimp. special.c - Handles the \special command for including files with Impress commands in the output stream. PicMacros.tex - TeX and LaTeX macros You must be using the "imagen1" dvi-to-impress driver in order to make this stuff work. This was the driver that came with the TeX distribution tape we purchased. There may be others that could be made to work also. Imagen1 handles \special's with a routine that reads the data and ignores it. Special.c has a new routine for handling the \special command and needs to be linked in with the rest of imagen1.c First, go into your copy of imagen1.c and find the routine "DoSpecial". Delete or comment out the DoSpecial in imagen1.c so the one in special.c will be used instead. Compile imagen1.c and special.c, link them together with whatever else is needed, and move imagen1 to where it will be found by the shell scripts that drive the Imagen printer. The following assumes something like MacTerminal and macget have been used to upload the MacDraw files to Unix. Normally this leaves three files on Unix for each Mac file, with extensions .data, .info, and .rsrc. The .info and .rsrc files can be deleted. Move all the .data files to one place and do % drawimp -t *.data This will cause drawimp to process each MacDraw .data file into a separate file containing Impress commands with the same name except ending in .imp. If there are text objects in any of the pictures, it is important that all the MacDraw files be processed together in this way. If a new picture is added later, they should all be processed again or the fonts used in the pictures will get mixed up. In the LaTeX file, pictures are include with lines like \DrawPicture{500}{200}{filename} The first and second arguments are the width and height respectively of the box area to reserve for the picture. They are specified in the current units as set by \setlength{\unitlength}{0.01in} or something similar. The picture can be larger or smaller than this, but LaTeX will reserve space according to these parameters. The top-left corner of the active area of the picture will be placed on the page at the top-left corner of the reserved area. The picture does not have to be pushed to the top-left of the MacDraw document page in order for drawimp to find it. The DrawPicture macro will center the reserved picture area horizontally on the page. The third parameter is the file name of the picture file as processed by "drawimp -t". See the macro definition for more info. Send any comments or bug reports to "Weber%Brand@USC-ECL.ARPA" Allan Weber USC Signal and Image Processing Inst. PHE 306, MC-0272 L.A., CA 90089-0272 (213) 743-5519 SHAR_EOF fi # end of overwriting check if test -f 'special.c' then echo shar: will not over-write existing file "'special.c'" else cat << \SHAR_EOF > 'special.c' /* Routines for handling \special commands. Currently only supports inserting impress data from external files. Bitmap stuff is not complete. Allan Weber (Weber%Brand@USC-ECL.ARPA) - 9/12/86 */ /* #define DEBUG */ #include <stdio.h> #include <ctype.h> extern char *malloc(); extern int errno; extern int ImHH, ImVV, hh, vv; int S_bitmap(); int S_impress(); char *nb(); struct spec { char *name; int (*func)(); } spectbl[] = { "bitmap", S_bitmap, "impress", S_impress, "", NULL }; /* Perform a \special */ DoSpecial (len) int len; /* length of the \special string */ { struct spec *s; char *p; register char ch, *p1, *p2; if (ImHH != hh || ImVV != vv) /* flush out any pending moves */ ImSetPosition (hh, vv); p1 = p = malloc(len + 1); while (len--) /* read the special string */ *p1++ = getc(stdin); *p1 = '\0'; #ifdef DEBUG fprintf(stderr,"special: '%s'\n",p); #endif p1 = nb(p); /* skip leading blanks */ if (*p1 == '\0') /* if nothing left, return */ return; p2 = p1; while ((ch = *p2) != '\0' && !isspace(ch)) /* find end of 1st word */ p2++; if (ch != '\0') { /* more than one word? */ *p2++ = '\0'; /* mark end of first word */ p2 = nb(p2); /* point to start of rest of string */ } s = spectbl; while (s->func != NULL) { if (strcmp(p1,s->name) == 0) { (s->func)(p1,p2); return; } else s++; } free(p); } /* split - separate the words in string s, placing a '\0' after each one and setting the elements of tok to point to the beginning of each word. Only do this for up to max words. Return the number of words found. */ static split(s,tok,max) register char *s; char *tok[]; { int i, n; register char ch; n = 0; for (i = 0; i < max; i++) { s = nb(s); /* find word start */ if ((ch = *s) != '\0') { /* did we find one? */ tok[i] = s; n++; while ((ch = *s) != '\0' && !isspace(ch)) s++; /* find end of word */ if (ch != '\0') /* mark end of word */ *s++ = '\0'; } else tok[i] = NULL; } return(n); } char *nb(s) char *s; { register char ch; while ((ch = *s) != '\0' && isspace(ch)) s++; return(s); } /* --------------------------------------------------------------------- */ static S_bitmap(s1, s2) char *s1, *s2; { int i, n, fd; int rows, cols, wrows, wcols, wroff, wcoff; char *p, *word[7]; #ifdef DEBUG fprintf(stderr,"in bitmap: s1='%s', s2='%s'\n",s1,s2); #endif p = malloc(strlen(s2) + 1); strcpy(p,s2); n = split(p,word,7); #ifdef DEBUG fprintf(stderr, "split into %d words\n",n); for (i = 0; i < n; i++) fprintf(stderr,"%d: '%s'\n",i,word[i]); #endif #ifndef DEBUG if ((fd = open(word[0], 0)) == -1) { error (1, errno, "can't open %s", s2); } if (n < 7) /* no window offset */ word[6] = word[5] = "0"; if (n < 5) { /* full window */ word[3] = word[1]; word[4] = word[2]; } if (n < 3) { /* need at least the dimensions */ error(1, 0, "\"\\special bitmap\" not enough arguments"); free(p); return; } rows = atoi(word[1]); cols = atoi(word[2]); wrows = atoi(word[3]); wcols = atoi(word[4]); wroff = atoi(word[5]); wcoff = atoi(word[6]); close(fd); #endif free(p); } static S_impress(s1, s2) char *s1, *s2; { FILE *fp; int n, h, v, ch; char *p, *word[3]; #ifdef DEBUG fprintf(stderr,"in impress: s1='%s', s2='%s'\n",s1,s2); #endif #ifndef DEBUG p = malloc(strlen(s2) + 1); strcpy(p,s2); n = split(p,word,3); if ((fp = fopen(word[0], "r")) == NULL) { error (1, errno, "can't open %s", word[0]); } putchar(211); /* push */ if (n == 3) { /* absolute move specified */ if (sscanf(word[1],"%d", &h) == 1) { putchar(135); putchar((h >> 8) & 255); putchar(h & 255); } if (sscanf(word[2],"%d", &v) == 1) { putchar(137); putchar((v >> 8) & 255); putchar(v & 255); } } while ((ch = getc(fp)) != EOF || !feof(fp)) putchar(ch); putchar(212); /* pop */ fclose(fp); #endif } SHAR_EOF fi # end of overwriting check if test -f 'PicMacros.tex' then echo shar: will not over-write existing file "'PicMacros.tex'" else cat << \SHAR_EOF > 'PicMacros.tex' \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} \ifundefined{newcommand} % define DrawPicture for TeX \long\gdef\DrawPicture#1#2#3 {\centerline {\vbox to #1pt {\hbox to #2pt {\special{impress #3}} } } } \else % define DrawPicture for LaTeX % output some impress data at current location on page \newcommand{\Impress}[1] { \makebox(0,0){\special{impress #1}} } % put a picture on page (use for multiple pictures across page) \newcommand{\PutPicture}[3] { \begin{picture}(#1,#2) \put(0,#2){\Impress{#3}} \end{picture} } % put a centered picture on page (use for single picture across page) \newcommand{\DrawPicture}[3] { \begin{center} \PutPicture{#1}{#2}{#3} \end{center} } \fi SHAR_EOF fi # end of overwriting check # End of shell archive exit 0 ---