home *** CD-ROM | disk | FTP | other *** search
- /* Copyright 1985, 1986, 1987, 1988 Chris Lewis
- All Rights Reserved
-
- Permission to copy and further distribute is freely given provided
- this copyright notice remains intact and that this software is not
- sold for profit.
-
- Project: Generic Troff drivers
- Module: ps.c
- Author: Chris Lewis
- Specs: PostScript driver
- */
-
- #include "defs.h"
-
- #ifdef PS
- #include "ps.h"
-
- #ifndef SVR3
- #ifndef lint
- static char SCCSid[] = "@(#)ps.c: 1.24 Copyright 89/08/28 17:11:47 Chris Lewis";
- #endif
- #else
- #ident "@(#)ps.c: 1.24 Copyright 89/08/28 17:11:47 Chris Lewis" /*(SVR3)*/
- #endif
-
- #define METRICS
- static charCount;
-
- #ifdef FORM
- static char Overlay[100] = {""};
- #endif
-
- #ifdef BIN
- static char Bin = 'D';
- #endif
-
- #define MAXFONT 50
-
- #define USED 01
-
- struct psFts {
- char *troffName;
- char *fontName;
- int flags;
- } psFts[MAXFONT+1];
-
- struct psFts *t2psf[8];
-
- struct troff2befont psStdFont[108] = {
-
- /* +-------------------------------- Troff character number
- |
- | +--------------------------- U: standard fonts
- | | S: symbol font
- | | D: draw macro
- | | n: new font
- | |
- | | +------------------------ X-shift (scaled by point)
- | | | Note: positive is right.
- | | |
- | | | +--------------------- Y-shift (scaled by point)
- | | | | Note: positive is up.
- | | | |
- | | | | +------------------ Point scale factor
- | | | | |
- | | | | | +-------------- Sequence
- | | | | | |
- | | | | | | Printable sequence title
- | | | | | | |
- | | | | | | |
- v v v v v v v */
- /* 1*/ {U, 0, 0, 1, "h", "h"},
- /* 2*/ {U, 0, 0, 1, "t", "t"},
- /* 3*/ {U, 0, 0, 1, "n", "n"},
- /* 4*/ {U, 0, 0, 1, "m", "m"},
- /* 5*/ {U, 0, 0, 1, "l", "l"},
- /* 6*/ {U, 0, 0, 1, "i", "i"},
- /* 7*/ {U, 0, 0, 1, "z", "z"},
- /* 8*/ {U, 0, 0, 1, "s", "s"},
- /* 9*/ {U, 0, 0, 1, "d", "d"},
- /* 10*/ {U, 0, 0, 1, "b", "b"},
- /* 11*/ {U, 0, 0, 1, "x", "x"},
- /* 12*/ {U, 0, 0, 1, "f", "f"},
- /* 13*/ {U, 0, 0, 1, "j", "j"},
- /* 14*/ {U, 0, 0, 1, "u", "u"},
- /* 15*/ {U, 0, 0, 1, "k", "k"},
- /* 16*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- /* 17*/ {U, 0, 0, 1, "p", "p"},
- /* 18*/ {D, 0, 0, 1, "do34em", "3/4 em"},
- /* 19*/ {U, 0, 0, 1, ";", ";"},
- /* 20*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- /* 21*/ {U, 0, 0, 1, "a", "a"},
- /* 22*/ {D, 0, 0, 1, "doru", "horizontal rule"},
- /* 23*/ {U, 0, 0, 1, "c", "c"},
- /* 24*/ {U, 0, 0, 1, "`", "` open"},
- /* 25*/ {U, 0, 0, 1, "e", "e"},
- /* 26*/ {U, 0, 0, 1, "'", "' close"},
- /* 27*/ {U, 0, 0, 1, "o", "o"},
- /* 28*/ {D, 0, 0, 1, "do14", "1/4"},
- /* 29*/ {U, 0, 0, 1, "r", "r"},
- /* 30*/ {D, 0, 0, 1, "do12", "1/2"},
- /* 31*/ {U, 0, 0, 1, "v", "v"},
- /* 32*/ {U, 0, 0, 1, "-", "- hyphen"},
- /* 33*/ {U, 0, 0, 1, "w", "w"},
- /* 34*/ {U, 0, 0, 1, "q", "q"},
- /* 35*/ {U, 0, 0, 1, "/", "/"},
- /* 36*/ {U, 0, 0, 1, ".", "."},
- /* 37*/ {U, 0, 0, 1, "g", "g"},
- /* 38*/ {D, 0, 0, 1, "do34", "3/4"},
- /* 39*/ {U, 0, 0, 1, ",", ","},
- /* 40*/ {U, 0, 0, 1, "&", "&"},
- /* 41*/ {U, 0, 0, 1, "y", "y"},
- /* 42*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- /* 43*/ {U, 0, 0, 1, "\%", "%"},
- /* 44*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- /* 45*/ {U, 0, 0, 1, "Q", "Q"},
- /* 46*/ {U, 0, 0, 1, "T", "T"},
- /* 47*/ {U, 0, 0, 1, "O", "O"},
- /* 48*/ {U, 0, 0, 1, "H", "H"},
- /* 49*/ {U, 0, 0, 1, "N", "N"},
- /* 50*/ {U, 0, 0, 1, "M", "M"},
- /* 51*/ {U, 0, 0, 1, "L", "L"},
- /* 52*/ {U, 0, 0, 1, "R", "R"},
- /* 53*/ {U, 0, 0, 1, "G", "G"},
- /* 54*/ {U, 0, 0, 1, "I", "I"},
- /* 55*/ {U, 0, 0, 1, "P", "P"},
- /* 56*/ {U, 0, 0, 1, "C", "C"},
- /* 57*/ {U, 0, 0, 1, "V", "V"},
- /* 58*/ {U, 0, 0, 1, "E", "E"},
- /* 59*/ {U, 0, 0, 1, "Z", "Z"},
- /* 60*/ {U, 0, 0, 1, "D", "D"},
- /* 61*/ {U, 0, 0, 1, "B", "B"},
- /* 62*/ {U, 0, 0, 1, "S", "S"},
- /* 63*/ {U, 0, 0, 1, "Y", "Y"},
- /*from here on are actually code 1-45, upper half of font */
- /* 64*/ {U, 0, 0, 1, "F", "F"},
- /* 65*/ {U, 0, 0, 1, "X", "X"},
- /* 66*/ {U, 0, 0, 1, "A", "A"},
- /* 67*/ {U, 0, 0, 1, "W", "W"},
- /* 68*/ {U, 0, 0, 1, "J", "J"},
- /* 69*/ {U, 0, 0, 1, "U", "U"},
- /* 70*/ {U, 0, 0, 1, "K", "K"},
- /* 71*/ {U, 0, 0, 1, "0", "0"},
- /* 72*/ {U, 0, 0, 1, "1", "1"},
- /* 73*/ {U, 0, 0, 1, "2", "2"},
- /* 74*/ {U, 0, 0, 1, "3", "3"},
- /* 75*/ {U, 0, 0, 1, "4", "4"},
- /* 76*/ {U, 0, 0, 1, "5", "5"},
- /* 77*/ {U, 0, 0, 1, "6", "6"},
- /* 78*/ {U, 0, 0, 1, "7", "7"},
- /* 79*/ {U, 0, 0, 1, "8", "8"},
- /* 80*/ {U, 0, 0, 1, "9", "9"},
- /* 81*/ {U, 0, 0, 1, "*", "*"},
- /* 82*/ {S, 0, 0, 1, "\\055", "minus"},
- /* 83*/ {U, 0, 0, 1, "\\256", "fi"},
- /* 84*/ {U, 0, 0, 1, "\\257", "fl"},
- /* 85*/ {D, 0, 0, 1, "doff", "ff"},
- /* 86*/ {S, 0, 0, 1, "\\242", "cent sign"},
- /* 87*/ {D, 0, 0, 1, "doFl", "ffl"},
- /* 88*/ {D, 0, 0, 1, "doFi", "ffi"},
- /* 89*/ {U, 0, 0, 1, "\\(", "("},
- /* 90*/ {U, 0, 0, 1, "\\)", ")"},
- /* 91*/ {U, 0, 0, 1, "[", "["},
- /* 92*/ {U, 0, 0, 1, "]", "]"},
- /* 93*/ {S, 0, 0, 1, "\\260", "degree"},
- /* 94*/ {U, 0, 0, 1, "\\262", "dagger"},
- /* 95*/ {U, 0, 0, 1, "=", "="},
- /* 96*/ {S, 0, 0, 1, "\\322", "registered"},
- /* 97*/ {U, 0, 0, 1, ":", ":"},
- /* 98*/ {U, 0, 0, 1, "+", "+"},
- /* 99*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- /*100*/ {U, 0, 0, 1, "!", "!"},
- /*101*/ {U, 0, -.1, 1.5, "\\267", "bullet"},
- /*102*/ {U, 0, 0, 1, "?", "?"},
- /*103*/ {S, 0, 0, 1, "\\242", "foot mark (minute)"},
- /*104*/ {U, -.1, 0, 1, "|", "|"},
- /*105*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- /*106*/ {S, 0, 0, 1, "\\323", "copyright"},
- /*107*/ {D, 0, 0, 1, "dosq", "square"},
- /*108*/ {U, 0, 0, 1, "$", "$"}
- };
-
- struct troff2befont psSymFont[] = {
- /* +-------------------------------- Troff character number
- |
- | +--------------------------- U: standard fonts
- | | S: symbol font
- | | D: draw macro
- | | n: new font
- | |
- | | +------------------------ X-shift (scaled by point)
- | | | Note: positive is right.
- | | |
- | | | +--------------------- Y-shift (scaled by point)
- | | | | Note: positive is up.
- | | | |
- | | | | +------------------ Point scale factor
- | | | | |
- | | | | | +-------------- Sequence
- | | | | | |
- | | | | | | Printable sequence title
- | | | | | | |
- | | | | | | |
- v v v v v v v */
- /* 1*/ {S, 0, 0, 1, "\\171", "psi"},
- /* 2*/ {S, 0, 0, 1, "\\161", "theta"},
- /* 3*/ {S, 0, 0, 1, "\\156", "nu"},
- /* 4*/ {S, 0, 0, 1, "\\155", "mu"},
- /* 5*/ {S, 0, 0, 1, "\\154", "lambda"},
- /* 6*/ {S, 0, 0, 1, "\\151", "iota"},
- /* 7*/ {S, 0, 0, 1, "\\172", "zeta"},
- /* 8*/ {S, 0, 0, 1, "\\163", "sigma"},
- /* 9*/ {S, 0, 0, 1, "\\144", "delta"},
- /* 10*/ {S, 0, 0, 1, "\\142", "beta"},
- /* 11*/ {S, 0, 0, 1, "\\170", "xi"},
- /* 12*/ {S, 0, 0, 1, "\\150", "eta"},
- /* 13*/ {S, 0, 0, 1, "\\146", "phi"},
- /* 14*/ {S, 0, 0, 1, "\\165", "upsilon"},
- /* 15*/ {S, 0, 0, 1, "\\153", "kappa"},
- /* 16*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- /* 17*/ {S, 0, 0, 1, "\\160", "pi"},
- /* 18*/ {U, 0, 0, 1, "@", "@"},
- /* 19*/ {S, 0, 0, 1, "\\257", "down arrow"},
- /* 20*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- /* 21*/ {S, 0, 0, 1, "\\141", "alpha"},
- /* 22*/ {S, 0, 0, 1, "\\174", "or (was star)"},
- /* 23*/ {S, 0, 0, 1, "\\143", "chi"},
- /* 24*/ {U, 0, 0, 1, "\\042", "double quote"},
- /* 25*/ {S, 0, 0, 1, "\\145", "epsilon"},
- /* 26*/ {S, 0, 0, 1, "\\075", "equation equal"},
- /* 27*/ {S, 0, 0, 1, "\\157", "omicron"},
- /* 28*/ {S, 0, 0, 1, "\\254", "left arrow"},
- /* 29*/ {S, 0, 0, 1, "\\162", "rho"},
- /* 30*/ {S, 0, 0, 1, "\\255", "up arrow"},
- /* 31*/ {S, 0, 0, 1, "\\164", "tau"},
- /* 32*/ {4, 0, 0, 1, "O", "underline"},
- /* 33*/ {U, 0, 0, 1, "\\134", "\\\\"},
- /* 34*/ {S, 0, 0, 1, "\\131", "Psi"},
- /* 35*/ {D, 0, 0, 1, "BellSymbol", "bell system sign"},
- /* 36*/ {S, 0, 0, 1, "\\245", "infinity"},
- /* 37*/ {S, 0, 0, 1, "\\147", "gamma"},
- /* 38*/ {S, 0, 0, 1, "\\312", "improper superset"},
- /* 39*/ {S, 0, 0, 1, "\\265", "proportional to"},
- /* 40*/ {S, 0, 0, 1, "\\336", "right hand"},
- /* 41*/ {S, 0, 0, 1, "\\167", "omega"},
- /* 42*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- /* 43*/ {S, 0, 0, 1, "\\321", "gradient"},
- /* 44*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- /* 45*/ {S, 0, 0, 1, "\\106", "Phi"},
- /* 46*/ {S, 0, 0, 1, "\\121", "Theta"},
- /* 47*/ {S, 0, 0, 1, "\\127", "Omega"},
- /* 48*/ {S, 0, 0, 1, "\\310", "union"},
- /* 49*/ {4, 0, 0, 1, "M", "root en"},
- /* 50*/ {S, 0, 0, 1, "\\123", "terminal sigma (was root em)"},
- /* 51*/ {S, 0, 0, 1, "\\114", "Lambda"},
- /* 52*/ {S, 0, 0, 1, "\\055", "equation minus"},
- /* 53*/ {S, 0, 0, 1, "\\107", "Gamma"},
- /* 54*/ {S, 0, 0, 1, "\\362", "integral sign"},
- /* 55*/ {S, 0, 0, 1, "\\120", "Pi"},
- /* 56*/ {S, 0, 0, 1, "\\314", "subset of"},
- /* 57*/ {S, 0, 0, 1, "\\311", "superset of"},
- /* 58*/ {U, 0, 0, 1, "\\176", "approximates"},
- /* 59*/ {S, 0, 0, 1, "\\266", "partial derivative"},
- /* 60*/ {S, 0, 0, 1, "\\104", "Delta"},
- /* 61*/ {S, .35, 0, 1, "\\326", "square root"},
- /* 62*/ {S, 0, 0, 1, "\\123", "Sigma"},
- /* 63*/ {S, 0, 0, 1, "\\273", "approx ="},
- /* 64*/ {S, 0, 0, 1, "\\076", ">"},
- /* 65*/ {S, 0, 0, 1, "\\130", "Xi"},
- /* 66*/ {S, 0, 0, 1, "\\074", "<"},
- /* 67*/ {S, 0, 0, 1, "\\244", "long slash (longer)"},
- /* 68*/ {S, 0, 0, 1, "\\307", "intersect"},
- /* 69*/ {S, 0, 0, 1, "\\125", "Upsilon"},
- /* 70*/ {S, 0, 0, 1, "\\330", "logical not"},
- /* 71*/ {4, 0, 0, 1, "J", "right ceiling"},
- /* 72*/ {4, 0, 0, 1, "B", "left top brace"},
- /* 73*/ {4, 0, 0, 1, "A", "bold vertical"},
- /* 74*/ {4, 0, 0, 1, "C", "left ctr brace"},
- /* 75*/ {4, 0, 0, 1, "D", "left bot brace"},
- /* 76*/ {4, 0, 0, 1, "E", "right top brace"},
- /* 77*/ {4, 0, 0, 1, "F", "right ctr brace"},
- /* 78*/ {4, 0, 0, 1, "G", "right bot brace"},
- /* 79*/ {4, 0, 0, 1, "K", "right floor"},
- /* 80*/ {4, 0, 0, 1, "I", "left floor"},
- /* 81*/ {4, 0, 0, 1, "H", "left ceiling"},
- /* 82*/ {S, 0, 0, 1, "\\264", "multiply"},
- /* 83*/ {S, 0, 0, 1, "\\270", "divide"},
- /* 84*/ {S, 0, 0, 1, "\\261", "plus-minus"},
- /* 85*/ {S, 0, 0, 1, "\\243", "<="},
- /* 86*/ {S, 0, 0, 1, "\\263", ">="},
- /* 87*/ {S, 0, 0, 1, "\\272", "identically equal"},
- /* 88*/ {S, 0, 0, 1, "\\271", "not equal"},
- /* 89*/ {S, 0, 0, 1, "\\173", "{"},
- /* 90*/ {S, 0, 0, 1, "\\175", "}"},
- /* 91*/ {U, 0, 0, 1, "\\302", "acute accent"},
- /* 92*/ {U, 0, 0, 1, "\\301", "grave accent"},
- /* 93*/ {U, 0, 0, 1, "\\303", "^"},
- /* 94*/ {U, 0, 0, 1, "\\043", "#"},
- /* 95*/ {S, 0, 0, 1, "\\334", "left hand"},
- /* 96*/ {S, 0, 0, 1, "\\316", "member of"},
- /* 97*/ {U, 0, 0, 1, "\\304", "~"},
- /* 98*/ {S, 0, 0, 1, "\\306", "empty set"},
- /* 99*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- /*100*/ {U, 0, 0, 1, "\\263", "dbl dagger"},
- /*101*/ {4, 0, 0, 1, "L", "box rule (was parallel sign)"},
- /*102*/ {S, 0, 0, 1, "\\052", "math * "},
- /*103*/ {S, 0, 0, 1, "\\315", "improper subset"},
- /*104*/ {4, 0, 0, 1, "N", "circle"},
- /*105*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- /*106*/ {S, 0, 0, 1, "\\053", "equation plus"},
- /*107*/ {S, 0, 0, 1, "\\256", "right arrow"},
- /*108*/ {U, 0, 0, 1, "\\247", "section"}
- };
-
- psPage() {
- EMITPS("ShowPage\n");
- EMITPS("PageSave restore\n");
- pagePending = 1;
- }
-
- static
- doPageStart(e) {
- currentPage++;
- EMITPS("%%%%Page: ? %d\n", currentPage);
- #ifdef BIN
- switch(Bin) {
- case 'M':
- EMITPS("/manualfeed true def\n");
- break;
- default:
- fprintf(stderr,
- "%s: bad bin selection %c - set to default\n", progname,
- Bin);
- Bin = 'D';
- case 'D':
- EMITPS("/manualfeed false def\n");
- break;
- }
- #endif
- #ifdef FORM
- EMITPS("/Form { %s } def\n", Overlay);
- #endif
- EMITPS("/PageSave save def\n");
- pagePending = 0;
- EMITPS("StartPage\n");
- }
-
- static int lastFont = (-1), lastPoints = (-1);
-
- psSetFont(font, points)
- int font, points; {
- if (lastPoints != points || font != lastFont) {
- psFts[font].flags |= USED;
- #ifdef FONTMACRO
- EMITPS("/%s %d SetFont\n", psFts[font].fontName, points);
- #else
- EMITPS("/%s dup /curFont exch def findfont\n",
- psFts[font].fontName);
- EMITPS("%d dup /curPoints exch def scalefont setfont\n", points);
- #endif
- lastPoints = points;
- lastFont = font;
- }
- }
-
- psChar(x, y, font, points, troffChar)
- int x, y, font, points, troffChar; {
- static double lasty = (-1);
- register double nx = TROFF2PSX(x), ny = TROFF2PSY(y);
- register struct troff2befont *rp;
- register char *sequence = "a";
- if (pagePending) {
- lasty = lastFont = lastPoints = (-1);
- doPageStart();
- }
-
- charCount++;
-
- DEBUGPRINTF("x,y=%d,%d; font=%d, points=%d, tc=%d\n",
- x, y, font, points, troffChar);
-
- if (font == 3) {
- rp = &be->besymfont[troffChar];
- } else {
- rp = &be->bestdfont[troffChar];
- }
-
- switch(rp->t2b_font) {
- /* Only fonts with "U" are subject to font translation */
- case U:
- if (font == 3)
- font = 0; /* Special chars are Courier */
- else {
- DEBUGPRINTF("psSetChar %d->%s (%s)\n", font,
- t2psf[font]->troffName,
- t2psf[font]->fontName);
- font = t2psf[font] - psFts;
- }
- break;
- case S:
- font = 3;
- break;
- case D:
- break;
- default:
- /* Typically used when the main fonts don't have the
- character desired. Eg: right-hand is in the
- ZapfDingbats font */
- font = rp->t2b_font;
- break;
- }
-
- sequence = rp->t2b_charseq;
-
- if (!sequence) {
- fprintf(stderr, "No coding for %d\n", troffChar);
- return;
- }
-
- /* We're committed now */
-
- points *= rp->t2b_scale;
- nx += points * rp->t2b_xc;
- ny += points * rp->t2b_yc;
- psSetFont(font, points);
- if (rp->t2b_font == D)
- EMITPS("%g %g %s\n", nx, ny, sequence);
- else {
- emitnum(nx);
- if (lasty != ny) {
- EMITPS(" ");
- emitnum(ny);
- EMITPS("(%s)Y\n", sequence);
- lasty = ny;
- } else
- EMITPS("(%s)X\n",sequence);
- }
- }
-
- emitnum(val)
- double val; {
- static char buffer[30];
- register char *p;
- sprintf(buffer, "%g", val);
- p = strchr(buffer, '.');
- if (p)
- *(p+2) = '\0';
- EMITPS(buffer);
- }
-
-
- static
- loadfontdefs(f)
- FILE *f; {
- struct psFts *p = psFts;
- extern char *malloc();
- char rbuf[512], nbuf[512], psbuf[512];
- while(fgets(rbuf, sizeof(rbuf), f)) {
- switch(sscanf(rbuf, "%s%s", nbuf, psbuf)) {
- default:
- break;
- case 2:
- if (nbuf[0] == '#')
- break;
- if (p - psFts >= MAXFONT) {
- fprintf(stderr, "Too many font definitions in %s\n",
- PSFONTS);
- exit(1);
- }
- p->troffName = malloc(strlen(nbuf) + 1);
- strcpy(p->troffName, nbuf);
- p->fontName = malloc(strlen(psbuf) + 1);
- strcpy(p->fontName, psbuf);
- p++;
- }
- }
- #ifdef DEBUG
- for (p = psFts; p->troffName; p++)
- DEBUGPRINTF("%s -> %s\n", p->troffName, p->fontName);
- #endif
- }
-
- extern char nodename[];
-
- psProlog() {
- extern char *getlogin(), *ctime();
- extern char *strchr();
- char buffer[512];
- char *lognm;
- FILE *library;
- int c;
- long curtime;
-
- currentPage = 0;
- pagePending = 1;
-
- for (c = 0; c < 8; c++)
- t2psf[c] = &psFts[c];
- if ((library = fopen(PSFONTS, "r")) == NULL) {
- sprintf(buffer, "%s/%s", LIBDIR, PSFONTS);
- if ((library = fopen(buffer, "r")) == NULL) {
- fprintf(stderr, "Cannot open PostScript font definitions %s\n",
- buffer);
- exit(1);
- }
- }
-
- loadfontdefs(library);
- fclose(library);
-
- if ((library = fopen(PSLIB, "r")) == NULL) {
- sprintf(buffer, "%s/%s", LIBDIR, PSLIB);
- if ((library = fopen(buffer, "r")) == NULL) {
- fprintf(stderr, "Cannot open %s\n", buffer);
- exit(1);
- }
- }
-
- time(&curtime);
- strcpy(buffer, ctime(&curtime));
- *strchr(buffer, '\n') = '\0';
- getnodename();
-
- lognm = getlogin();
- if (!lognm || !*lognm)
- lognm = "unknown";
-
- EMITPS("%%!PS-Adobe-1.0\n");
- EMITPS("%%%%Title: (stdin)\n");
- EMITPS("%%%%Creator: %s %s %s\n", lognm, progname, T2VERSION);
- EMITPS("%%%%CreationDate: %s\n", buffer);
- EMITPS("%%%%For: %s\n", lognm);
- EMITPS("%%%%Pages: (atend)\n");
- EMITPS("%%%%DocumentFonts: (atend)\n");
- EMITPS("%%%%EndComments\n");
- EMITPS("(%s@%s %s %s %s\n) print\n", lognm, nodename, buffer,
- progname, T2VERSION);
- psXlate(library);
- EMITPS("/GlobalSave save def\n");
- EMITPS("%%%%EndProlog\n");
- fclose(library);
- }
-
- psEpilog() {
- int i;
- #ifdef METRICS
- int curpos = 720; /* ten inches from bottom of page */
- #define XD 36
- #define CH 16
- if (metrics) {
- psBin("");
- psOverlay("");
- doPageStart();
- lastFont = -1; /* force the font change nomatter what */
- psSetFont(0, 16);
- EMITPS("%d %d(%s Execution Summary:)Y\n", progname, XD, curpos);
- curpos -= CH;
- EMITPS("%d %d(Font cache hits: )Y Hits show\n",
- XD + 18, curpos);
- curpos -= CH;
- EMITPS("%d %d(Font cache misses: )Y Misses show\n",
- XD + 18, curpos);
- curpos -= CH;
- EMITPS("%d %d(Character Count: %d)Y\n",
- charCount, XD + 18, curpos);
- psPage();
- }
- #endif
- EMITPS("%%%%Trailer\n");
- EMITPS("GlobalSave restore\n");
- EMITPS("%%%%DocumentFonts:");
- for (i = 0; i < MAXFONT; i++)
- if (psFts[i].flags&USED)
- EMITPS(" %s", psFts[i].fontName);
- EMITPS("\n");
- EMITPS("%%%%Pages: %d\n", currentPage);
- putchar('\004');
- }
-
- psFontSel(from, to)
- char from, *to; {
- #ifdef DEBUG
- register int i;
- register struct psFts *p;
- #endif
- DEBUGPRINTF("psFontSel: %c -> %s\n", from, to);
- if (from < '1' || from > '8') {
- fprintf(stderr, "Bad arguments to psFontSel: %c %s\n", from, to);
- return;
- }
-
- for (p = psFts; p->troffName; p++)
- if (strcmp(p->troffName, to) == 0) {
- t2psf[from - '1'] = p;
- break;
- }
- if (!p->troffName) {
- fprintf(stderr, "Could not translate font %c (%s)\n", from, to);
- }
- #ifdef DEBUG
- for (i = 0; i < 8; i++)
- DEBUGPRINTF("Font %d->%s\n", i+1, t2psf[i]->fontName);
- #endif
- }
-
- /*struct troff2befont *
- psGetFontTables(which)
- int which; {
- return(which? symbolFont: standardFont);
- }*/
-
- psXlate(library)
- FILE *library; {
- char buf[512];
- while (fgets(buf, sizeof(buf), library))
- if (0 == strncmp(buf, "%%%", 3))
- interp(&buf[3], psXlate, ".ps");
- else
- fputs(buf, stdout);
- }
-
- psOverlay(overlay)
- char *overlay; {
- #ifdef FORM
- strcpy(Overlay, overlay);
- EMITPS("%%%%%%Form set: %s\n", Overlay);
- #endif
- }
-
- psBin(bin)
- char *bin; {
- #ifdef BIN
- Bin = *bin;
- #endif
- }
-
- #endif /* PS */
-