diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /dviware/dvitops |
Initial commit
Diffstat (limited to 'dviware/dvitops')
48 files changed, 10418 insertions, 0 deletions
diff --git a/dviware/dvitops/aftopl.1 b/dviware/dvitops/aftopl.1 new file mode 100644 index 0000000000..6d4112f573 --- /dev/null +++ b/dviware/dvitops/aftopl.1 @@ -0,0 +1,77 @@ +.\" $Header: /usr/jjc/dvitops/RCS/aftopl.1,v 1.1 89/02/01 09:06:36 jjc Rel $ +.TH AFTOPL L "10 December 1988" +.SH NAME +aftopl \- convert an AFM file to a TeX PL file +.SH SYNOPSIS +.B aftopl +[ +.BI \-e encoding +] +.I afmfile +[ +.I plfile +] +.SH DESCRIPTION +.B aftopl +converts an AFM (Adobe Font Metric) file to a TeX PL (Property List) file. +An extension of +.B .afm +can be omitted from +.IR afmfile . +An extension of +.B .pl +can be omitted from +.IR plfile . +If +.I plfile +is omitted, it will be derived from +.I afmfile +by replacing the extension of +.I afmfile +by +.BR .pl . +The PL file can be converted to the TFM file needed by TeX by the pltotf +utility. +.SH OPTIONS +.TP +.BI \-e encoding +Produce a PL file suitable for the font when reencoded using +.IR encoding . +There should be a file called +.IB encoding .enc +in the same place that TFM files are kept. +This should give the PostScript name of each element of the encoding vector +(without a leading +.BR / ). +Names should be separated by white space. +Use the name +.B .notdef +for empty elements of the vector. +.SH FILES +.B /usr/local/tex/fonts/*.enc +.SH "SEE ALSO" +.BR tex (L), +.BR pltotf (L), +.BR dvitops (L), +.IR "PostScript Language Reference Manual" . +.SH BUGS +.LP +The same character must not occur more than once in the encoding vector. +.LP +There is no single `right' way to generate a PL file from an AFM file. +.B aftopl +tries to do something reasonable. +If you don't like the results, you should feel free to edit the PL file. +.LP +If a composite character is included in the encoding vector, then all +of its components must also be included; for example, if +.B aacute +occurs +then so must +.B a +and +.BR acute . +.B aftopl +does not check this. +.SH AUTHOR +James Clark <jjc@jclark.uucp> diff --git a/dviware/dvitops/aftopl.c b/dviware/dvitops/aftopl.c new file mode 100644 index 0000000000..a93f2963ea --- /dev/null +++ b/dviware/dvitops/aftopl.c @@ -0,0 +1,516 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/aftopl.c,v 1.4 89/10/02 10:39:25 jjc Exp $"; + +#include "util.h" + +#define MAXNAMES 500 +#define NOT_DEFINED 100000.0 +#ifndef PI +#define PI 3.14159265358979324 +#endif + +struct ligatures { + char *ch; + char *succ; + char *lig; +}; + +char *program_name = "aftopl"; + +static int lineno = 0; + +FILE *infp; +FILE *outfp; +#ifdef PROTO +int lookup(const char *); +char *getkeyvalue(char *, int); +void scan_char_metric(char *); +void compute_font_dimens(void); +void do_kern_pairs(int); +void do_char_metrics(int); +void do_afms(void); +void print_font_dimens(void); +void do_encoding(char *); +void print_char_metrics(void); +void print_lig_kerns(void); +void do_ligatures(struct ligatures *); +#endif + +#define bad_afm_file() message(FATAL_ERROR, "bad afm file, line %d", lineno) + +struct lig_kern_list { + struct lig_kern_list *next; + int succ; + int lig; /* -1 if its a kern */ + double x; +}; + + +struct { + struct lig_kern_list *p; + char *name; + int code; + double llx; + double lly; + double urx; + double ury; + double wx; +} table[MAXNAMES]; + +struct { + int is_fixed_pitch; + double italic_angle; + double x_height; + /* we use max(urx - wx + italic_correction_space, 0) + as the italic correction for each character */ + double italic_correction_space; + double normal_space; + double normal_stretch; + double normal_shrink; + double extra_space; + double quad; + double slant; +} font = { 0, 0.0, NOT_DEFINED, NOT_DEFINED, NOT_DEFINED, NOT_DEFINED, +NOT_DEFINED, NOT_DEFINED, NOT_DEFINED, NOT_DEFINED}; + + + +int lookup(s) +const char *s; +{ + int i; + for (i = 0; i < MAXNAMES; i++) + if (table[i].name == NULL) + break; + else if (strcmp(table[i].name, s) == 0) + return i; + if (i == MAXNAMES) + message(FATAL_ERROR, "too many names"); + if ((table[i].name = malloc(strlen(s) + 1)) == NULL) + message(FATAL_ERROR, "out of memory"); + strcpy(table[i].name, s); + table[i].code = -2; + table[i].llx = table[i].lly = 0.0; + table[i].urx = table[i].ury = 0.0; + table[i].wx = 0.0; + table[i].p = NULL; + return i; +} + + +char *getkeyvalue(s, c) +char *s; +char c; +{ + while (*s != '\0') { + while (isspace(*s)) + s++; + if (*s == c) + return s + 1; + while (*s != '\0') + if (*s++ == ';') + break; + } + return NULL; +} + +void scan_char_metric(s) +char *s; +{ + char name[128]; + int code, n; + double llx, lly, urx, ury; + double wx, wy; + char *p; + while (isspace(*s)) + s++; + if (*s == '\0') /* ignore blank line */ + return; + p = getkeyvalue(s, 'N'); + if (p == NULL) + bad_afm_file(); + /* sscanf(p, " %[A-Za-z0-9]", name); */ + /* Microsoft C scanf doesn't understand %[ */ + sscanf(p, "%s", name); + if ((p = strchr(name, ';')) != NULL) + *p = '\0'; + if ((p = getkeyvalue(s, 'C')) == NULL) + bad_afm_file(); + if (sscanf(p, "%d", &code) != 1) + bad_afm_file(); + p = getkeyvalue(s, 'B'); + if (p == NULL) + bad_afm_file(); + if (sscanf(p, "%lg %lg %lg %lg", &llx, &lly, &urx, &ury) != 4) + bad_afm_file(); + p = getkeyvalue(s, 'W'); + if (p == NULL) + bad_afm_file(); + if (*p == 'X') { + if (sscanf(p+1, "%lg", &wx) != 1) + bad_afm_file(); + wy = 0.0; + } + else if (sscanf(p, "%lg %lg", &wx, &wy) != 2) + bad_afm_file(); + n = lookup(name); + table[n].code = code; + table[n].wx = wx; + table[n].llx = llx; + table[n].lly = lly; + table[n].urx = urx; + table[n].ury = ury; + while ((p = getkeyvalue(s, 'L')) != NULL) { + char successor[128]; + char ligature[128]; + struct lig_kern_list *ptr; + if (sscanf(p, " %s %s", successor, ligature) != 2) + bad_afm_file(); + else if ((s = strchr(ligature, ';')) != NULL) + *s = '\0'; + if ((s = strchr(p, ';')) == NULL) + bad_afm_file(); + s++; + if ((ptr = (struct lig_kern_list *)malloc(sizeof(struct lig_kern_list))) == NULL) + message(FATAL_ERROR, "out of memory"); + ptr->succ = lookup(successor); + ptr->lig = lookup(ligature); + ptr->next = table[n].p; + table[n].p = ptr; + } +} + + +void compute_font_dimens() +{ + if (font.normal_space == NOT_DEFINED) { + int n = lookup("space"); + if (table[n].code == -2) + message(FATAL_ERROR, "no char metric for space character"); + else + font.normal_space = table[n].wx; + } + if (font.quad == NOT_DEFINED) + font.quad = (font.is_fixed_pitch?2.0:3.0)*font.normal_space; + if (font.italic_correction_space == NOT_DEFINED) + font.italic_correction_space = font.normal_space/12.0; + if (font.normal_shrink == NOT_DEFINED) + font.normal_shrink = font.is_fixed_pitch ? 0.0 : + font.normal_space/3.0; + if (font.normal_stretch == NOT_DEFINED) + font.normal_stretch = font.is_fixed_pitch ? 0.0 : + font.normal_space/2.0; + if (font.extra_space == NOT_DEFINED) + font.extra_space = (font.is_fixed_pitch ? 1.0 :0.5) + *font.normal_space; + if (font.slant == NOT_DEFINED) + if (font.italic_angle == 0.0) + font.slant = 0.0; + else + font.slant = sin(-font.italic_angle*PI/180.0); + if (font.x_height == NOT_DEFINED) + font.x_height = table[lookup("x")].ury; +} + +void do_kern_pairs(n) +int n; +{ + char buf[512]; + char name1[128]; + char name2[128]; + double x, y; + for (;;) { + int i; + struct lig_kern_list *ptr; + lineno++; + if (fgets(buf, 512, infp) == NULL) + bad_afm_file(); + if (buf[0] == '\n') + continue; + if (strcmp(buf, "EndKernPairs\n") == 0) + break; + if (sscanf(buf, "KPX %s %s %lg", name1, name2, &x) != 3) { + if (sscanf(buf, "KP %s %s %lg %lg", name1, name2, + &x, &y) != 4) + bad_afm_file(); + } + else + y = 0.0; + i = lookup(name1); + if ((ptr = (struct lig_kern_list *)malloc(sizeof(struct lig_kern_list))) == NULL) + message(FATAL_ERROR, "out of memory"); + ptr->succ = lookup(name2); + ptr->lig = -1; + ptr->x = x; + ptr->next = table[i].p; + table[i].p = ptr; + n--; + } + if (n != 0) + message(WARNING, "wrong number of kern pairs"); +} + + +void do_char_metrics(n) +int n; +{ + char buf[512]; + for (;;) { + char *ptr = buf; + lineno++; + if (fgets(buf, 512, infp) == NULL) + bad_afm_file(); + if (strcmp(buf, "EndCharMetrics\n") == 0) + break; + while (isspace(*ptr)) + ptr++; + if (*ptr == '\0') + continue; + scan_char_metric(buf); + n--; + } + if (n != 0) + message(WARNING, "wrong number of char metrics"); +} + +void do_afms() +{ + char buf[512]; + lineno = 0; + + while (fgets(buf, 512, infp) != NULL) { + char *key, *value; + key = buf; + lineno++; + while (isspace(*key)) + key++; + value = key; + while (*value != '\0' && !isspace(*value)) + value++; + if (*value != '\0') { + /* strip trailing white space */ + char *p; + *value++ = '\0'; + while (isspace(*value)) + value++; + p = value; + while (*p != '\0') + p++; + while (p > value && isspace(*(p-1))) + p--; + *p = '\0'; + } + if (strcmp(key, "IsFixedPitch") == 0) + font.is_fixed_pitch = (strcmp(value, "true") == 0); + else if (strcmp(key, "XHeight") == 0) + font.x_height = atof(value); + else if (strcmp(key, "StartCharMetrics") == 0) + do_char_metrics(atoi(value)); + else if (strcmp(key, "ItalicAngle") == 0) + font.italic_angle = atof(value); + else if (strcmp(key, "StartKernPairs") == 0) + do_kern_pairs(atoi(value)); + else if (strcmp(key, "italicCorrectionSpace") == 0) + font.italic_correction_space = atof(value); + } + +} + + +void print_font_dimens() +{ + fprintf(outfp, "(FONTDIMEN\n"); + fprintf(outfp, " (SLANT R %f)\n", font.slant); + fprintf(outfp, " (SPACE R %f)\n", font.normal_space/1000.0); + fprintf(outfp, " (SHRINK R %f)\n", font.normal_shrink/1000.0); + fprintf(outfp, " (STRETCH R %f)\n", font.normal_stretch/1000.0); + fprintf(outfp, " (EXTRASPACE R %f)\n", font.extra_space/1000.0); + fprintf(outfp, " (QUAD R %f)\n", font.quad/1000.0); + fprintf(outfp, " (XHEIGHT R %f)\n", font.x_height/1000.0); + fprintf(outfp, " )\n"); +} + + +void do_encoding(encoding) +char *encoding; +{ + int i; + char name[256]; + FILE *fp; + char *texfonts; + fprintf(outfp, "(CODINGSCHEME %s)\n", encoding); + texfonts = getenv("TEXFONTS"); + if (texfonts == NULL) + texfonts = TEXFONTS; + if ((fp = xfopen(encoding, FALSE, texfonts, ".enc")) == NULL) + message(FATAL_ERROR, "can't find %s", encoding); + for (i = 0; i < MAXNAMES; i++) + if (table[i].code >= -1) + table[i].code = -1; + for (i = 0; i < 256 && fscanf(fp, " %s ", name) == 1; i++) { + int n; + if (strcmp(".notdef", name) == 0) + continue; + n = lookup(name); + if (table[n].code == -2) + message(WARNING, "%s in encoding but not in font", name); + else if (table[n].code == -1) + table[n].code = i; + else + message(ERROR, "%s appears more than once in encoding", name); + } +} + + + +void print_char_metrics() +{ + int i; + for (i = 0; i < MAXNAMES; i++) + if (table[i].name != NULL && table[i].code > 0) { + double charic; + fprintf(outfp, "(CHARACTER O %03o\n", table[i].code); + fprintf(outfp, " (COMMENT %s)\n", table[i].name); + fprintf(outfp, " (CHARWD R %f)\n", + table[i].wx/1000.0); + /* negative heights and depths mess up \mathaccent */ + if (table[i].ury > 0.0) + fprintf(outfp, " (CHARHT R %f)\n", + table[i].ury/1000.0); + if (table[i].lly < 0.0) + fprintf(outfp, " (CHARDP R %f)\n", + -table[i].lly/1000.0); + charic = table[i].urx - table[i].wx + font.italic_correction_space; + if (charic > 0.0) + fprintf(outfp, " (CHARIC R %f)\n", + charic/1000.0); + fputs(" )\n", outfp); + } +} + + + +void print_lig_kerns() +{ + int i; + fputs("(LIGTABLE\n", outfp); + for (i = 0; i < MAXNAMES; i++) { + struct lig_kern_list *p; + char label_line[128]; + if (table[i].name == NULL || table[i].code < 0) + continue; + sprintf(label_line, " (LABEL O %03o)\n", table[i].code); + /* print the ligatures */ + for (p = table[i].p; p != NULL; p = p->next) + if (p->lig != -1 && table[p->lig].code > 0 + && table[p->succ].code > 0) { + fputs(label_line, outfp); + label_line[0]= '\0'; + fprintf(outfp," (LIG O %03o O %03o)\n", + table[p->succ].code, + table[p->lig].code); + } + for (p = table[i].p; p != NULL; p = p->next) + if (p->lig == -1 && table[p->succ].code > 0) { + fputs(label_line, outfp); + label_line[0] = '\0'; + fprintf(outfp, " (KRN O %03o R %f)\n", + table[p->succ].code, + p->x/1000.0); + } + if (label_line[0] == '\0') + fputs(" (STOP)\n", outfp); + } + fputs(" )\n", outfp); +} + + +struct ligatures standard_ligatures[] = { + "hyphen", "hyphen", "endash", + "endash", "hyphen", "emdash", + "quoteleft", "quoteleft", "quotedblleft", + "quoteright", "quoteright", "quotedblright", + "exclam", "quoteleft", "exclamdown", + "question", "quoteleft", "questiondown", + NULL, NULL, NULL + }; + +struct ligatures tt_ligatures[] = { + "exclam", "quoteleft", "exclamdown", + "question", "quoteleft", "questiondown", + NULL, NULL, NULL + }; + + +void do_ligatures(lig) +struct ligatures *lig; +{ + int i; + for (i = 0; lig[i].lig != NULL; i++) { + int n; + struct lig_kern_list *p; + n = lookup(lig[i].ch); + if ((p = (struct lig_kern_list *)malloc(sizeof(struct lig_kern_list))) == NULL) + message(FATAL_ERROR, "out_of_memory"); + p->succ = lookup(lig[i].succ); + p->lig = lookup(lig[i].lig); + p->next = table[n].p; + table[n].p = p; + } +} + + + +int main(argc, argv) +int argc; +char **argv; +{ + char filename[128]; + int c; + char *efile = NULL; + int nolig = FALSE; + while ((c = getopt(argc, argv, "ne:")) != EOF) + switch(c) { + case 'n': + nolig = TRUE; + break; + case 'e': + efile = optarg; + break; + case '?': + goto usage; + } + if (argc - optind < 1) + goto usage; + strcpy(filename, argv[optind]); + if (strchr(filename, '.') == NULL) + strcat(filename, ".afm"); + if ((infp = fopen(filename, "r")) == NULL) + message(FATAL_ERROR, "can't open %s", filename); + if (argc - optind == 1) + strcpy(strchr(filename, '.'), ".pl"); + else if (argc - optind == 2) { + strcpy(filename, argv[optind+1]); + if (strchr(filename, '.') == NULL) + strcat(filename, ".pl"); + } + else + goto usage; + if ((outfp = fopen(filename, "w")) == NULL) + message(FATAL_ERROR, "can't open %s", filename); + do_afms(); + if (efile != NULL) + do_encoding(efile); + if (!nolig) { + if (font.is_fixed_pitch) + do_ligatures(tt_ligatures); + else + do_ligatures(standard_ligatures); + } + compute_font_dimens(); + print_font_dimens(); + print_char_metrics(); + print_lig_kerns(); + exit(history); +usage: + message(FATAL_ERROR, "usage: aftopl [-e encoding] afmfile [plfile]"); +} diff --git a/dviware/dvitops/cms.h b/dviware/dvitops/cms.h new file mode 100644 index 0000000000..de0f0d0568 --- /dev/null +++ b/dviware/dvitops/cms.h @@ -0,0 +1,33 @@ +/* $Header: /usr/jjc/dvitops/RCS/cms.h,v 1.4 90/10/19 09:42:18 jjc Exp $ */ +/* Support for VM/CMS */ + +#define PAPER "a4" + +#ifndef FILENAME_MAX +#define FILENAME_MAX 20 +#endif +#define POSTFIX_AREA +#define AREA_LIST_SEP ':' +#define AREA_SEP '.' +#define TEXFONTS ".*" +#define TEXINPUTS ".*" +#define TEXPK "%f.%dpk.*" +#define TEXMAGS 214,248,257,270,300,329,360,432,518,622,746,896,1075,1290 +#define PSFONTS ".*" +#define DPI 300 +#define MAXFONTS 256 +#define FOPEN_RB(file) (fopen((file), "rb")) +#define FILENAME_HAS_AREA(f) FALSE +/* You may need to uncomment this. */ +/*#define BROKEN_PROTO */ +#define STDARG +#define EBCDIC +#define NEED_QSORT +/* #define HAVE_ISATTY */ +/* do not embed getc in a macro */ +#define NO_GETC_IN_MACRO +#define ERRNO_IN_STDEFS + +/* You may need to change this to <stdefs.h> */ +#include <stddef.h> +#include <limits.h> diff --git a/dviware/dvitops/code.c b/dviware/dvitops/code.c new file mode 100644 index 0000000000..dfa792f30c --- /dev/null +++ b/dviware/dvitops/code.c @@ -0,0 +1,451 @@ +#include "dvitops.h" + +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/code.c,v 1.5 90/08/14 13:07:42 jjc Rel $"; + +static struct { + char *name; + int width; + int height; +} paper_table[] = +{ +"letter", 612, 792, +"lettersmall", 612, 792, +"a4", 595, 842, +"A4", 595, 842, +"a4small", 595, 842, +"legal", 612, 1008, +"b5", 516, 729, +"b4", 729, 1032, +"tabloid", 792, 1224, +"ledger", 1224, 792, +"statement", 396, 612, +"executive", 540, 720, +"a3", 842, 1190, +"a5", 420, 595, +"folio", 612, 936, +"quarto", 610, 780, +"10x17", 720, 1224, +NULL }; + +#define MAXCOLS 70 + +static FILE *psfp; +static int cols = 0; /* the number of characters on the current line */ + +#define NS 200 +typedef struct string { + size_t i; /* index into pool */ + int n; /* number of characters */ + int region; + integer h; + integer v; + struct string *next; +} STRING; + +struct rule { + int region; + integer a,b,h,v; + struct rule *next; +} *rule_list = NULL; + +static unsigned char *pool = NULL; +static size_t pool_size = 0, pool_used = 0; + +STRING *string_list[MAXFONTS]; /* one list of strings for each font */ + +STRING *free_string_list; + +#ifdef PROTO +void ps_string(unsigned char *s, int n); +void print_string_list(STRING *s); +static void print_rule_list(void); +#else +void ps_string(); +void print_string_list(); +static void print_rule_list(); +#endif + +static int page_number = 0; +int landscape = FALSE; +int magnification = 0; + +void print_string_list(s) +STRING *s; +{ + int cc; + integer v; + integer ox = 0, oy = 0; /* current origin */ + int r = NO_REGION; /* the current region */ + if (s == NULL) + return; + v = s->v + 1; /* use the 'Z' command not the 'X' command */ + while (s != NULL) { + if (s->region != r) { + fprintf(psfp, "%% region %d\n", s->region); + if (r != NO_REGION) + fputs("grestore\n", psfp); + if (s->region != NO_REGION) { + fputs("gsave\n", psfp); + do_transform(s->region, &ox, &oy, psfp); + } + else + ox = oy = 0; + r = s->region; + v = s->v + 1; /* use the 'Z' command not the 'X' command */ + } + if (s->v == v) { + cols = put_dim((long)(s->h - ox), psfp); + cc = 'X'; + } + else { + cols = put_dim((long)(s->h - ox), psfp); + putc(' ', psfp); + cols++; + cols += put_dim((long)(s->v - oy), psfp); + cc = 'Z'; + } + v = s->v; + ps_string(pool + s->i, s->n); + putc(cc, psfp); + putc('\n', psfp); + s = s->next; + } + if (r != NO_REGION) + fputs("grestore\n", psfp); +} + +void set_string(p, n, f, h, v) +char *p; +int n, f; +integer h, v; +{ + STRING *s; + if (!free_string_list) { + int i; + free_string_list = (STRING *)malloc(sizeof(STRING)*NS); + if (free_string_list == NULL) + out_of_memory(); + for (i = 0; i < NS - 1; ++i) + free_string_list[i].next = free_string_list + i + 1; + free_string_list[NS - 1].next = NULL; + } + s = free_string_list; + free_string_list = free_string_list->next; + if (pool == NULL || pool_size - pool_used < n) { + if (pool == NULL) { + pool_size = 5000; + pool = (unsigned char *)malloc(pool_size); + pool_used = 0; + } + else { + if (pool_used > SIZE_MAX - n) + message(FATAL_ERROR, "too many characters on the page"); + pool_size = pool_used + n; + if (pool_size > SIZE_MAX/2) + pool_size = SIZE_MAX; + else + pool_size <<= 1; + pool = (unsigned char *)realloc((char *)pool, pool_size); + } + if (pool == NULL) + out_of_memory(); + } + s->i = pool_used; + memcpy((char *)(pool + pool_used), p, n); + pool_used += n; + s->h = h; + s->v = v; + s->n = n; + s->next = string_list[f]; + s->region = current_region; + string_list[f] = s; +} + +void set_rule(a, b, h, v) +integer a, b, h, v; +{ + struct rule *p; + if (a <= 0 || b <= 0) + return; + p = (struct rule *)malloc(sizeof(struct rule)); + if (p == NULL) + out_of_memory(); + p->a = a; + p->b = b; + p->h = h; + p->v = v; + p->region = current_region; + p->next = rule_list; + rule_list = p; +} + +static void print_rule_list() +{ + int r = NO_REGION; + integer ox = 0, oy = 0; + struct rule *p = rule_list; + while (p != NULL) { + struct rule *q = p; + if (p->region != r) { + fprintf(psfp, "%% region %d\n", p->region); + if (r != NO_REGION) + fputs("grestore\n", psfp); + if (p->region != NO_REGION) { + fputs("gsave\n", psfp); + do_transform(p->region, &ox, &oy, psfp); + } + else + ox = oy = 0; + r = p->region; + } + put_dim((long)(p->a), psfp); + putc(' ', psfp); + put_dim((long)(p->b), psfp); + putc(' ', psfp); + put_dim((long)(p->h - ox), psfp); + putc(' ', psfp); + put_dim((long)(p->v - oy), psfp); + fputs(" R\n", psfp); + p = p->next; + free((char *)q); + } + rule_list = NULL; + if (r != NO_REGION) + fputs("grestore\n", psfp); +} + +void eop(page) +struct page_info *page; +{ + char page_label[100]; + int i, j; + char *ptr; + int page_height, page_width; + for (i = 0; paper_table[i].name != NULL; i++) + if (strcmp(paper_table[i].name, page->paper) == 0) + break; + if (paper_table[i].name == NULL) { + page_height = paper_table[0].height; + page_width = paper_table[0].width; + message(ERROR, "unrecognised page type %s", optarg); + } + else { + page_height = paper_table[i].height; + page_width = paper_table[i].width; + } + ptr = page_label; + for (i = 9; page->count[i] == 0 && i > 0; --i) + ; + for (j = 0; j < i; ++j) { + sprintf(ptr, "%ld.", (long)(page->count[j])); + ptr += strlen(ptr); + } + sprintf(ptr, "%ld", (long)page->count[i]); + if (!quiet) + fprintf(stderr, "[%s", page_label); + ++page_number; + fprintf(psfp, "\n%%%%Page: %s %d\n", page_label, page_number); + fputs("dvitops begin\n", psfp); + fprintf(psfp, "/#copies %d def BP\n", page->copies); + p_form_list(psfp); + if (landscape) { + int n; + fprintf(psfp, "%d landscape\n", page_width); + n = page_height; + page_height = page_width; + page_width = n; + landscape = FALSE; + } + if (magnification > 0) { + page->mag = magnification; + magnification = 0; + } + fprintf(psfp, "%ld ", (long)(page->num)); + put_dim((long)(page->den), psfp); + fprintf(psfp, " %d %g %g %d SC\n", + page->mag, page->hoffset, page->voffset, page_height); + p_inline_list(psfp); + p_import_list(psfp, page); +#ifdef TPIC_SUPPORT + p_tpic_list(psfp, page); +#endif + print_rule_list(); + for (j = 0; j < MAXFONTS; ++j) { + int emitted = FALSE; + for (i = j; i != EOF; i = same_font(i)) { + STRING *p = NULL; + STRING *q = string_list[i]; + STRING *last = q; + if (string_list[i] == NULL) + continue; + /* reverse the string list */ + while (q != NULL) { + STRING *temp = q; + q = q->next; + temp->next = p; + p = temp; + } + if (!f_is_blank(i)) { + if (!emitted) { + fputs("BO\n", psfp); + f_emit(i, psfp); + emitted = TRUE; + } + f_set(i, psfp); + print_string_list(p); + } + last->next = free_string_list; + free_string_list = p; + string_list[i] = NULL; + } + if (emitted) + fputs("EO\n", psfp); + } + pool_used = 0; + fputs("\nEP end", psfp); + if (ferror(psfp)) + message(FATAL_ERROR, "write error: disk full?"); + if (!quiet) + fputs("] ", stderr); + pool_used = 0; + current_region = NO_REGION; + nregions = 0; +} + +void trailer() +{ + fputs("\n%%Trailer\n", psfp); + if (!quiet) + fputc('\n', stderr); +} + +void prologue(fp, npages, is_reverse, paper) +FILE *fp; +int npages, is_reverse; +char *paper; +{ + time_t t; + psfp = fp; + (void)time(&t); + fputs("%!PS-Adobe-2.0\n", psfp); + fputs("%%Creator: dvitops\n", psfp); + f_comment(psfp); + fprintf(psfp, "%%%%CreationDate: %s", ctime(&t)); + fprintf(psfp, "%%%%DocumentPaperSizes: %s\n", paper); + fprintf(psfp, "%%%%Pages: %d %d\n", npages, (is_reverse ? -1 : 1)); + fputs("%%EndComments\n", psfp); + p_special_prologues(psfp); + if (include_file("dvitops.pro", psfp) == EOF) + message(FATAL_ERROR, "can't open dvitops.pro"); + fputs("dvitops begin\n", psfp); + f_prologue(psfp); + fputs("end\n", psfp); + fputs("%%EndProlog\n", psfp); + fprintf(psfp, "%%%%BeginSetup\n"); + fprintf(psfp, "%%%%PaperSize: %s\n", paper); + fprintf(psfp, "%%%%EndSetup\n"); +} + + +/* we asssume all seven-bit printable ascii characters are representable in the + host character set */ + +#define ASCII_LEFT_PARENTHESIS 050 +#define ASCII_RIGHT_PARENTHESIS 051 +#define ASCII_BACKSLASH 0134 + +void ps_string(s, n) +unsigned char *s; +int n; +{ + cols++; + putc('(', psfp); + while (n--) { + unsigned char c = *s++; + if (c == ASCII_LEFT_PARENTHESIS + || c == ASCII_RIGHT_PARENTHESIS + || c == ASCII_BACKSLASH) { + if (cols + 2 > MAXCOLS) + cols = 0, fputs("\\\n", psfp); + fputc('\\', psfp); fputc(XCHAR(c), psfp); + cols += 2; + } + else if (c >= 040 && c < 0177) { + if (cols + 1 > MAXCOLS) + cols = 0, fputs("\\\n", psfp); + putc(XCHAR(c), psfp); + cols++; + } + else { + if (cols + 4 > MAXCOLS) + cols = 0, fputs("\\\n", psfp); + fprintf(psfp, "\\%03o", c); + cols += 4; + } + } + putc(')', psfp); +} + +static int fixed_point = 4; + +#define LONG_DIGITS 10 + +int put_dim(n, fp) +long n; +FILE *fp; +{ + int len; + /* room for a -, LONG_DIGITS digits, a decimal point, + and a terminating '\0' */ + char buf[LONG_DIGITS + 3]; + char *p = buf + LONG_DIGITS + 2; + int point = 0; + buf[LONG_DIGITS + 2] = '\0'; + if (n >= 0) { + do { + *--p = '0' + (n % 10); + n /= 10; + if (++point == fixed_point) + *--p = '.'; + } while (n != 0 || point < fixed_point); + } + else { /* n < 0 */ + do { + *--p = '0' - (n % 10); + n /= 10; + if (++point == fixed_point) + *--p = '.'; + } while (n != 0 || point < fixed_point); + *--p = '-'; + } + if (fixed_point > 0) { + char *q; + /* there must be a dot, so this will terminate */ + for (q = buf + LONG_DIGITS + 2; q[-1] == '0'; --q) + ; + if (q[-1] == '.') { + if (q - 1 == p) { + q[-1] = '0'; + q[0] = '\0'; + } + else + q[-1] = '\0'; + } + else + *q = '\0'; + } + len = strlen(p); + fputs(p, fp); + return len; +} + +/* +Local Variables: +tab-width: 4 +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +End: +*/ diff --git a/dviware/dvitops/config.doc b/dviware/dvitops/config.doc new file mode 100644 index 0000000000..c50eea1073 --- /dev/null +++ b/dviware/dvitops/config.doc @@ -0,0 +1,133 @@ +PAPER: the default type of paper: either "a4" or "letter". + +TEXPK: a string which gives the possible names for pk files; %f will +be replaced by the name of the font, %d by the resolution in dpi; +possible names are separated by AREA_LIST_SEP. + +TEXFONTS: a string containing a list of directories in which to look +for tfm files; elements of the list are separated by AREA_LIST_SEP. + +TEXINPUTS: a string containing a list of directories in which to look +for other input files; elements of the list are separated by +AREA_LIST_SEP. + +TEXMAGS: a list of magnifications at which some pk font is available, +separated by commas. + +PSFONTS: a string containing a list of directories in which to look +for PostScript fonts; elements of the list are separated by +AREA_LIST_SEP. Used by psfont. + +HAVE_REDIRECTION: define this if the OS supports redirection. + +HAVE_SETVBUF: define this if your C library contains setvbuf. + +FOPEN_RB(filename): a macro to open `filename' in binary mode for reading; +by default fopen(filename, "r"). + +DPI: an integer giving the default resolution which should be used in +dots per inch. + +FILENAME_MAX: the maximum length of a filename (including the directory and +extension.) + +AREA_LIST_SEP: the character that separates elements in a list of +directories. + +AREA_SEP: the character that separates the name of the area from the +name of the file. + +AREA_SEP2: alternative character that separates the name of an area from +the name of the file. + +FILENAME_HAS_AREA(f): a macro which returns non-zero if the string f +is absolute, ie it already has an area attached. + +POSTFIX_AREA: define this if area names come after file names. + +CASE_INSENSITIVE_FILENAME: define this if filenames are case +insensitive. + +REORDER_ARGS: define this if options can be given after the filename, +as well as before it. + +CASE_INSENSITIVE_OPTIONS: define this if option names are case insensitive. + +MAXFONTS: maximum font number; TeX 82 never has more than 256. + +HAVE_ISATTY: define this if your C library supports isatty. + +PROTO: define this if your compiler supports prototypes. + +BROKEN_PROTO: ANSI C says that the correct prototype for an old-style +function definition like this + +void foo(c) +unsigned char c; +{ +} + +is + +extern void foo(int); + +Some compilers incorrectly require the prototype + +extern void foo(unsigned char); + +If you have a compiler that is broken in this way define BROKEN_PROTO. + +STDARG: define this if your compiler supports stdarg.h rather than +varargs.h. + +SWITCHAR: define this if you are using MS-DOS and you want getopt to +take account of the current `switchar'. + +UCHAR_MAX: the maximum value of an unsigned char. +USHRT_MAX: the maximum value of an unsigned short. +UINT_MAX: the maximum value of an unsigned int. +SHRT_MAX: the maximum value of a short. +INT_MAX: the maximum value of an int. +LONG_MAX: the maximum value of a long. + +time_t: the type returned by the time() function. + +size_t: the type of arguments to malloc. + +const: define this as nothing if your system does not understand const. + +TPIC_SUPPORT: define this to get support for the tpic specials (version 2). + +NORMAL_EXIT_CODE: define this to be the exit code to be used when no +warnings or errors were encountered; by default 0. + +WARNING_EXIT_CODE: define this to be the exit code to be used when a +warning was generated; by default 1 + +ERROR_EXIT_CODE: define this to be the exit code to be used when an +error was generated; by default 2. + +FATAL_ERROR_EXIT_CODE: define this to be the exit code to be used if a +fatal error was generated; by default 3. + +PRIMOS_GETENV: define this if you have PRIMOS, and need a simulated +getenv(). + +HAVE_MEMORY_H: define this if the mem* functions are declared in +<memory.h>. + +NEED_MEM_FUNCTIONS: define this if your C library does not contain +mem* functions. + +NEED_QSORT: define this if you C library does not contain qsort. + +NEED_STRTOK: define this if you C library does not contain strtok. + +EBCDIC: define this if your system uses EBCDIC rather than ASCII. + +XCHAR(c): if defined, this macro translates from ASCII to the +machine's native character set; you don't need to define this if +you've already defined EBCDIC. Like the xchr array in the TeX +sources. + +$Header: /usr/jjc/dvitops/RCS/config.doc,v 1.2 90/08/17 15:52:24 jjc Exp $ diff --git a/dviware/dvitops/config.h b/dviware/dvitops/config.h new file mode 100644 index 0000000000..8e3f514053 --- /dev/null +++ b/dviware/dvitops/config.h @@ -0,0 +1,43 @@ +/* $Header: /usr/jjc/dvitops/RCS/unix.h,v 1.2 90/08/17 15:52:56 jjc Exp $ */ +/* UNIX support */ + +#define PAPER "a4" +#define TPIC_SUPPORT + +#define TEXFONTS ".:/usr/local/tex/fonts" +#define TEXINPUTS ".:/usr/local/tex/inputs" +#define TEXPK "%f.%dpk:/usr/local/tex/pk/%f.%dpk" +#define TEXMAGS 214,240,257,270,300,329,360,432,518,622,746,896,1075,1290 +#define PSFONTS ".:/usr/local/psfonts" +#define HAVE_REDIRECTION +#define HAVE_SETVBUF +#define DPI 300 +#define FILENAME_MAX 1024 +#define AREA_LIST_SEP ':' +#define AREA_SEP '/' +#define FILENAME_HAS_AREA(f) (*(f) == '/') +#define MAXFONTS 256 +#define HAVE_ISATTY +#define HAVE_MEMORY_H + +#ifdef __STDC__ + +#define PROTO +#define HAVE_SETVBUF +#define STDARG +#include <limits.h> + +#else + +#define const +#define UCHAR_MAX 255 +#define USHRT_MAX 0xffff +#define SHRT_MAX 32767 +#define UINT_MAX 0xffff +#define INT_MAX 32767 +#define LONG_MAX 2147483647L + +#endif /* __STDC__ */ + +typedef unsigned size_t; +typedef long time_t; diff --git a/dviware/dvitops/dvi.c b/dviware/dvitops/dvi.c new file mode 100644 index 0000000000..6038eca5f6 --- /dev/null +++ b/dviware/dvitops/dvi.c @@ -0,0 +1,625 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/dvi.c,v 1.6 90/08/14 13:09:18 jjc Rel $"; + +#include "dvitops.h" + + +static struct stack { + integer h, v, w, x, y, z; +} *stack; + + + +struct addr_count0 { + integer addr; + integer count0; +}; +struct postamble_info { + integer num; + integer den; + int mag; + integer last_bop; /* address of last bop */ + int npages; + int stack_size; +}; + + +#ifdef PROTO +static void first_pass(int, long *, int, struct addr_count0 *); +static void read_page(struct page_info *page); +static int read_opcode(void); +static void read_postamble(struct postamble_info *postamble); +static void bad_dvi_file(void); +static int count_compare(char *p1, char *p2); +#else +static void first_pass(); +static void read_page(); +static int read_opcode(); +static void read_postamble(); +static void bad_dvi_file(); +static int count_compare(); +#endif +#if 0 +typedef enum { SET_CHAR_0 = 0, SET1 = 128, SET_RULE = 132, PUT1 = 133, +PUT_RULE = 137, BOP = 139, EOP = 140, PUSH = 141, POP = 142, RIGHT1 = 143, +W0 = 147, W1 = 148, X0 = 152, X1 = 153, DOWN1 = 157, Y0 = 161, Y1 = 162, +Z0 = 166, Z1 = 167, FNT_NUM_0 = 171, FNT1 = 235, NOP = 138, XXX1 = 239, +FNT_DEF1 = 243, PRE = 247, POST = 248, POST_POST = 249 } dvi_opcode; +#else +#define SET_CHAR_0 0 +#define SET1 128 +#define SET_RULE 132 +#define PUT1 133 +#define PUT_RULE 137 +#define BOP 139 +#define EOP 140 +#define PUSH 141 +#define POP 142 +#define RIGHT1 143 +#define W0 147 +#define W1 148 +#define X0 152 +#define X1 153 +#define DOWN1 157 +#define Y0 161 +#define Y1 162 +#define Z0 166 +#define Z1 167 +#define FNT_NUM_0 171 +#define FNT1 235 +#define NOP 138 +#define XXX1 239 +#define FNT_DEF1 243 +#define PRE 247 +#define POST 248 +#define POST_POST 249 +#endif + +static FILE *dvifp; + +#define SPECIAL_BUF_SIZE 2048 +static char special_buf[SPECIAL_BUF_SIZE]; + + +static void first_pass(totalpages, start_page, maxpages, pagevec) +int totalpages, maxpages; +long start_page[10]; +struct addr_count0 *pagevec; +{ + integer count[10]; + int pageno; + int started = FALSE; + int selected = FALSE; + int pages_selected = 0; + fseek(dvifp, 14L, 0); + if (fseek(dvifp, (long)uread1(dvifp), 1) != 0) + bad_dvi_file(); + for (pageno = 0; pageno < totalpages; pageno++) { + unsigned char opcode; + int i; + int donepage = FALSE; + int f = -1; + pagevec[pageno].addr = ftell(dvifp); + while (!donepage) { + unsigned char c; + integer n = 0; + /* deal with the most common case in its own loop */ + while ((opcode = uread1(dvifp)) <= 127) { + if (feof(dvifp) || ferror(dvifp)) + bad_dvi_file(); + if (selected) + used_char(f, opcode); + } + /* we use the fact that SET_CHAR_0 is 0 */ + + if (FNT_NUM_0 <= opcode && opcode <= FNT_NUM_0 + 63) { + n = opcode - FNT_NUM_0; + opcode = FNT1; + } + else + switch (opcode) { + case SET1 + 3 : case PUT1 + 3 : case XXX1 + 3: + case FNT_DEF1 + 3: case FNT1 + 3: + n = sread4(dvifp); break; + case SET1 + 2 : case PUT1 + 2 : case XXX1 + 2: + case FNT_DEF1 + 2: case FNT1 + 2: + n = uread3(dvifp); break; + case SET1 + 1 : case PUT1 + 1 : case XXX1 + 1: + case FNT_DEF1 + 1: case FNT1 + 1: + n = uread2(dvifp); break; + case SET1 : case PUT1 : case XXX1: + case FNT_DEF1: case FNT1: + n = uread1(dvifp); break; + case RIGHT1 + 3: case W1 + 3: case X1 + 3: + case DOWN1 + 3: case Y1 + 3: case Z1 + 3: + (void)uread1(dvifp); + /* falls through */ + case RIGHT1 + 2: case W1 + 2: case X1 + 2: + case DOWN1 + 2: case Y1 + 2: case Z1 + 2: + (void)uread1(dvifp); + /* falls through */ + case RIGHT1 + 1: case W1 + 1: case X1 + 1: + case DOWN1 + 1: case Y1 + 1: case Z1 + 1: + (void)uread1(dvifp); + /* falls through */ + case RIGHT1: case W1: case X1: + case DOWN1: case Y1: case Z1: + (void)uread1(dvifp); + break; + case SET_RULE: case PUT_RULE : + sread4(dvifp); sread4(dvifp); + break; + } + switch (opcode) { + case SET1 + 3 : case SET1 + 2 : case SET1 + 1 : case SET1 : + case PUT1 + 3 : case PUT1 + 2 : case PUT1 + 1 : case PUT1 : + if (!selected) + break; + c = (unsigned char) n; + if (n >= MAXCHARS || n < 0) + message(ERROR, + "character code %ld too large: using %d instead", + (long)n, c); + used_char(f, c); + break; + case BOP : + for (i = 0; i < 10; ++i) + count[i] = sread4(dvifp); + pagevec[pageno].count0 = count[0]; + (void) sread4(dvifp); + if (!started) { + int j; + started = TRUE; + for (j = 0; j < 10; j++) + if (start_page[j] != WILD + && start_page[j] != count[j]) + started = FALSE; + } + if (started && ++pages_selected <= maxpages) + selected = TRUE; + else { + selected = FALSE; + pagevec[pageno].addr = -1; + } + break; + case EOP : + if (selected) + store_page_usage(); + donepage = TRUE; + break; + case FNT1 : case FNT1 + 1 : case FNT1 + 2 : case FNT1 + 3 : + if (!selected) + break; + if (n < 0 || n >= MAXFONTS) + /* this should have been spotted in the postamble */ + cant_happen(); + f = (int) n; + break; + case XXX1 + 3 : case XXX1 + 2 : case XXX1 + 1 : case XXX1: + if (n >= SPECIAL_BUF_SIZE) { + message(ERROR, + "special string too long: ignoring it"); + fseek(dvifp, (long)n, 1); + break; + } + fread(special_buf, 1, (size_t)n, dvifp); + special_buf[n] = '\0'; + STRXCHAR(special_buf) + if (selected) + special(PASS1, special_buf,(integer)0,(integer)0); + break; + case FNT_DEF1 : case FNT_DEF1 + 1 : + case FNT_DEF1 + 2 : case FNT_DEF1 + 3 : + fseek(dvifp, 12L, 1); + n = uread1(dvifp); + n += uread1(dvifp); + fseek(dvifp, (long)n, 1); + break; + case POST : + bad_dvi_file(); + default : + break; + } + } + } +} + +static int read_opcode() +{ + for (;;) { + int c = uread1(dvifp); + if (c == EOF) + cant_happen(); + if (XXX1 <= c && c <= XXX1 + 3) { + integer k; + switch (c) { + case XXX1 : + k = uread1(dvifp); break; + case XXX1 + 1: + k = uread2(dvifp); break; + case XXX1 + 2: + k = uread3(dvifp); break; + case XXX1 + 3: + k = sread4(dvifp); break; + } + fseek(dvifp, (long)k, 1); + } + else if (c != NOP) + return c; + } +} + + +static void read_postamble(postamble) +struct postamble_info *postamble; +{ + int c; + integer n; + long offset; + /* Avoid using a negative offset. + Some implementations can't handle this. */ + if (fseek(dvifp, 0L, 2) != 0) + message(FATAL_ERROR, "can't perform seek on dvi file"); + offset = ftell(dvifp); + do { + offset--; + fseek(dvifp, offset, 0); + c = uread1(dvifp); + } while (c == 223); + if (c != ID_BYTE) + message(FATAL_ERROR, "this is the wrong type of dvi file"); + offset -= 5; + fseek(dvifp, offset, 0); + if (uread1(dvifp) != POST_POST) + cant_happen(); + offset = sread4(dvifp); + fseek(dvifp, offset, 0); + if (uread1(dvifp) != POST) + cant_happen(); + postamble->last_bop = sread4(dvifp); + postamble->num = sread4(dvifp); + postamble->den = sread4(dvifp); + n = sread4(dvifp); + if (postamble->mag == 0) { + postamble->mag = (int)n; + if (n < 0 || n > INT_MAX) { + message(ERROR, "bad magnification: using 1000 instead"); + n = 1000; + } + } + (void) sread4(dvifp); + (void) sread4(dvifp); + postamble->stack_size = sread2(dvifp); + postamble->npages = sread2(dvifp); + while ((c = read_opcode()) >= FNT_DEF1 && c <= FNT_DEF1 + 3) { + integer k; + integer cs, s, d; + int a, l; + char area[257]; + char name[257]; + switch (c + 1 - FNT_DEF1) { + case 1: + k = uread1(dvifp); break; + case 2: + k = uread2(dvifp); break; + case 3: + k = uread3(dvifp); break; + case 4: + k = sread4(dvifp); break; + } + cs = sread4(dvifp); + s = sread4(dvifp); + d = sread4(dvifp); + a = uread1(dvifp); + l = uread1(dvifp); + if (a) + fread(area, 1, a, dvifp); + area[a] = '\0'; + fread(name, 1, l, dvifp); + name[l] = '\0'; + STRXCHAR(name) + STRXCHAR(area) + f_def(k, name, area, cs, s, d, postamble->mag); + } + if (c != POST_POST) + cant_happen(); +} + + +static int count_compare(p1, p2) +char *p1, *p2; +{ + integer n1 = ((struct addr_count0 *)p1)->count0; + integer n2 = ((struct addr_count0 *)p2)->count0; + if (n1 == n2) + return (int)(((struct addr_count0 *)p1)->addr - + ((struct addr_count0 *)p2)->addr); + else if (n1 <= 0 || n2 <= 0) { + if (n2 > 0) + return -1; + else if (n1 > 0) + return 1; + else + return (int)(n2 - n1); + } + else + return (int)(n1 - n2); +} + + + +void read_dvi_file(fp, ofp, option) +FILE *fp, *ofp; +struct option_info *option; +{ + struct postamble_info postamble; + struct page_info page; + FILE *psfp; + int i; + int actual_npages; + struct addr_count0 *pagevec; + dvifp = fp; + postamble.mag = option->mag; + read_postamble(&postamble); + if ((stack = + (struct stack *)malloc(sizeof(struct stack)*postamble.stack_size)) + == NULL) + out_of_memory(); + if ((pagevec = (struct addr_count0 *)malloc((1 + postamble.npages) + *sizeof(struct addr_count0))) == NULL) + out_of_memory(); + first_pass(postamble.npages, option->start_page, option->maxpages, + pagevec); + psfp = ofp; +#ifdef HAVE_SETVBUF + setvbuf(psfp, (char *)NULL, _IOFBF, 16384); /* ignore any error */ +#endif + for (i = 0, actual_npages = 0; i < postamble.npages; i++) + if (pagevec[i].addr != -1L) + actual_npages++; + prologue(psfp, actual_npages, option->reverse, option->paper); + page.num = postamble.num; + page.den = postamble.den; + page.hoffset = option->hoffset; + page.voffset = option->voffset; + page.copies = option->copies; + page.paper = option->paper; + page.max_drift = (int)((254000.0/page.num) * (page.den/(double)dpi) * 2.0); + if (option->sort) + qsort((char *)pagevec, postamble.npages, sizeof(struct addr_count0), + count_compare); + if (option->reverse) { + for (i = postamble.npages - 1; i >= 0; i--) + if (pagevec[i].addr != -1L) { + page.address = pagevec[i].addr; + page.mag = postamble.mag; + read_page(&page); + } + } + else { + for (i = 0; i < postamble.npages; i++) + if (pagevec[i].addr != -1L) { + page.address = pagevec[i].addr; + page.mag = postamble.mag; + read_page(&page); + } + } + trailer(); +} + +static void read_page(page) +struct page_info *page; +{ + unsigned char opcode; + int had_large_hmotion = FALSE; + int i; + char buf[512]; + int nbuf = 0; /* number of characters in buf */ + integer endh = 0, rounded_endh = 0; + integer h, v, w, x, y, z; + struct stack *sp = stack; + int f = -1; + integer fs = 0; /* = f_space(f) */ + h = v = w = x = y = z = 0; + + fseek(dvifp, (long)page->address, 0); + for (;;) { + integer starth; + integer startv; + int startf; + unsigned char c; + integer a, b; + integer wd; + integer n = (integer)0; + opcode = uread1(dvifp); + /* we use the fact that SET_CHAR_0 is 0 */ + if (opcode <= 127) { + /* we checked for eof and error on pass 1 */ + n = opcode; + opcode = SET1; + } + else if (FNT_NUM_0 <= opcode && opcode <= FNT_NUM_0 + 63) { + n = opcode - FNT_NUM_0; + opcode = FNT1; + } + else + switch (opcode) { + case SET1 + 3 : case PUT1 + 3 : case XXX1 + 3: + case RIGHT1 + 3: case W1 + 3: case X1 + 3: + case DOWN1 + 3: case Y1 + 3: case Z1 + 3: + case FNT_DEF1 + 3: case FNT1 + 3: + n = sread4(dvifp); break; + case SET1 + 2 : case PUT1 + 2 : case XXX1 + 2: + case FNT_DEF1 + 2: case FNT1 + 2: + n = uread3(dvifp); break; + case SET1 + 1 : case PUT1 + 1 : case XXX1 + 1: + case FNT_DEF1 + 1: case FNT1 + 1: + n = uread2(dvifp); break; + case SET1 : case PUT1 : case XXX1: + case FNT_DEF1: case FNT1: + n = uread1(dvifp); break; + case RIGHT1 + 2: case W1 + 2: case X1 + 2: + case DOWN1 + 2: case Y1 + 2: case Z1 + 2: + n = sread3(dvifp); break; + case RIGHT1 + 1: case W1 + 1: case X1 + 1: + case DOWN1 + 1: case Y1 + 1: case Z1 + 1: + n = sread2(dvifp); break; + case RIGHT1: case W1: case X1: + case DOWN1: case Y1: case Z1: + n = sread1(dvifp); break; + } + switch (opcode) { + case SET1 + 3 : case SET1 + 2 : case SET1 + 1 : case SET1 : + case PUT1 + 3 : case PUT1 + 2 : case PUT1 + 1 : case PUT1 : + /* we checked it wasn't out of range on pass 1 */ + c = (unsigned char)n; + if (nbuf > 0 && + (h != endh || v != startv || f != startf + || had_large_hmotion + || nbuf >= sizeof(buf) + || endh - rounded_endh > page->max_drift + || endh - rounded_endh < -page->max_drift)) { + set_string(buf, nbuf, startf, starth, startv); + nbuf = 0; + } + if (nbuf == 0) { + if (endh != rounded_endh && !had_large_hmotion) { + if (rounded_endh - endh > page->max_drift) + starth = h + page->max_drift; + else if (rounded_endh - endh < -page->max_drift) + starth = h - page->max_drift; + else + starth = h + (rounded_endh - endh); + } + else + starth = h; + endh = h; + rounded_endh = starth; + startv = v; + startf = f; + had_large_hmotion = FALSE; + } + buf[nbuf++] = c; + used_char(f, c); + wd = f_width(f, c); + endh += wd; + rounded_endh += f_rounded_width(f, c); + /* we rely on the fact that SET1 < PUT1 */ + if (opcode < PUT1) + h += wd; + break; + case SET_RULE : case PUT_RULE : + a = sread4(dvifp); + b = sread4(dvifp); + set_rule(a, b, h, v); + if (opcode == SET_RULE) + h += b; + break; + case NOP : + break; + case BOP : + for (i = 0; i < 10; ++i) + page->count[i] = sread4(dvifp); + (void) sread4(dvifp); + break; + case EOP : + if (nbuf) + set_string(buf, nbuf, startf, starth, startv); + eop(page); + return; + case PUSH : + sp->h = h; sp->v = v; sp->w = w; + sp->x = x; sp->y = y; sp->z = z; + ++sp; + break; + case POP : + --sp; + h = sp->h; v = sp->v; w = sp->w; + x = sp->x; y = sp->y; z = sp->z; + break; + case RIGHT1 : case RIGHT1 + 1 : + case RIGHT1 + 2 : case RIGHT1 + 3 : + h += n; + if (n >= fs || n <= fs*-4) + had_large_hmotion = TRUE; + break; + case W0 : + h += w; + break; + case W1 : case W1 + 1 : case W1 + 2 : case W1 + 3 : + h += w = n; + break; + case X0 : + h += x; + break; + case X1 : case X1 + 1 : case X1 + 2 : case X1 + 3 : + h += x = n; + break; + case DOWN1 : case DOWN1 + 1 : case DOWN1 + 2 : case DOWN1 + 3: + v += n; + break; + case Y0 : + v += y; + break; + case Y1 : case Y1 + 1 : case Y1 + 2 : case Y1 + 3 : + v += y = n; + break; + case Z0 : + v += z; + break; + case Z1 : case Z1 + 1 : case Z1 + 2 : case Z1 + 3 : + v += z = n; + break; + case FNT1 : case FNT1 + 1 : case FNT1 + 2 : case FNT1 + 3 : + if (n < 0 || n >= MAXFONTS) + /* this should have caused a fatal error on pass 1 */ + cant_happen(); + f = (int)n; + fs = f_space(f); + break; + case XXX1 + 3 : case XXX1 + 2 : case XXX1 + 1 : case XXX1 : + if (n >= SPECIAL_BUF_SIZE) { + /* we printed an error on the first pass */ + fseek(dvifp, (long)n, 1); + break; + } + if (nbuf > 0) { /* flush buf */ + set_string(buf, nbuf, startf, starth, startv); + nbuf = 0; + } + fread(special_buf, 1, (int)n, dvifp); + special_buf[n] = '\0'; + STRXCHAR(special_buf) + special(PASS2, special_buf, h, v); + break; + case FNT_DEF1 : case FNT_DEF1 + 1 : + case FNT_DEF1 + 2 : case FNT_DEF1 + 3 : + fseek(dvifp, 12L, 1); + n = uread1(dvifp); + n += uread1(dvifp); + fseek(dvifp, (long)n, 1); + break; + case POST : + if (nbuf) + set_string(buf, nbuf, startf, starth, startv); + return; + default : + bad_dvi_file(); + } + } +} + +static void bad_dvi_file() +{ + message(FATAL_ERROR, "this dvi file is bad -- use dvitype"); +} + +/* +Local Variables: +tab-width: 4 +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +End: +*/ diff --git a/dviware/dvitops/dvitops.1 b/dviware/dvitops/dvitops.1 new file mode 100644 index 0000000000..bc55ac49e2 --- /dev/null +++ b/dviware/dvitops/dvitops.1 @@ -0,0 +1,398 @@ +'\" e +.\" $Header: /usr/jjc/dvitops/RCS/dvitops.1,v 1.5 90/08/14 13:31:17 jjc Rel $ +.TH DVITOPS L +.SH NAME +dvitops \- convert the output of TeX to PostScript +.SH SYNOPSIS +.B dvitops +[ +.B \-qrs +] [ +.BI \-c ncopies +] [ +.BI \-f firstpage +] [ +.BI \-n npages +] +.if n .ti +0.5i +[ +.BI \-m magnification +] [ +.BI \-y kmem +] [ +.BI \-h hoffset +] +.if n .ti +0.5i +.if t .ti +0.5i +[ +.BI \-v voffset +] [ +.BI \-p papersize +] [ +.BI \-d dpi +] [ +.I dvifile +] +.SH DESCRIPTION +.B dvitops +converts a dvi file produced by TeX into PostScript. +If the +.I dvifile +argument is not present, +.B dvitops +reads the standard input. In this case the standard input must be a file +rather than a pipe. +The extension +.B .dvi +may be omitted. +The output is written on the standard output, and is normally piped +into +.BR lpr . +Either bitmap fonts in pk format, or ordinary PostScript fonts +may be used. If PostScript fonts are used which are not +resident in the printer, the output of +.B dvitops +must be passed through a filter or spooler that can handle +font downloading. +.SH OPTIONS +.TP +.B \-q +Quiet mode. Don't print the numbers of pages as they are printed. +.TP +.B \-r +Output pages in reverse order. +.TP +.B \-s +Sort pages by their +.B \ecount0 +values. +.TP +.BI \-c ncopies +Print +.I ncopies +of each page. The copies will not be collated. The default is 1. +.TP +.BI \-f firstpage +The first page to be output will be +.I firstpage. +This is specified in the same way as in +.BR dvitype : +a sequence of one to ten numbers or asterisks separated by periods. +For example, +.B \-1.*.3 +will match the first page whose +.B \ecount0 +value is \-1, and whose +.B \ecount2 +value is 3. The default is +.BR * , +which will match any page. +.TP +.BI \-n npages +Output at most +.I npages +pages. The default is a large number. +.TP +.BI \-m magnification +Replace the magnification in the input file by +.IR magnification . +A magnification of 1000 means no magnification; a magnification to 2000 +means magnification by a factor of 2. +.TP +.BI \-y kmem +Use at most +.IR kmem k +bytes of printer memory for preloading bitmap fonts. +In order to improve performance, +.B dvitops +puts the bitmap fonts that are most used in the document at the +beginning of the output; other fonts have to be output for each page +on which they are used. The default value is 100, which is suitable for +the oldest PostScript printers. Newer printers with more memory will +give better performance with a higher value. +.TP +.BI \-h hoffset +Position the left hand edge of the output +.I hoffset +away from the left edge of the paper. +.I hoffset +is given as a number with an optional decimal point followed by one +of the units of measure recognised by TeX. +The default value is 1 inch, which is the value assumed by most macro +packages. +.TP +.BI \-v voffset +Position the top edge of the output +.I voffset +away from the top edge of the paper. +.I voffset +is given as a number with an optional decimal point followed by one +of the units of measure recognised by TeX. +The default value is 1 inch, which is the value assumed by most macro +packages. +.TP +.BI \-p papersize +Produce output suitable for +.I papersize +paper. +.I papersize +is one of the standard PostScript paper types: +.BR a4 , +.BR letter , +.BR legal , +.BR b5 , +.BR b4 , +.BR tabloid , +.BR ledger , +.BR statement , +.BR executive , +.BR a3 , +.BR a5 , +.BR folio , +.B quarto +or +.BR 10x17 . +The default is +.BR letter . +.B dvitops +uses the paper dimensions to position the output correctly. +Non-standard paper sizes can be accommodated using the +.B \-h +or +.B \-v +options. +.TP +.BI \-d dpi +Choose bitmap fonts suitable for a printer with a resolution +of +.I dpi +dots per inch. The default is 300. +.SH USAGE +.B dvitops +supports the use of TeX's +.B \especial +primitive to take advantage of some of PostScript's advanced facilities. +.B dvitops +recognises only +.B \especial +commands whose arguments start with a +.B dvitops:\& +tag. +The following +.B \especial +commands are available: +.TP +\fB\especial{dvitops: landscape}\fP +Print the current page in landscape mode, +with its top along the long side of the paper. +.TP +\fB\especial{dvitops: import \fIfilename width height \ +\fR[ \fIoption\fR\|.\|.\|. ] \fB}\fR +This is used to include a picture in the output. +.I filename +must contain PostScript code. +The picture will be positioned with its +lower left hand corner at the current position. +The +.I width +and +.I height +arguments +give the desired height and width of the illustration in the output; +these are given as numbers with an optional decimal point followed +by one of the units of measure recognised by TeX. +.B dvitops +will scale the picture to fit this space. +Usually +.B dvitops +will scale the picture by the same amount vertically as horizontally, +so that the picture retains its original proportions, and +will center the picture in any surplus horizontal or vertical white space. +An option of +.BR top , +.BR bottom , +.B left +or +.B right +will cause the picture to be positioned at the top, bottom, left or +right of the specified space, rather than being centered. +An option of +.B fill +will cause the picture to be scaled to fit the specified space both +horizontally and vertically. The imported file must +comply with the Adobe Document Structuring Conventions. In particular +it must contain a +.B %%BoundingBox: +comment in an appropriate place. Additionally, the file should +comply with the guidelines given in the specification of EPSF +(Encapsulated PostScript Format). A file beginning with the line +.br +.B "%!PS-Adobe-2.0 EPSF-1.2" +.br +is likely to meet these requirements. +.TP +\fB\especial{dvitops: inline \fIanything\fB}\fR +Include the arbitrary PostScript code +.I anything +in the output. +When this code is executed, the coordinate system in effect will +be TeX's: units are scaled points (65536 in a point) with the origin +1 inch down from and 1 inch to the right of the top left corner of +the page; currentpoint will be set to the currrent position +in the dvi file. All +.B inline +commands occurring on a given page will be collected together and output +at the end of page in the order in which they appeared. +.TP +\fB\especial{dvitops: prolog \fIfilename\fB}\fR +Make the PostScript definitions contained in +.I filename +available at this point in the file. +An extension of +.B .ps +may be omitted from +.IR filename . +This command is intended for use with the +.B inline +command. The +.B inline +command should be used simply to invoke procedures defined in other files +and made available by the +.B prolog +command. +The +.B prolog +command must be given at each place that the definitions that it contains +are required. This ensures that the definitions will be available even +if not all pages are output. The file will be downloaded at most once, +however many times it appears. +.TP +\fB\especial{dvitops: begin \fIregion\fB}\fR +.PD 0 +.TP +\fB\especial{dvitops: end}\fR +Delimit a region of the dvi file to which +some geometric transformation is to be applied; the +.I region +argument serves to identify the region. +Regions cannot be nested, nor can they extend over more than one +output page. There can be multiple +.B begin +and +.B end +commands for each region. +.PD +.TP +\fB\especial{dvitops: origin \fIregion\fB}\fR +Make the current position the origin for transformations to be applied to +.IR region . +By default the origin is TeX's origin, 1 inch down from and 1 inch to +the right of the top left hand corner of the page. +.TP +\fB\especial{dvitops: rotate \fIregion \(*h\fB}\fR +Rotate +.I region +clockwise about its origin by \(*h degrees. +.TP +\fB\especial{dvitops: transform \fIregion a b c d\fB}\fR +Apply the affine transformation represented by the matrix +.EQ +left [ matrix { +ccol { a above c } +ccol { b above d } +} right ]. +.EN +to +.IR region . +Arbitrarily many transformations may be applied to each region. +They will be applied in the order in which they are given. +.TP +\fB\especial{dvitops: gray \fIregion shade\fB}\fR +Use the gray shade corresponding to +.IR shade , +which must be a number between 0 and 1, for +.IR region . +0 corresponds to black and 1 corresponds to white. +.TP +\fB\especial{dvitops: rgbcolor \fIregion red green blue\fB}\fR +Use the color described by the parameters +.IR red , +.IR green , +and +.IR blue , +each of which must be numbers between 0 and 1, for +.IR region . +.TP +\fB\especial{dvitops: hsbcolor \fIregion hue saturation brightness\fB}\fR +Use the color described by the parameters +.IR hue , +.IR saturation , +and +.IR brightness , +each of which must be numbers between 0 and 1, for +.IR region . +.SH ENVIRONMENT +.B dvitops +uses various environment variables in order to find the files +it requires. They each contain lists separated by colons. +.TP 15 +.B +.SM TEXINPUTS +A list of directories in which to search for text input files. +.TP +.B +.SM TEXFONTS +A list of directories in which to search for tfm files. +.TP +.B +.SM TEXPK +A list of prototypes of names of pk files. +When a particular font is being searched for, a +.B %d +in the prototype will be replaced by the magnification of +the font in dots per inch, and a +.B %f +will be replaced by the name of the font. +.TP +.B +.SM TEXMAGS +A list of all the magnifications for which there is some pk file. +The magnifications are expressed in dots per inch. +.B dvitops +will only look for pk files at these magnifications. If a font +is required at some other magnification, a scaled version of the +font at one of the listed magnifications will be used. +.TP +.B +.SM DVITOPS +The value of this variable will be interpreted as if it had been typed in +at the beginning of the command line. For example, if it is set to +.B \-r +all output from +.B dvitops +will appear in reverse order (unless overridden by a second occurrence of +.BR \-r ). +.SH FILES +.PD 0 +.TP 30 +.B /usr/local/tex/inputs/dvitops.pro +PostScript definitions used by dvitops +.TP +.B /usr/local/tex/input/dvitops.fnt +list of the TeX and PostScript names of PostScript fonts +.TP +.B /usr/local/tex/pk/*.*pk +pk files +.TP +.B /usr/local/tex/fonts/*.tfm +tfm files +.TP +.B /usr/local/tex/fonts/*.enc +encoding files +.PD +.SH "SEE ALSO" +.LP +.\" IR "DVITOPS User Manual" , +.BR tex (L) +.SH AUTHOR +James Clark <jjc@jclark.uucp> diff --git a/dviware/dvitops/dvitops.fnt b/dviware/dvitops/dvitops.fnt new file mode 100644 index 0000000000..103c895123 --- /dev/null +++ b/dviware/dvitops/dvitops.fnt @@ -0,0 +1,44 @@ +AvantGarde-Book +AvantGarde-BookOblique +AvantGarde-Demi +AvantGarde-DemiOblique +Bookman-Demi +Bookman-DemiItalic +Bookman-Light +Bookman-LightItalic +Courier-Bold +Courier-BoldOblique +Courier-Oblique +Courier +Helvetica-Bold +Helvetica-BoldOblique +Helvetica-Narrow-Bold +Helvetica-Narrow-BoldOblique +Helvetica-Narrow-Oblique +Helvetica-Narrow +Helvetica-Oblique +Helvetica +NewCenturySchlbk-Bold +NewCenturySchlbk-BoldItalic +NewCenturySchlbk-Italic +NewCenturySchlbk-Roman +Optima-Bold +Optima-BoldOblique +Optima-Oblique +Optima +Palatino-Bold +Palatino-BoldItalic +Palatino-Italic +Palatino-Roman +Symbol +Times-Bold +Times-BoldItalic +Times-Italic +Times-Roman +ZapfChancery-MediumItalic +ZapfDingbats +timessl Times-Slanted +timessc Times-SmallCaps +timesex Times-Extension +symbolsl Symbol-Slanted + diff --git a/dviware/dvitops/dvitops.h b/dviware/dvitops/dvitops.h new file mode 100644 index 0000000000..eea8bc85c2 --- /dev/null +++ b/dviware/dvitops/dvitops.h @@ -0,0 +1,170 @@ +/* $Header: /usr/jjc/dvitops/RCS/dvitops.h,v 1.7 90/08/14 13:14:07 jjc Rel $ */ + +#include "util.h" + +#define MAXCHARS 256 + +#define NO_REGION -1 +#define PASS1 1 +#define PASS2 2 + +#define ID_BYTE 2 +#define SIZE_MAX UINT_MAX +#define uread1(fp) ((unsigned char)(getc((fp)))) + +#define used_char(f, c) (page_used[f][c] = TRUE) + +typedef long integer; + +struct depend_list { + struct postscript_f_list *f; + struct depend_list *next; +}; + +struct postscript_f_list { + struct postscript_f_list *next; + char *file; + int in_prolog; /* download it in the prolog or it's resident anyway */ + int nuses; + char s[1]; +}; + + +struct page_info { + integer address; + integer count[10]; + integer num; + integer den; + integer max_drift; + int mag; + double hoffset; + double voffset; + int copies; + char *paper; +}; + +#define WILD LONG_MAX + +struct option_info { + int mag; + int reverse; + int sort; + int copies; + int maxpages; + char *paper; + double hoffset; + double voffset; + long start_page[10]; /* WILD if it's a * */ +}; + +extern char *texfonts; +extern char *texinputs; +extern char *texpk; +extern int dpi; +extern char *page_used[MAXFONTS]; +extern long f_memory; +extern int nprolog_fonts; +extern int current_region; +extern int nregions; +extern int landscape; +extern int magnification; +extern int quiet; + +#ifdef PROTO +integer sread4(FILE *fp); +integer sread3(FILE *fp); +int sread2(FILE *fp); +int sread1(FILE *fp); +integer uread3(FILE *fp); +integer uread2(FILE *fp); +void store_page_usage(void); +void used_font(int f); +integer f_space(int f); +integer f_width(int f, PROMOTED_UNSIGNED_CHAR c); +integer f_rounded_width(int f, PROMOTED_UNSIGNED_CHAR c); +int f_is_blank(int f); +void f_comment(FILE *); +void f_prologue(FILE *); +void f_set(int, FILE *); /* used characters are in page_used */ +void f_def(integer fontno, char *name, char *area, +integer checksum, integer at_size, integer design_size, int magnification); +int same_font(int f); +void f_emit(int i, FILE *fp); +void emit_ps_font(char *font, FILE *psfp); +void need_ps_font(char *name, FILE *psfp); +integer scale(integer x, integer z); +void set_string(char *p, int n, int f, integer h, integer v); +void set_rule(integer a, integer b, integer h, integer v); +void eop(struct page_info *p); +void trailer(void); +void prologue(FILE *, int, int, char*); +struct postscript_f_list *add_postscript_font(char *font); +void read_dvi_file(FILE *fp, FILE *ofp, struct option_info *option); +int bigpoint(char *str, char **ptr, double *res); +void p_import_list(FILE *psfp, struct page_info *page); +void special(int pass, char *s, integer h, integer v); +void p_inline_list(FILE *psfp); +void p_tpic_list(FILE *psfp, struct page_info *page); +void p_form_list(FILE *psfp); +void p_special_prologues(FILE *psfp); +int include_file(char *filename, FILE *psfp); +/* returns 1 if it can load it 0 if not */ +int load_pk_font(int n, char *name, char *used, integer at_size, + integer checksum, integer *width, integer *rounded_width); +/* returns number of bytes of vm used, roughly */ +char *find_pk_file(char *name, int mag); +integer emit_pk_font(int n, char *psname, char *used, FILE *fp); +void free_pk_font(int n); +void do_transform(int n, integer *origin_x, integer *origin_y, FILE *psfp); +char *strsave(char *); +/* return number of bytes output */ +int put_dim(long, FILE *); +int tpic_special(int, char *, integer, integer); +#else +integer sread4(); +integer sread3(); +int sread2(); +int sread1(); +integer uread3(); +integer uread2(); +void store_page_usage(); +void used_font(); +integer f_space(); +integer f_width(); +integer f_rounded_width(); +int f_is_blank(); +void f_comment(); +void f_prologue(); +void f_set(); /* used characters are in page_used */ +void f_def(); +int same_font(); +void f_emit(); +void emit_ps_font(); +void need_ps_font(); +integer scale(); +void set_string(); +void set_rule(); +void eop(); +void trailer(); +void prologue(); +struct postscript_f_list *add_postscript_font(); +void read_dvi_file(); +int bigpoint(); +void p_import_list(); +void special(); +void p_inline_list(); +void p_tpic_list(); +void p_form_list(); +void p_special_prologues(); +int include_file(); +/* returns 1 if it can load it 0 if not */ +int load_pk_font(); +char *find_pk_file(); +integer emit_pk_font(); +void free_pk_font(); +void do_transform(); +char *strsave(); +int put_dim(); +int tpic_special(); +#endif + diff --git a/dviware/dvitops/dvitops.pro b/dviware/dvitops/dvitops.pro new file mode 100644 index 0000000000..fb1c5561c2 --- /dev/null +++ b/dviware/dvitops/dvitops.pro @@ -0,0 +1,309 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/dvitops.pro,v 1.4 90/03/12 18:44:05 jjc Exp $ + +/dvitops 200 dict def dvitops begin + +systemdict /setpacking known { + /savepacking currentpacking def + true setpacking +} if + +% <h> <v> <string> Z +/Z { + 3 1 roll moveto show +} bind def + +% <h> <string> X +/X { + exch currentpoint exch pop moveto show +} bind def + +% <rh> <string> W +/W { + exch 0 rmoveto show +} bind def + +/M /moveto load def + +% When PostScript fills a path, it seems to blacken any pixel that +% wholly ***or partly*** lies within the path. Thus we can achieve +% results predictable down to the pixel level by ensuring that +% the corners of the rule do ***not*** lie on pixel boundaries. +% This procedure is made more complex by the fact that we do +% not know what the orientation of device space is---it cannot be +% assumed to be same as the default user coordinate system. +% This procedure assumes that the height and width are both > 0. +% height width x y R +/R { + newpath + % transform the coordinates of the bottom left hand corner + % to device space and round them to the nearest pixel + transform round exch round exch + % compute and moveto the point half a pixel up from and half a pixel to the + % right of this position + .5 .5 idtransform abs neg exch abs exch dtransform + 3 -1 roll add 3 1 roll add exch itransform moveto + % compute the height and width of the rule + exch dtransform abs ceiling 1 sub exch abs ceiling 1 sub exch idtransform + abs exch abs exch + % draw the rule + dup 0 exch neg rlineto exch 0 rlineto 0 exch rlineto fill +} bind def + + +/BP { + /level0 save def +} bind def + +/EP { + level0 restore showpage +} bind def + +/BO { + /level1 save def +} bind def + +/EO { + level1 restore +} bind def + + +% <page width> landscape +% page width is in PostScript points + +/landscape { + /pw exch def + [0 1 -1 0 pw 0] concat +} def + + +% <num> <den> <mag> <hoffset> <voffset> <page height> SC +% hoffset and voffset are in PostScript points +% page height is in PostScript points + +/SC { + /ph exch def + /voffset exch def + /hoffset exch def + /mag exch def + /den exch def + /num exch def + 0 ph translate 1 -1 scale + hoffset voffset translate + num 254000 div 72 mul den div mag mul 1000 div dup scale +} bind def + + + +/FF { + findfont def +} bind def + +/SF { + /a exch def + [a 0 0 a neg 0 0] makefont def +} bind def + +/F /setfont load def + +% newdictname newfontname newencoding basefontdict RE - +/RE { + dup maxlength dict /f exch def + { + exch dup dup /FID ne exch /Encoding ne and { + exch f 3 1 roll put + } { + pop pop + } ifelse + } forall + f /Encoding 3 -1 roll put + dup f /FontName 3 -1 roll put + f definefont def +} bind def + +%<string> <start index> makelong +/makelong { + /i exch def + /s exch def + s i get 24 bitshift + s i 1 add get 16 bitshift or + s i 2 add get 8 bitshift or + s i 3 add get or +} bind def + +/BuildPK { + /char exch def + /fontdict exch def + /charname + fontdict /Encoding get char get + def + /charinfo + fontdict /CharData get charname get + def + /flag + charinfo 0 get + def + flag 0 eq { + /dm charinfo 1 get def + /dn 0 def + /cols charinfo 2 get def + /rows charinfo 3 get def + /hoff + charinfo 4 get + dup 127 gt { + 256 sub + } if + def + /voff + charinfo 5 get + dup 127 gt { + 256 sub + } if + def + /prelen 6 def + } { + flag 1 eq { + /dm charinfo 1 get 256 mul charinfo 2 get add def + /dn 0 def + /cols charinfo 3 get 256 mul charinfo 4 get add def + /rows charinfo 5 get 256 mul charinfo 6 get add def + /hoff + charinfo 7 get 256 mul charinfo 8 get add + dup 32767 gt { + 65536 sub + } if + def + /voff + charinfo 9 get 256 mul charinfo 10 get add + dup 32767 gt { + 65536 sub + } if + def + /prelen 11 def + } { + /dm charinfo 1 makelong 65536 div def + /dn charinfo 5 makelong 65536 div def + /cols charinfo 9 makelong def + /rows charinfo 13 makelong def + /hoff charinfo 17 makelong def + /voff charinfo 21 makelong def + /prelen 25 def + } ifelse + } ifelse + /llx hoff neg .5 sub def + /lly voff 1 add rows sub .5 add def + dm dn llx lly llx cols add lly rows add setcachedevice + cols + rows + true + fontdict /ImageMaskMatrix get dup 4 llx neg put dup 5 rows lly add put + { + charinfo prelen charinfo length prelen sub getinterval + } + imagemask +} bind def + + +/EmptyEncoding 256 array def 0 1 255 {EmptyEncoding exch /.notdef put} for + +% <name> <ds> <hppp> <vppp> <encoding> <CharData> <llx> <lly> <urx> <ury> +/DefinePKFont { + 4 array astore /bbox exch def + /data exch def + /encoding exch def + /vppp exch def + /hppp exch def + /ds exch def + + 9 dict dup begin + /FontType 3 def + /Encoding encoding def + /BuildChar /BuildPK load def + /ImageMaskMatrix [1 0 0 -1 0 0] def + /FontMatrix [ + 65536 ds 1048576 div hppp mul div + 0 + 0 + 65536 ds 1048576 div vppp mul div + 0 + 0 + ] def + /FontBBox bbox def + /CharData data def + CharData /.notdef <000000000000> put + end + definefont pop +} def + +% this comes from the Adobe Ilustrator manual + +/Locate { + 8 dict begin + [/newury /newurx /newlly /newllx /ury /urx /lly /llx] + { + exch def + } forall + newllx newlly translate + newurx newllx sub urx llx sub div + newury newlly sub ury lly sub div + scale + llx neg lly neg translate + end +} bind def + +% tpic stuff + +/MT { + transform round exch round exch itransform + moveto +} bind def + +/LT { + transform round exch round exch itransform + lineto +} bind def + +/CT { + transform round exch round exch itransform + curveto +} bind def + +/ST /stroke load def +/FI /fill load def +/CP /closepath load def +/SG /setgray load def +/LW /setlinewidth load def +/GR /grestore load def +/GS /gsave load def + +% dash-len gap-len DH - + +/DH { + [ 3 1 roll ] 0 setdash +} bind def + +/SO { + [] 0 setdash +} bind def + +/AR /arc load def + +/TM matrix def + +/EL { + TM currentmatrix pop + translate + scale newpath 0 0 1 0 360 arc closepath + TM setmatrix +} bind def + +/TP { + 1 setlinecap 1 setlinejoin +} bind def + +systemdict /setpacking known { + savepacking setpacking +} if + +end + diff --git a/dviware/dvitops/dvitops.tex b/dviware/dvitops/dvitops.tex new file mode 100644 index 0000000000..524cda5b23 --- /dev/null +++ b/dviware/dvitops/dvitops.tex @@ -0,0 +1,436 @@ +% $Header: /usr/jjc/dvitops/RCS/dvitops.tex,v 1.2 89/02/02 14:08:01 jjc Rel $ +% this is the User Manual for DVITOPS in LaTeX format + +% this macro was borrowed from the manual to Beebe's drivers +\newcommand{\namelistlabel}[1]{\mbox{#1}\hfil} +\newenvironment{namelist}[1]{% +\begin{list}{} + { + \let\makelabel\namelistlabel + \settowidth{\labelwidth}{#1} + \setlength{\leftmargin}{1.1\labelwidth} + } + }{% +\end{list}} +\documentstyle [11pt,a4,ps]{article} +\newcommand{\dvitops}{{\tt DVITOPS}} +\newcommand{\ps}{{\sc Post\-Script}} +\title{\dvitops\ User Manual} +\author{James Clark} +\newcommand{\error}[1]{\subsubsection{{\tt #1}}} + +\begin{document} +\maketitle +\section{Introduction} +\dvitops\ translates a dvi file output of \TeX\ into \ps. It works with +both bitmap fonts and PostScript fonts. When used with the latter it +produces device-independent output. +\section{Usage} +The syntax for the \dvitops\ command is +\begin{flushleft} +{\tt dvitops} [{\it options}] {\it dvi\_file} +\end{flushleft} +You may omit the extension {\tt .dvi} from {\it dvi\_file}. +Options are delimited by the `{\tt -}' character. On MS-DOS, +they can also be delimited by `{\tt /}'. Options with no arguments +can be grouped behind a single delimiter. Option arguments that contain +white space must be enclosed in double-quotes. Option arguments +may, but need not be preceded by white space. +The following options are currently supported: + +\begin{namelist}{{\tt -h} {\it dimension}} +\item[{\tt -c} {\it ncopies}] +Print {\it ncopies\/} copies of each page; +note that the copies will not be collated. +\item[{\tt -h} {\it dimension}] +Horizontal offset. Position the origin {\it dimension} from the left edge +of the page; {\it dimension} must be a number followed by one of the units +of measure used by \TeX, for example {\tt1.5in}. +By default \dvitops\ positions the origin +of each page 1~inch down from and 1~inch to the right of +the upper left corner of the page. +This is the standard behaviour suggested by the Stanford \TeX\ project. +\item[{\tt -v} {\it dimension\/}] +Vertical offset. Position the origin {\it dimension} from the top of the page. +\item[{\tt -m} {\it number\/}] +This replaces the magnification in the +{\tt .dvi} file by {\it number}. This has the same effect as saying + `\verb|\magnification=| {\it number}' in the \TeX\ file. +\item[{\tt -r}] +Reverse the order of the pages. This is useful if you have a printer +such as the Apple LaserWriter which stacks its output face up. If this +option occurs twice on the command line, pages will be in forward order. +This is useful if you include this option in the {\tt DVITOPS} +environment variable. See Section~\ref{ev}. +\item[{\tt -q}] +Work quietly; \dvitops\ will not print the numbers of pages as it +produces them. +\item[{\tt -f} {\it page}] +Select the first page to be processed; +{\it page} is specified by giving a sequence of 1 to 10 numbers or +asterisks separated by dots. For example, the specification `\verb|1.*.-5|' +can be used to refer to a page output by \TeX{} when \verb|\count0| is 1 +and \verb|\count1| is $-5$. +An asterisk matches any number, +so the `\verb|*|' in `\verb|1.*.-5|' means that \verb|\count1| is ignored when +specifying the first page. If several pages match the given specification, +\dvitops\ will begin with the earliest such page in the file. The +default specification is `\verb|*|' which denotes +the page at the beginning of the file, since `\verb|*|' matches any page. +\item[{\tt -n} {\it number}] +Number of pages. Produce at most {\it number} pages. +\item[{\tt -s}] +Sort the pages by their \verb|\count0| value. +Negative numbers precede positive numbers. Negative numbers are sorted +in decreasing order, positive numbers in increasing order. Zero counts +as negative. +\item[{\tt -y} {\it kmem}] +Use at most {\it kmem\/} kbytes of printer memory for +preloading bitmap fonts. +\dvitops\ downloads the fonts that are most frequently used +in the document at the beginning. Other fonts have to be downloaded +on each page that they are used. +By default \dvitops\ will use at most 100k of the printer VM for this. +With this option it will use at most {\it kmem\/}k of VM. +\item[{\tt -p} {\it pagesize}] +This option informs \dvitops\ that {\it pagesize} paper will be used; +{\it pagesize} must be one of letter, legal, a4, b5, corresponding to the +page sizes used by standard \ps\ printers. This option does +not produce any \ps\ code to select this page size. +\dvitops\ needs to know the size of the page +because the \ps\ origin is at the bottom of the page, +and the \TeX\ origin is at the top of the page. If you are using a +non-standard page size, you should choose the nearest standard page size +and adjust the position of the origin using the {\tt -h} and {\tt -v} +options. +\end{namelist} +See Section~\ref{ev} to find out how you can avoid having to +type in the options that you use frequently. + +\section{\ps\ Fonts} +Ordinary \ps\ fonts not in pk format must have an entry in +the font directory file in order to be used with \dvitops. +This file is called {\tt dvitops.fnt}, and should be placed +in the same directory as the macro files used by \TeX. +Comments begin with a \verb|%|. They can start anywhere on the line +and continue to the end of the line. +Blank lines are ignored. +The syntax for each line is +\begin{flushleft} +{\it name} [{\it psname} [{\it encoding}]] +\end{flushleft} +{\it name} is the name of the font as it is known to \TeX, which is the same +as the name of the tfm file (with the extension {\tt .tfm} removed); +{\it psname} is the name of the font as it is known to \ps, for example +{\tt Times-Roman}. If {\it psname} is omitted it will be taken to be the same +as {\it name}. +The {\it encoding} field refers to an encoding file. An encoding file +describes an encoding vector for a font. +It should contain a list of the elements of the encoding vector +(without a preceding \verb|/|) separated by white space. +The file should have an extension of \verb|.enc|, which should be omitted +from {\it encoding}. +This field should be used in two situations: +if you created the tfm file with the {\tt aftopl} utility, +and you specified an encoding file (with the \verb|-e| option), +or if you wish to use \dvitops\ with tfm files intended for +use with some other driver that automatically reencodes fonts. + +\section{Environment variables} +\label{ev} +\dvitops\ needs to be able to find a number of different files. +It uses environment variables to do this. +The environment variables must be all uppercase. +These environment variables all contain +lists. Elements of the list are separated by \verb|:| under UNIX +and by \verb|;| under MS-DOS. +\begin{namelist}{{\tt TEXINPUTS}} +\item[{\tt TEXFONTS}] +If this is set, it should contain a list of directories in which +\dvitops\ should search for tfm files, and encoding files. +\item[{\tt TEXINPUTS}] +If this is set, it should contain a list of directories in which +\dvitops\ should search for its text input files: +{\tt dvitops.fnt}, {\tt dvitops.pro}, +and all the files referenced by \verb|\special| commands. +\item[{\tt TEXPK}] +This should be a list of prototypes of names of pk files. +A \verb|%f| in the prototype will be replaced by the name of the font +being searched for, +and a \verb|%d| by the magnification of the font in dots per inch. +\item[{\tt TEXMAGS}] +This should be a list of all the magnifications in dots per inch for which +there is some pk file. +\end{namelist} +The {\tt DVITOPS} environment variable allows you to avoid having to +type in frequently used options each time you use them. +When \dvitops\ reads its command line arguments, it types in the +value of this variable before any of the other arguments that have been +given. Thus if {\tt DVITOPS} is set to +\begin{verbatim} +-y 200 -r -p a4 +\end{verbatim} +and you type +\begin{verbatim} +dvitops -f 1 user +\end{verbatim} +the effect will be the same as if you had typed +\begin{verbatim} +dvitops -y 200 -r -p a4 -f 1 user +\end{verbatim} +with the environment variable {\tt DVITOPS} unset. + + +\section{{\tt \char'134special} commands} +\TeX\ has a primitive \verb|\special| which allows +arbitrary text to be included in the {\tt .dvi} file. +\dvitops\ uses this to offer a variety of extra facilities. +To be recognised by \dvitops\ the \verb|\special| must begin +with the `tag' {\tt dvitops:}. This tag is followed by a keyword and +possibly some arguments. The tag and keyword are not case-sensitive, +but the arguments are. White space is optional between the tag and the +keyword, but the keyword and arguments must be separated by white space. +A warning will be given if a \verb|\special| command with an +unrecognised tag is encountered, but it is an error if the keyword +following the {\tt dvitops:} tag is unrecognised. +\subsection{Landscape mode} +The command +\begin{verbatim} +\special{dvitops: landscape} +\end{verbatim} +will cause the page on which it occurs to be printed in landscape mode, +i.e. with the top of the page running along the long edge of the paper. +You must specify the command for each page that you want +printed in landscape mode. +\subsection{Graphics} +\label{graph} +You can include graphics in you document with the {\tt import} command. +The syntax of this command is: +\begin{flushleft} +\verb|\special{dvitops: import |{\it filename width height +{\rm[{\it option}\ldots]}}\verb|}| +\end{flushleft} +This option permits you to include a graphic in \ps\ form into the +document. There are three arguments: +{\it filename} is the name of the file containing the graphic, +{\it width} is the desired width of the graphic. +and {\it height} is the desired height of the graphic, +The {\it width} and {\it height} arguments must be specified as dimensions, +that is as a number with an optional decimal point followed by one +of the units of measure recognised by \TeX. The bottom left hand corner +of the graphic will be located at the point where the \verb|\special| +command was issued. +The graphic will be scaled so that it fits into the desired space, +but it will be scaled by the same factor horizontally +and vertically. It will be centred in any surplus +white space. This means that you do not have to know anything about the +dimensions of the graphic to be imported. \dvitops\ gets this +information from the \ps\ file. For example, Figure~\ref{elephant} +\begin{figure}[hbt] +\vspace{2in} +\special{dvitops: import picture.ps \the\textwidth 2in} +\caption{An Elephant} +\label{elephant} +\end{figure} +was produced by the \LaTeX\ commands +\begin{verbatim} +\begin{figure}[hbt] +\vspace{2in} +\special{dvitops: import picture.ps \the\textwidth 2in} +\caption{An Elephant} +\end{figure} +\end{verbatim} +\TeX\ expands \verb|\the\textwidth| to \the\textwidth, which +is the width of the text on the page. Note that the +graphic has been scaled so as to be 2~inches high and has been +centered horizontally with respect to the text. +The file {\tt picture.ps} is the unaltered output of the +Macintosh version of Adobe Illustrator. + +The \ps\ file containing the graphic should comply +with the Encapsulated Postscript Format +(EPSF) standard. EPSF files come in three flavours. The simplest +is just a text file. The first line of such a file will be: +\begin{verbatim} +%!PS-Adobe-2.0 EPSF 1.2 +\end{verbatim} +This is the type of file that \dvitops\ needs. The other two +flavours contain in addition to the \ps\ text a representation +of the image that the \ps\ code will produce; one is intended +for the Macintosh environment, one for the MS-DOS environment. +In order for \dvitops\ successfully to import such a file, the +\ps\ text must be extracted from the file. +A Macintosh EPSF file contains the \ps\ text in its data fork, +and the graphical representation in its resource fork. If such a +file is transferred to another system as a straight +binary (not MacBinary) file, only the contents of the data fork +will in fact be transferred. Thus in order to import a Macintosh +EPSF file into \dvitops\ on another computer, it is only +necessary to transfer the file as a binary file. It may also +be necessary to change the carriage-returns which the Macintosh +uses as its line separator to whatever is used as a line separator +on the computer on which \dvitops\ is running +(carriage-return followed by line feed in MS-DOS, +line-feed in UNIX). +This method has been used successfully to import pictures produced with +Adobe Illustrator, Cricket Draw and Aldus Freehand running on a +Macintosh into \dvitops\ running under MS-DOS. + +\subsection{\ps\ code} +\label{prolog} +\dvitops\ allows you to include your own \ps\ code in a document. +The \ps\ file that is output by \dvitops\ contains two sections: +a prologue and a script. The prologue contains only procedure +definitions and produces no printed output. The script +calls the procedures defined in the prologue to generate the printed +pages. The pages of the script are independent of each other +but dependent on the prologue. \ps\ code that is executed within +the script of the document can only affect the page in which it occurs. +The command +\begin{flushleft} +\verb|\special{dvitops: prolog| {\it filename}\verb|}| +\end{flushleft} +will include {\it filename} in the prologue of the output file; +{\it filename} must contain {\em only} definitions. The command +\begin{flushleft} +\verb|\special{dvitops: inline| {\it anything}\verb|}| +\end{flushleft} +will include {\it anything} in the script of the output file; +{\it anything} should a short piece of \ps\ code +which calls procedures defined in a prologue file. +All the pieces of code from the {\tt inline} commands on a particular +page are held in memory until the end of the page is encountered. +The pieces of code are then output together after all the other output on +the page. The coordinate system in effect is the same as that used by +\TeX: units are scaled points (there are 65536 scaled points in a point); +y coordinates increase down the page; the origin is 1~inch down from +and 1~inch to the right of the upper left hand corner of the page. +Each \verb|\special| command in the {\tt .dvi} file +has an associated position, namely the reference point that would +have been present if a box of height, depth and width zero had appeared +in place of the \verb|\special| command. +\dvitops\ inserts code to move to that position before it outputs +the code from each {\tt inline} command. +(This is what makes the {\tt inline} command useful.) +Note that any definitions +that you make in the code using {\tt inline} commands will only +last until the end of the current page. + +\subsection{Regions} +\dvitops\ allows you to select regions of a page and perform +various operations on them. Regions of the page are selected +using the following specials +\begin{flushleft} +\verb|\special{dvitops: begin |{\it region}\verb|}|\\ +\verb|\special{dvitops: end}| +\end{flushleft} +Anything bracketed between these two commands will be part of the region +called {\it region}; {\it region} can be any alphanumeric string. +Regions cannot be nested; a {\tt begin} +command automatically terminates any previous {\tt begin} command +not already terminated with an {\tt end} command. All regions +are terminated automatically at the end of a page. The same +region can be the subject of more than one {\tt begin} command. +An {\tt end} command must have a preceding {\tt begin} command +on the same page. +Regions can include inline \ps\ and graphics. + +\subsubsection{Transformations} +Once you have selected a region, you can apply a geometrical +transformation to it. +Each transformation is relative to an origin. By default +the origin is \TeX's origin, 1~inch down from and 1~inch to the +right of the upper right hand corner of the page +(unless changed by the {\tt -h} and {\tt -v} options). +This origin can be changed. The command +\begin{flushleft} +\verb|\special{dvitops: origin |{\it region}\verb|}| +\end{flushleft} +makes the current point the origin for {\it region}. +A region can have only one origin. Giving a region an origin +does not alter the position of the region on the page; +it just alters the effect of transformations on that region. +The {\tt origin} command can be given anywhere on the page. + +There are two \verb|\special| commands that perform +transformations: +\begin{flushleft} +\verb|\special{dvitops: rotate |{\it region $\theta$}\verb|}|\\ +\verb|\special{dvitops: transform |{\it region a b c d}\verb|}| +\end{flushleft} +The {\tt transform} command performs the affine transformation +represented by the matrix +\[ \left( \begin{array}{cc} +a &b\\ +c &d\\ +\end{array} \right). \] +The {\tt rotate} command rotates the region about the origin of that +region by $\theta$ degrees in a clockwise direction. It is equivalent +to a {\tt transform} command; it is included because it is inconvenient +to calculate the appropriate transformation matrix for a rotation in \TeX. +Any number of transformations can be applied to a region. They will be +applied in the order in which they are given. +Regions are only affected by transformation commands that appear on the +same page. Apart from this transformation commands can appear at +any point in the document. For example, the following code +\begin{verbatim} +A \special{dvitops: begin example}% +\special{dvitops: origin example}sloping% +\special{dvitops: end} +word. +\special{dvitops: rotate example -30} +\end{verbatim} +will produce +\begin{flushleft} +A \special{dvitops: begin example}% +\special{dvitops: origin example}sloping\special{dvitops: end} word. +\special{dvitops: rotate example -30} +\end{flushleft} +\subsubsection{Color} +You can also choose what color a region should be painted with. +\begin{flushleft} +\verb|\special{dvitops: gray| {\it whiteness}\verb|}|\\ +\verb|\special{dvitops: hsbcolor| {\it hue saturation brightness}\verb|}|\\ +\verb|\special{dvitops: rgbcolor| {\it red green blue}\verb|}| +\end{flushleft} +You should use at most one of these for each region. The arguments must +all be numbers between 0 and 1. A value of 0 for {\it whiteness} +will give black, and a value of 1 white. +You can get interesting effects using the \verb|gray| special. +For example, a macro \verb|\rbox| can be defined like this +\def\rbox#1{% +\leavevmode\setbox0\hbox{\strut#1}\special{dvitops: gray reverse 1}% +\vrule width \wd0 height \ht0 depth \dp0 +\llap{\special{dvitops: begin reverse}\box0\special{dvitops: end}}} +\begin{verbatim} +\def\rbox#1{% + \leavevmode\setbox0\hbox{\strut#1}% + \special{dvitops: gray reverse 1}% + \vrule width \wd0 height \ht0 depth \dp0 + \llap{\special{dvitops: begin reverse}% + \box0 + \special{dvitops: end}}} +\end{verbatim} +Then \verb|\rbox{reverse out}| will produce \rbox{reverse out}. Note +that objects on a page are not necessarily output in the order in +which they occur in the dvi file; in particular, all the text on a page +is output after everything else on the page. + +\section{Errors} +\dvitops\ produces three types of error messages---fatal errors, errors +and warnings. The program will terminate immediately on a fatal error. +Each error message is prefixed by the full pathname of the +\dvitops\ program, followed by a colon and one of +``fatal error'', ``error'' and ``warning.'' +\dvitops\ operates in two passes. On the second pass +\dvitops\ prints an opening bracket followed by the number of a page +just as it is about to start outputting the \ps\ code for that page; +it prints a closing bracket when it's done with a page. +The page number displayed is the values of \verb|\count0| through +\verb|\count9| separated by dots with trailing `.0's suppressed. +\TeX\ does the same. +This enables you to tell on the second pass where \dvitops\ has +encountered the error. + +\end{document} + diff --git a/dviware/dvitops/font.c b/dviware/dvitops/font.c new file mode 100644 index 0000000000..c0d9498cfc --- /dev/null +++ b/dviware/dvitops/font.c @@ -0,0 +1,629 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/font.c,v 1.6 90/03/12 18:47:02 jjc Exp $"; + +#include "dvitops.h" + +#define MAXFONTSIZE (20*1024) /*maximum printer VM that a bitmap font can use*/ + +#ifdef PROTO +static void load_tfm_file(int f); +static void scale_font(int i, FILE *fp); +static void find_font(char *name, FILE *fp); +#if 0 +static void choose_ps_prolog(void); +#endif +static void read_f_directory(void); +static int compare(char *p1, char *p2); +static void choose_mags(void); +static int order_mag(char *p1, char *p2); +static void emit_encodings(FILE *psfp); +#else +static void load_tfm_file(); +static void scale_font(); +static void find_font(); +#if 0 +static void choose_ps_prolog(); +#endif +static void read_f_directory(); +static int compare(); +static void choose_mags(); +static int order_mag(); +static void emit_encodings(); +#endif + + +/* int nprolog_fonts = 2; */ +#define MAGS_MAX 50 + +static struct postscript_f_list *postscript_fonts = NULL; + +static struct f_info { + int no; + enum { BLANK, BITMAP, POSTSCRIPT, BITMAP_PROLOG } type; + int mag; + int same_font; /* index of next font that is the same */ + long doc_chars; /* sum over each page of the number of distinct + characters from the font occurring on that page */ + integer at_size; + integer checksum; + long usage_index; /* the higher this is, the better it is to download + it in the prologue rather than on each page */ + int npages; /* how many pages is it used on */ + char *texname; + char *psname; /* the postscript name */ + char *encoding; /* name of the encoding vector */ + struct postscript_f_list *ps; + char used[MAXCHARS]; /* which characters are used in the document */ + integer width[MAXCHARS]; + integer rounded_width[MAXCHARS]; + char *filename; +} *font[MAXFONTS]; + + + +static int target_mag; + +/* returns -1, 0, or 1 according as *p1 is better, equally good, + or worse as a choice of magnification when the desired + magnification is target_mag +*/ + +static int order_mag(p1, p2) +char *p1, *p2; +{ + int n1 = *(int *)p1; + int n2 = *(int *)p2; + int d1 = abs(target_mag - n1); + int d2 = abs(target_mag - n2); + if (d2 < d1 && d2 <= 2) + return 1; + if (d1 < d2 && d1 <= 2) + return -1; + if (d1 == d2) + return 0; + if (n1 > n2) + return -1; + return 1; +} + + + +static void choose_mags() +{ + int i; + int nmags; + char *p; + static int mag[MAGS_MAX] = {TEXMAGS,0}; + for (i = 0; i < MAGS_MAX && mag[i] != 0; i++) + ; + nmags = i; + if ((p = getenv("TEXMAGS")) != NULL) { + static char sep_string[] = { AREA_LIST_SEP, ',', ':', ' ', '\t', '\0' }; /* be tolerant */ + for (i = 0,p = strtok(p, sep_string); p != NULL && i < MAGS_MAX; p = strtok((char *)NULL, sep_string)) + if ((mag[i] = atoi(p)) > 0) + ++i; + nmags = i; + } + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && font[i]->type != POSTSCRIPT) { + int j; + target_mag = font[i]->mag; + qsort((char *)mag, nmags, sizeof(int), order_mag); + for (j = 0; j < nmags; j++) { + char *p = find_pk_file(font[i]->texname, mag[j]); + if (p != NULL) { + char buf[FILENAME_MAX + 20]; + if (abs(mag[j] - font[i]->mag) > 2) + message(WARNING, + "no exact font for %s at %d dpi", + font[i]->texname, font[i]->mag); + font[i]->mag = mag[j]; + font[i]->type = BITMAP; + sprintf(buf,"%s-%d", font[i]->texname, font[i]->mag); + font[i]->psname = strsave(buf); + font[i]->filename = strsave(p); + break; + } + } + } +} + + +static void read_f_directory() +{ + char buf[512]; + FILE *fp; + int i, j; + if ((fp = xfopen("dvitops.fnt", FALSE, texinputs, (char *)NULL)) == NULL) + message(FATAL_ERROR, "can't find dvitops.fnt"); + while (fgets(buf, 512, fp) != NULL) { + char *ptr, *name, *psname; + char *encoding = NULL; + if ((ptr = strchr(buf, '%')) != NULL) + *ptr = '\0'; + ptr = buf; + while (isspace(*ptr)) + ptr++; + if (*ptr == '\0') + continue; + if ((name = strtok(ptr, " \t\n\r")) == NULL) + continue; + if ((psname = strtok((char *)NULL, " \t\n\r")) == NULL) + psname = name; + else + encoding = strtok((char *)NULL, "\t\n\r"); + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && strcmp(font[i]->texname, name) == 0) { + font[i]->psname = strsave(psname); + font[i]->ps = add_postscript_font(psname); + font[i]->encoding = strsave(encoding); + font[i]->type = POSTSCRIPT; + } + } + choose_mags(); + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && font[i]->type == BLANK) + message(WARNING, + "no font directory entry for %s: using blank space instead\n", + font[i]->texname); + fclose(fp); + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && font[i]->type == POSTSCRIPT) + for (j = i + 1; j < MAXFONTS; j++) + if (font[j] != NULL && font[j]->type == POSTSCRIPT + && strcmp(font[i]->psname, font[j]->psname) == 0) { + font[i]->same_font = j; + break; + } +} + + +static int compare(p1, p2) +char *p1; +char *p2; +{ + return (int)((*(struct f_info **)p2)->usage_index + - (*(struct f_info **)p1)->usage_index); +} + +void f_prologue(fp) +FILE *fp; +{ + struct f_info *p[MAXFONTS]; + int i, j; + integer n; + struct postscript_f_list *q = postscript_fonts; +#if 0 + choose_ps_prolog(); +#endif + emit_encodings(fp); + for (q = postscript_fonts; q != NULL; q = q->next) + if (q->file != NULL && q->in_prolog) { + emit_ps_font(q->s, fp); + find_font(q->s, fp); + } + /* determine the most used bitmapped fonts */ + for (i = j = 0; i < MAXFONTS; i++) { + if (font[i] != NULL && font[i]->type == BITMAP) + p[j++] = font[i]; + if (font[i] != NULL) + font[i]->no = (unsigned char)i; + } + for (i = 0; i < j; i++) { + char *ptr = p[i]->used; + int k; + int nused = 0; + for (k = 0; k < MAXCHARS; k++) + if (ptr[k]) + ++nused; + p[i]->usage_index = p[i]->doc_chars - nused; + } + + qsort((char *)p, j, sizeof(struct f_info *), compare); + n = 0; + /* download and scale the most used bitmapped fonts */ + for (i = 0; i < j && p[i]->usage_index > 0 + && n + MAXFONTSIZE < f_memory; i++) { + int k = p[i]->no; + if (p[i]->type != BITMAP) + continue; + if (!load_pk_font(k, p[i]->filename,p[i]->used,p[i]->at_size, + p[i]->checksum, p[i]->width, p[i]->rounded_width)) { + p[i]->type = BLANK; + continue; + } + n += emit_pk_font(k, p[i]->psname, p[i]->used, fp); + free_pk_font(k); + p[i]->type = BITMAP_PROLOG; + find_font(p[i]->psname, fp); + scale_font(k, fp); + } + /* Load the pk files for the bitmapped fonts + not downloaded in the prologue; + load the tfm files for the bitmapped fonts for which no pk file + could be found, and for the PostScript files */ + for (i = 0; i < MAXFONTS; i++) { + if (font[i] == NULL) + continue; + if (font[i]->type == BITMAP) { + if (!load_pk_font(i, font[i]->filename, + font[i]->used, font[i]->at_size, + font[i]->checksum, font[i]->width, font[i]->rounded_width)) + font[i]->type = BLANK; + } + if (font[i]->type == BLANK || font[i]->type == POSTSCRIPT) { + load_tfm_file(i); + memcpy((char *)font[i]->rounded_width, (char *)font[i]->width, + MAXCHARS*sizeof(integer)); + } + } + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && font[i]->type == POSTSCRIPT + && font[i]->ps->in_prolog == TRUE) + scale_font(i, fp); +} + +static void scale_font(i, fp) +int i; +FILE *fp; +{ + fprintf(fp, "/F%d _%s", i, font[i]->psname); + if (font[i]->encoding != NULL) + fprintf(fp, "_%s", font[i]->encoding); + putc(' ', fp); + put_dim((long)(font[i]->at_size), fp); + fputs(" SF\n", fp); +} + + +static void find_font(name, fp) +char *name; +FILE *fp; +{ + int i; + fprintf(fp, "/_%s /%s FF\n", name, name); + /* reencode all fonts based on it */ + for (i = 0; i < MAXFONTS; i++) + if (font[i] != 0 && font[i]->encoding != 0 + && strcmp(font[i]->psname, name) == 0) { + int j; + for (j = 0; j < i; j++) + if (font[j] != 0 && font[j]->encoding != 0 + && strcmp(font[i]->encoding, font[j]->encoding) == 0 + && strcmp(font[j]->psname, name) == 0) + break; + if (j == i) + /* newdictname newfontname encodingvector basefontdict */ + fprintf(fp, "/_%s_%s /%s_%s %s_encoding _%s RE\n", + name, font[i]->encoding, + name, font[i]->encoding, + font[i]->encoding, + name); + } +} + + +/* we might use the area argument in the future */ +void f_def(fontno, name, area, checksum, at_size, design_size, magnification) +integer fontno; +char *name, *area; +integer checksum, at_size, design_size; +int magnification; +{ + int i; + if (fontno < 0 || fontno > MAXFONTS) + message(FATAL_ERROR, "too many fonts"); + i = (int)fontno; + if (font[i] != NULL) + cant_happen(); + if ((font[i] = (struct f_info *) + calloc(1, sizeof(struct f_info))) == NULL) + out_of_memory(); + font[i]->texname = strsave(name); + font[i]->checksum = checksum; + font[i]->at_size = at_size; + font[i]->mag = (int)(.5 + + ((double)magnification*(double)at_size*(double)dpi) + /(design_size*1000.0)); + font[i]->same_font = EOF; + font[i]->npages = 0; + if ((page_used[i] = (char *)calloc(MAXCHARS, 1)) == NULL) + out_of_memory(); +} + +void store_page_usage() +{ + int i, j; + for (i = 0; i < MAXFONTS; i++) { + char *ptr = page_used[i], *q = font[i]->used; + int used = FALSE; + if (ptr != NULL) + for (j = 0; j < MAXCHARS; j++) + if (ptr[j]) { + q[j] = TRUE; + font[i]->doc_chars++; + ptr[j] = FALSE; + used = TRUE; + } + if (used) + (font[i]->npages)++; + } +} + + + +char *strsave(s) +char *s; +{ + char *p; + if (s == NULL) + return NULL; + if ((p = (char *)malloc(strlen(s) + 1)) == NULL) + out_of_memory(); + strcpy(p, s); + return p; +} + +/* this code is borrowed from sections 571, 572 of TeX the Program */ + +integer scale(x, z) +integer x, z; +{ + integer sw; + integer a, b, c, d; + integer alpha, beta; + alpha = 16*z; beta = 16; + while (z >= 040000000L) { + z /= 2; beta /= 2; + } + d = x & 255; + c = (x >> 8) & 255; + b = (x >> 16) & 255; + a = (x >> 24) & 255; + sw = (((((d * z) / 0400) + (c * z)) / 0400) + (b * z)) / beta; + if ( a == 255) + sw -= alpha; + else if (a != 0) + cant_happen(); + return sw; +} + +static void load_tfm_file(f) +int f; +{ + int i; + int lh, bc, ec, nw; + integer ds, cs; + FILE *tfmfp; + unsigned char width_index[MAXCHARS]; + integer width_table[MAXCHARS]; + if ((tfmfp = xfopen(font[f]->texname, TRUE, texfonts, ".tfm")) == NULL) + message(FATAL_ERROR, "couldn't find tfm file for %s", + font[f]->texname); + (void)sread2(tfmfp); + lh = sread2(tfmfp); + bc = sread2(tfmfp); + ec = sread2(tfmfp); + nw = sread2(tfmfp); + fseek(tfmfp, 14L, 1); + cs = sread4(tfmfp); + if (cs != font[f]->checksum) + message(WARNING, "font %s: checksum in tfm file doesn't match", + font[f]->texname); + ds = sread4(tfmfp); /* not used at the moment */ + lh -= 2; + fseek(tfmfp, (long)lh*4, 1); + for (i = 0; i < ec + 1 - bc; ++i) { + width_index[i] = uread1(tfmfp); + fseek(tfmfp, 3L, 1); + } + for (i = 0; i < nw; ++i) + width_table[i] = scale(sread4(tfmfp), font[f]->at_size); + fclose(tfmfp); +/* Microsoft C 5.0's optimizer messes up this loop */ + for (i = bc; i <= ec; i++) + font[f]->width[i] = width_table[width_index[i - bc]]; +} + +struct postscript_f_list *add_postscript_font(font) +char *font; +{ + struct postscript_f_list *p; + for (p = postscript_fonts;p != NULL; p = p->next) + if (strcmp(font, p->s) == 0) + return p; + if ((p = (struct postscript_f_list *)malloc( + sizeof(struct postscript_f_list)+strlen(font)) + ) == NULL) + out_of_memory(); + strcpy(p->s, font); + p->next = postscript_fonts; + p->file = NULL; + p->in_prolog = FALSE; + p->nuses = 0; + postscript_fonts = p; + return p; +} + +void f_comment(psfp) +FILE *psfp; +{ + int i; + int cols; + struct postscript_f_list *p; + read_f_directory(); + cols = fprintf(psfp, "%%%%DocumentFonts:"); + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && font[i]->doc_chars > 0 + && (font[i]->type == BITMAP || font[i]->type == BITMAP_PROLOG)) { + if (cols + strlen(font[i]->psname) > 70) + cols = fprintf(psfp, "\n%%%%+ %s", font[i]->psname); + else + cols += fprintf(psfp, " %s", font[i]->psname); + } + for (p = postscript_fonts; p != NULL; p = p->next) { + if (cols + strlen(p->s) > 70) + cols = fprintf(psfp, "\n%%%%+ %s",p->s) - 1; + else + cols += fprintf(psfp, " %s", p->s); + } + putc('\n', psfp); + cols = fprintf(psfp, "%%%%DocumentSuppliedFonts:"); + for (i = 0; i < MAXFONTS; i++) + if (font[i] != NULL && font[i]->doc_chars > 0 + && (font[i]->type == BITMAP || font[i]->type == BITMAP_PROLOG)) { + if (cols + strlen(font[i]->psname) > 70) + cols = fprintf(psfp, "\n%%%%+ %s", font[i]->psname); + else + cols += fprintf(psfp, " %s", font[i]->psname); + } + putc('\n', psfp); + cols = fprintf(psfp, "%%%%DocumentNeededFonts:"); + for (p = postscript_fonts; p != NULL; p = p->next) { + if (cols + strlen(p->s) > 70) + cols = fprintf(psfp, "\n%%%%+ %s",p->s) - 1; + else + cols += fprintf(psfp, " %s", p->s); + } + putc('\n', psfp); +} + +void f_emit(i, fp) +int i; +FILE *fp; +{ + if (font[i]->type == BITMAP) { + emit_pk_font(i, font[i]->psname, page_used[i], fp); + find_font(font[i]->psname, fp); + } + else if (font[i]->type == POSTSCRIPT && !font[i]->ps->in_prolog) { + emit_ps_font(font[i]->psname, fp); + find_font(font[i]->psname, fp); + } +} + +void f_set(i, fp) +int i; +FILE *fp; +{ + if (font[i]->type == BITMAP || + (font[i]->type == POSTSCRIPT && !font[i]->ps->in_prolog)) + scale_font(i, fp); + memset(page_used[i], '\0', MAXCHARS); + fprintf(fp, "F%d F\n", i); +} + +void emit_ps_font(font, psfp) +char *font; +FILE *psfp; +{ + fprintf(psfp, "%%%%IncludeFont: %s\n", font); +} + + +int f_is_blank(f) +int f; +{ + return (font[f]->type == BLANK); +} + +integer f_space(f) +int f; +{ + return (font[f]->at_size/6); +} + + +integer f_width(f, c) +int f; +unsigned char c; +{ + return font[f]->width[c]; +} + +integer f_rounded_width(f, c) +int f; +unsigned char c; +{ + return font[f]->rounded_width[c]; +} + +int same_font(f) +int f; +{ + return font[f] == NULL ? EOF : font[f]->same_font; +} + +#if 0 +static void choose_ps_prolog() +{ + int i; + struct postscript_f_list *p, *s; + for (i = 0; i < MAXFONTS; ++i) + if (font[i] != NULL && font[i]->type == POSTSCRIPT) + font[i]->ps->nuses += font[i]->npages; + /* do a list insertion sort */ + s = NULL; + p = postscript_fonts; + while (p != NULL) { + struct postscript_f_list *ss = s, *ssp = NULL, *temp; + while (ss != NULL && p->nuses < ss->nuses) { + ssp = ss; + ss = ss->next; + } + temp = p->next; + if (ssp == NULL) { + p->next = s; + s = p; + } + else { + ssp->next = p; + p->next = ss; + } + p = temp; + } + postscript_fonts = s; + for (p = postscript_fonts, i = 0; p != NULL && i < nprolog_fonts; + p = p->next, i++) + p->in_prolog = TRUE; +} +#endif + +static void emit_encodings(psfp) +FILE *psfp; +{ + int i; + for (i = 0; i < MAXFONTS; i++) + if (font[i] != 0 && font[i]->encoding != NULL) { + int j; + for (j = 0; j < i; j++) + if (font[j] != 0 && font[j]->encoding != 0 + && strcmp(font[j]->encoding, font[i]->encoding) == 0) + break; + if (j == i) { + char name[256]; + FILE *fp = xfopen(font[i]->encoding, FALSE, texfonts, ".enc"); + if (fp == NULL) { + message(FATAL_ERROR, "%s: no encoding file", + font[i]->encoding); + } + fprintf(psfp, "/%s_encoding [\n", + font[i]->encoding); + for (j = 0; j < 256 && fscanf(fp, "%s", name) == 1; j++) + fprintf(psfp, "/%s\n", name); + for (; j < 256; j++) + fputs("/.notdef\n", psfp); + fputs("] def\n", psfp); + } + } +} + +/* +Local Variables: +tab-width: 4 +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +End: +*/ diff --git a/dviware/dvitops/getopt.c b/dviware/dvitops/getopt.c new file mode 100644 index 0000000000..84c8fd5a79 --- /dev/null +++ b/dviware/dvitops/getopt.c @@ -0,0 +1,151 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/getopt.c,v 1.3 90/08/14 13:06:48 jjc Rel $"; + +#include "dvitops.h" + +#ifdef SWITCHAR +#include <dos.h> +#endif + +int opterr = 1; +int optind = 1; +int optopt; +char *optarg; + +#ifndef OPTION_CHAR +#define OPTION_CHAR '-' +#endif + +int getopt(argc, argv, opts) +int argc; +char **argv; +char *opts; +{ +#ifdef SWITCHAR + union REGS regs; + static char switchar = '\0'; +#endif + static int sp = 1; + register int c; + register char *cp; + char *message; +#ifdef SWITCHAR + if (switchar == '\0') { + regs.x.ax = 0x3700; + intdos(®s, ®s); + if (!regs.x.cflag) + switchar = regs.h.dl; + else + switchar = '/'; + } +#endif + if (sp == 1) { + if (optind >= argc) + return EOF; + if (( +#ifdef SWITCHAR + argv[optind][0] != switchar && +#endif + argv[optind][0] != OPTION_CHAR) || argv[optind][1] == '\0') { +#ifdef REORDER_ARGS + int i; + for (i = optind; i < argc; i++) + if (( +#ifdef SWITCHAR + argv[i][0] == switchar || +#endif + argv[i][0] == OPTION_CHAR) && argv[i][1] != '\0') + break; + if (i < argc) { + c = argv[i][1]; +#ifdef CASE_INSENSITIVE_OPTIONS + if (isupper(c)) + c = tolower(c); +#endif + if (c != ':' && c != OPTION_CHAR && (cp = strchr(opts, c)) != NULL + && cp[1] == ':' && argv[i][2] == 0 && i < argc - 1) { + int j; + char *temp1 = argv[i]; + char *temp2 = argv[i+1]; + for (j = i - 1; j >= optind; j--) + argv[j+2] = argv[j]; + argv[optind] = temp1; + argv[optind+1] = temp2; + } + else { + int j; + char *temp = argv[i]; + for (j = i - 1; j >= optind; j--) + argv[j+1] = argv[j]; + argv[optind] = temp; + } + } + else +#endif + return EOF; + } + if ((argv[optind][0] == OPTION_CHAR && argv[optind][1] == OPTION_CHAR + && argv[optind][2] == '\0') +#ifdef SWITCHAR + || (argv[optind][0] == switchar && argv[optind][1] == switchar + && argv[optind][2] == '\0') +#endif + ) { + optind++; + return(EOF); + } + } + optopt = c = argv[optind][sp]; +#ifdef CASE_INSENSITIVE_OPTIONS + if (isascii(c) && isupper(c)) + optopt = c = tolower(c); +#endif + if (c == ':' || (cp = strchr(opts, c)) == NULL) { + if (argv[optind][++sp] == '\0') { + optind++; + sp = 1; + } + message = ": illegal option -- "; + goto bad; + } + if (*++cp == ':') { + if (argv[optind][sp+1] != '\0') + optarg = &argv[optind++][sp+1]; + else if (++optind >= argc) { + sp = 1; + message = ": option requires an argument -- "; + goto bad; + } + else + optarg = argv[optind++]; + sp = 1; + } + else { + if (argv[optind][++sp] == '\0') { + sp = 1; + optind++; + } + optarg = NULL; + } + return c; +bad: + if (opterr) { + fputs(argv[0], stderr); + fputs(message, stderr); + fputc(optopt, stderr); + fputc('\n', stderr); + } + return '?'; +} + + +/* +Local Variables: +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: 4 +c-argdecl-indent: 4 +c-label-offset: -4 +tab-width: 4 +End: +*/ + diff --git a/dviware/dvitops/install b/dviware/dvitops/install new file mode 100644 index 0000000000..2113955255 --- /dev/null +++ b/dviware/dvitops/install @@ -0,0 +1,42 @@ +How to install dvitops +---------------------- + +1. Copy unix.h, msdos.h, vms.h, cms.h or primos.h to config.h according +as your OS is UNIX, MS-DOS, VMS, VM/CMS, or PRIMOS. Then edit config.h. +The file config.doc explains what all the various defines mean. + +2. Edit Makefile. + +3. Do a make (or make makefile.ms if you're using Microsoft make). + +4. Edit dvitops.fnt. This should contain a list of all PostScript fonts +that you have available. If you have a file-system that does not permit +you to use the PostScript names of the fonts as the file names of your +tfm files, you must add the apporpriate file name to the beginning of each +line. For example, change the line + +Times-Roman + +to + +timesr Times-Roman + +5. Do a make install. If you're using MS-DOS, you'll have to install +by hand. + +6. Print out and read the manual. + +If you have any problems, don't hesitate to contact me. + +Good luck! + +James Clark + +jjc@jclark.uucp +ukc.ac.uk!jclark!jjc + +30 Peel Street +London W8 7PD +England + +$Header: /usr/jjc/dvitops/RCS/INSTALL,v 1.3 90/08/14 13:01:37 jjc Rel $ diff --git a/dviware/dvitops/main.c b/dviware/dvitops/main.c new file mode 100644 index 0000000000..5deb24c869 --- /dev/null +++ b/dviware/dvitops/main.c @@ -0,0 +1,269 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/main.c,v 1.8 90/08/14 13:10:37 jjc Rel $"; + +#include "dvitops.h" + +char *texfonts = TEXFONTS; +char *texinputs = TEXINPUTS; +char *texpk = TEXPK; +int dpi = DPI; +char *page_used[MAXFONTS]; +long f_memory = 200*1024L; +/* each region has a number which indexes into the `region' vector */ +/* the default region is `NO_REGION', and doesn't have an entry */ + +int current_region = NO_REGION; +int nregions = 0; +int quiet = FALSE; + +#ifdef PROTO +static void usage(void); +#else +static void usage(); +#endif + +#ifdef PROTO +static char **newargv(char **argv, int *argcp); +#else +static char **newargv(); +#endif + +char *program_name; + +void main(argc, argv) +int argc; +char *argv[]; +{ + int c; + int i; + char *ptr; +#ifndef HAVE_REDIRECTION + FILE *ofp; +#endif + FILE *fp; + struct option_info option; + int exit_code; + program_name = argv[0]; + opterr = 0; /* disable message from getopt */ + option.mag = 0; /* specified by default in dvi file */ + option.voffset = option.hoffset = 72.0; /* 1in in PostScript points */ + option.reverse = 0; + option.maxpages = INT_MAX; + option.copies = 1; + option.sort = FALSE; + option.paper = PAPER; + if ((ptr = getenv("TEXINPUTS")) != NULL) + texinputs = ptr; + if ((ptr = getenv("TEXFONTS")) != NULL) + texfonts = ptr; + if ((ptr = getenv("TEXPK")) != NULL) + texpk = ptr; + for (i = 0; i < 10; i++) + option.start_page[i] = WILD; + argv = newargv(argv, &argc); + while ((c = getopt(argc, argv, "qf:y:c:m:rp:n:sh:v:d:")) != EOF) + switch (c) { + case 'q': + quiet = TRUE; + break; + case 'p': + option.paper = optarg; + break; + case 'y': + f_memory = atol(optarg)*1024L; + break; + case 'c': + option.copies = atoi(optarg); + if (option.copies == 0) + option.copies = 1; + break; + case 'm': + option.mag = atoi(optarg); + if (option.mag <= 0) { + message(ERROR, "bad magnification: using 1000 instead"); + option.mag = 1000; + } + break; + case 'r': + option.reverse = !option.reverse; + break; + case 'f': + ptr = optarg; + for (i = 0; i < 10 && *ptr != '\0'; i++) { + if (*ptr == '*') { + option.start_page[i] = WILD; + ++ptr; + } + else { + option.start_page[i] = atol(ptr); + if (*ptr == '+' || *ptr == '-') + ++ptr; + while (isdigit(*ptr)) + ptr++; + } + if (*ptr == '.') + ++ptr; + else if (*ptr == '\0') + break; + else + usage(); + } + break; + case 'n': + option.maxpages = atoi(optarg); + break; + case 's': + option.sort = TRUE; + break; + case 'h': + if (bigpoint(optarg, (char **)NULL,&option.hoffset) == 0) + usage(); + break; + case 'v': + if (bigpoint(optarg, (char **)NULL, &option.voffset) == 0) + usage(); + break; + case 'd': + dpi = atoi(optarg); + break; + case '?': + usage(); + default: + cant_happen(); + } + if (argc - optind == 1) { +#ifndef HAVE_REDIRECTION + int len; + char ofilename[FILENAME_MAX+1]; +#endif + if ((fp = xfopen(argv[optind], TRUE, (char *)NULL, ".dvi")) == NULL) + message(FATAL_ERROR, "can't find %s", argv[optind]); +#ifndef HAVE_REDIRECTION + len = strlen(argv[optind]); + if (len >= 4 && +#ifdef CASE_INSENSITIVE_FILENAMES + stricmp(argv[optind] - 4, ".dvi") == 0 +#else + strcmp(argv[optind] - 4, ".dvi") == 0 +#endif + ) { + if (len < FILENAME_MAX) { + strcpy(ofilename, argv[optind]); + strcpy(ofilename + len - 3, "ps"); + } + else + message(FATAL_ERROR, "input filename `%s' too long", argv[optind]); + } + else if (len <= FILENAME_MAX - 3) { + strcpy(ofilename, argv[optind]); + strcpy(ofilename + len, ".ps"); + } + else + message(FATAL_ERROR, "input filename `%s' too long", argv[optind]); + if ((ofp = fopen(ofilename, "w")) == NULL) + message(FATAL_ERROR, "can't open `%s' for output", ofilename); +#endif + } +#ifdef HAVE_REDIRECTION + else if (argc == optind) { +#ifdef HAVE_ISATTY + if (isatty(fileno(stdin))) + message(FATAL_ERROR, "can't seek on standard input"); +#endif + fp = stdin; + } +#endif + else + usage(); +#ifdef HAVE_SETVBUF + setvbuf(fp, (char *)NULL, _IOFBF, 16384); /* ignore any error */ +#endif + read_dvi_file(fp, +#ifdef HAVE_REDIRECTION + stdout, +#else + ofp, +#endif + &option); + switch (history) { + case INFORMATION: + exit_code = NORMAL_EXIT_CODE; + break; + case WARNING: + exit_code = WARNING_EXIT_CODE; + break; + case ERROR: + exit_code = ERROR_EXIT_CODE; + break; + case FATAL_ERROR: + exit_code = FATAL_ERROR_EXIT_CODE; + break; + default: + cant_happen(); + break; + } + exit(exit_code); +} + +/* this looks for an environmental variable called DVITOPS + and types it into the command line */ + +#define MAXARGS 256 + +static char **newargv(argv, argcp) +char **argv; +int *argcp; +{ + char **p; + int i; + int argc = 0; + char *s, *env; + if ((s = getenv("DVITOPS")) == NULL) + return argv; + if ((env = (char *)malloc(strlen(s) + 1)) == NULL) + out_of_memory(); + if ((p = (char **)malloc(sizeof(char *)*MAXARGS)) == NULL) + out_of_memory(); + strcpy(env, s); + p[argc++] = argv[0]; + s = strtok(env, " \t"); + while (s != NULL && argc < MAXARGS) { + p[argc++] = s; + s = strtok((char *)NULL, " \t"); + } + for (i = 1; i < *argcp && argc < MAXARGS; i++) + p[argc++] = argv[i]; + if (argc == MAXARGS) { + message(ERROR, "too many arguments in environment variable DVITOPS"); + return argv; + } + p[argc] = NULL; + *argcp = argc; + return p; +} + + +static void usage() +{ + message(FATAL_ERROR, +#ifdef HAVE_REDIRECTION + "command line error: usage:\n\ +dvitops [-qrs] [-c ncopies] [-f firstpage] [-n npages] [-m magnification]\n\ + [-y kmem] [-h hoffset] [-v voffset] [-p papersize] [-d dpi] [dvifile]" +#else + "command line error: usage:\n\ +dvitops [-Vqrs] [-c ncopies] [-f firstpage] [-n npages] [-m magnification]\n\ + [-y kmem] [-h hoffset] [-v voffset] [-p papersize] [-d dpi] dvifile" +#endif + ); +} + +/* +Local Variables: +tab-width: 4 +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +End: +*/ diff --git a/dviware/dvitops/makefile b/dviware/dvitops/makefile new file mode 100644 index 0000000000..f415f5ff72 --- /dev/null +++ b/dviware/dvitops/makefile @@ -0,0 +1,78 @@ +# $Header: /usr/jjc/dvitops/RCS/Makefile,v 1.13 90/08/14 13:26:13 jjc Rel $ +BINDIR=/usr/local/bin +INPUTDIR=/usr/local/tex/inputs +FONTDIR=/usr/local/tex/fonts +MANDIR=/usr/local/man/man1 +MANEXT=1 +PSFONTDIR=/usr/local/psfonts +CFLAGS=-g +CC=cc +LIBS=-lm +COMPRESSFLAGS= + +OBJECTS=main.o code.o read.o special.o pk.o font.o dvi.o util.o getopt.o tpic.o +SOURCES=main.c code.c read.c special.c pk.c font.c dvi.c util.c \ + getopt.c tpic.c dvitops.h util.h config.h \ + msdos.h unix.h primos.h vms.h cms.h +INPUTS=dvitops.pro dvitops.fnt ps.sty pspict.ps +TFMS=timessl.tfm timessc.tfm timesex.tfm symbolsl.tfm +FONTS=psfonts.map timessc.ps timessl.ps timesex.ps symbolsl.ps +FILES=README INSTALL config.doc dvitops.1 aftopl.1 psfont.1 dvitops.tex \ +picture.ps timessc.afm timessl.afm timessc.ps timessl.ps timesex.ps \ +timesex.pl symbolsl.ps symbolsl.afm ps.sty printafm.ps tex.enc \ +Makefile makefile.ms dvitops.pro dvitops.fnt psfonts.map \ +unix.h primos.h msdos.h vms.h cms.h \ +dvitops.h util.h main.c font.c dvi.c pk.c special.c tpic.c util.c getopt.c \ +read.c code.c aftopl.c psfont.c pfbtops.c pspict.sty pspict.ps + +all : dvitops psfont aftopl pfbtops + +dvitops : $(OBJECTS) + $(CC) $(CFLAGS) -o dvitops $(OBJECTS) $(LIBS) + +psfont : psfont.o util.o + $(CC) $(CFLAGS) -o psfont psfont.o util.o + +aftopl : aftopl.o util.o + $(CC) $(CFLAGS) -o aftopl aftopl.o util.o -lm + +pfbtops : pfbtops.o util.o + $(CC) $(CFLAGS) -o pfbtops pfbtops.o util.o -lm + +psfont.o aftopl.o pfbtops.o : util.h config.h + +$(OBJECTS) : dvitops.h util.h config.h + +.SUFFIXES: .pl .tfm .afm + +.pl.tfm : + pltotf $< $@ + +.afm.pl : + aftopl $< + +timessl.tfm : timessl.pl +timessc.tfm : timessc.pl +timesex.tfm : timesex.pl +symbolsl.tfm : symbolsl.pl + +timessl.pl timessc.pl symbolsl.pl : aftopl + +clean: + -rm -f *.o *~ dvitops psfont aftopl pfbtops core dvitops.log \ + TAGS dvitops.tar.Z *.tfm symbolsl.pl timessl.pl timessc.pl + +install: all $(TFMS) $(FILES) + cp dvitops psfont aftopl pfbtops $(BINDIR) + cp $(FONTS) $(PSFONTDIR) + cp $(INPUTS) $(INPUTDIR) + cp $(TFMS) $(FONTDIR) + cp aftopl.1 $(MANDIR)/aftopl.$(MANEXT) + cp psfont.1 $(MANDIR)/psfont.$(MANEXT) + cp dvitops.1 $(MANDIR)/dvitops.$(MANEXT) + +TAGS: $(SOURCES) + etags $(SOURCES) + +dvitops.tar.Z : $(FILES) + tar cf - $(FILES) | compress $(COMPRESSFLAGS) >$@ diff --git a/dviware/dvitops/makefile.dist b/dviware/dvitops/makefile.dist new file mode 100644 index 0000000000..f415f5ff72 --- /dev/null +++ b/dviware/dvitops/makefile.dist @@ -0,0 +1,78 @@ +# $Header: /usr/jjc/dvitops/RCS/Makefile,v 1.13 90/08/14 13:26:13 jjc Rel $ +BINDIR=/usr/local/bin +INPUTDIR=/usr/local/tex/inputs +FONTDIR=/usr/local/tex/fonts +MANDIR=/usr/local/man/man1 +MANEXT=1 +PSFONTDIR=/usr/local/psfonts +CFLAGS=-g +CC=cc +LIBS=-lm +COMPRESSFLAGS= + +OBJECTS=main.o code.o read.o special.o pk.o font.o dvi.o util.o getopt.o tpic.o +SOURCES=main.c code.c read.c special.c pk.c font.c dvi.c util.c \ + getopt.c tpic.c dvitops.h util.h config.h \ + msdos.h unix.h primos.h vms.h cms.h +INPUTS=dvitops.pro dvitops.fnt ps.sty pspict.ps +TFMS=timessl.tfm timessc.tfm timesex.tfm symbolsl.tfm +FONTS=psfonts.map timessc.ps timessl.ps timesex.ps symbolsl.ps +FILES=README INSTALL config.doc dvitops.1 aftopl.1 psfont.1 dvitops.tex \ +picture.ps timessc.afm timessl.afm timessc.ps timessl.ps timesex.ps \ +timesex.pl symbolsl.ps symbolsl.afm ps.sty printafm.ps tex.enc \ +Makefile makefile.ms dvitops.pro dvitops.fnt psfonts.map \ +unix.h primos.h msdos.h vms.h cms.h \ +dvitops.h util.h main.c font.c dvi.c pk.c special.c tpic.c util.c getopt.c \ +read.c code.c aftopl.c psfont.c pfbtops.c pspict.sty pspict.ps + +all : dvitops psfont aftopl pfbtops + +dvitops : $(OBJECTS) + $(CC) $(CFLAGS) -o dvitops $(OBJECTS) $(LIBS) + +psfont : psfont.o util.o + $(CC) $(CFLAGS) -o psfont psfont.o util.o + +aftopl : aftopl.o util.o + $(CC) $(CFLAGS) -o aftopl aftopl.o util.o -lm + +pfbtops : pfbtops.o util.o + $(CC) $(CFLAGS) -o pfbtops pfbtops.o util.o -lm + +psfont.o aftopl.o pfbtops.o : util.h config.h + +$(OBJECTS) : dvitops.h util.h config.h + +.SUFFIXES: .pl .tfm .afm + +.pl.tfm : + pltotf $< $@ + +.afm.pl : + aftopl $< + +timessl.tfm : timessl.pl +timessc.tfm : timessc.pl +timesex.tfm : timesex.pl +symbolsl.tfm : symbolsl.pl + +timessl.pl timessc.pl symbolsl.pl : aftopl + +clean: + -rm -f *.o *~ dvitops psfont aftopl pfbtops core dvitops.log \ + TAGS dvitops.tar.Z *.tfm symbolsl.pl timessl.pl timessc.pl + +install: all $(TFMS) $(FILES) + cp dvitops psfont aftopl pfbtops $(BINDIR) + cp $(FONTS) $(PSFONTDIR) + cp $(INPUTS) $(INPUTDIR) + cp $(TFMS) $(FONTDIR) + cp aftopl.1 $(MANDIR)/aftopl.$(MANEXT) + cp psfont.1 $(MANDIR)/psfont.$(MANEXT) + cp dvitops.1 $(MANDIR)/dvitops.$(MANEXT) + +TAGS: $(SOURCES) + etags $(SOURCES) + +dvitops.tar.Z : $(FILES) + tar cf - $(FILES) | compress $(COMPRESSFLAGS) >$@ diff --git a/dviware/dvitops/makefile.ms b/dviware/dvitops/makefile.ms new file mode 100644 index 0000000000..8f20340a12 --- /dev/null +++ b/dviware/dvitops/makefile.ms @@ -0,0 +1,51 @@ +# $Header: /usr/jjc/dvitops/RCS/makefile.ms,v 1.3 89/02/22 14:51:52 jjc Rel $ +# makefile for Microsoft make and Microsoft C v5.1 +CC=cl +MODEL=C +STACKSIZE=5000 +FP=i +OPTIMISATIONS=x +CFLAGS=/A$(MODEL) /O$(OPTIMISATIONS) /Za /FP$(FP) +LDFLAGS=/Fm /F $(STACKSIZE) /FP$(FP) +OBJECTS=main.obj getopt.obj code.obj read.obj special.obj \ +pk.obj font.obj dvi.obj util.obj + +.c.obj : + $(CC) $(CFLAGS) /c $*.c + +main.obj : main.c dvitops.h util.h config.h + +code.obj : code.c dvitops.h util.h config.h + +read.obj : read.c dvitops.h util.h config.h + +special.obj : special.c dvitops.h util.h config.h + +pk.obj : pk.c dvitops.h util.h config.h + +font.obj : font.c dvitops.h util.h config.h + +dvi.obj : dvi.c dvitops.h util.h config.h + +util.obj : util.c util.h config.h + +getopt.obj : getopt.c dvitops.h util.h config.h + +dvitops.exe : $(OBJECTS) + $(CC) $(LDFLAGS) /Fedvitops $(OBJECTS) + +psfont.obj : psfont.c util.h config.h + +aftopl.obj : aftopl.c util.h config.h + +pfbtops.obj : pfbtops.c util.h config.h + +psfont.exe : psfont.obj util.obj + $(CC) $(LDFLAGS) /Fepsfont.exe psfont.obj util.obj + +aftopl.exe : aftopl.obj util.obj getopt.obj + $(CC) $(LDFLAGS) /Feaftopl.exe aftopl.obj util.obj getopt.obj + +pfbtops.exe : pfbtops.obj util.obj + $(CC) $(LDFLAGS) /Fepfbtops.exe pfbtops.obj util.obj + diff --git a/dviware/dvitops/msdos.h b/dviware/dvitops/msdos.h new file mode 100644 index 0000000000..53f1fdfed2 --- /dev/null +++ b/dviware/dvitops/msdos.h @@ -0,0 +1,50 @@ +/* $Header: /usr/jjc/dvitops/RCS/msdos.h,v 1.2 90/08/17 15:55:17 jjc Exp $ */ +/* Support for MS-DOS */ + +#define PAPER "a4" + +#define TEXFONTS ".;\\tex\\fonts" +#define TEXINPUTS ".;\\tex\\inputs" +#define TEXPK "%f.%d;c:\\texpixel\\cmpixel\\canon300\\dpi%d\\%f.pk" +#define TEXMAGS 214,240,257,270,300,329,360,432,518,622,746,896,1075,1290 +#define PSFONTS ".;C:\\psfonts" +#define HAVE_REDIRECTION +#define HAVE_SETVBUF +#define FOPEN_RB(file) (fopen((file), "rb")) +#define DPI 300 +#define FILENAME_MAX 80 +#define AREA_LIST_SEP ';' +#define AREA_SEP '\\' +#define AREA_SEP2 ':' +#define FILENAME_HAS_AREA(f) ((f)[0] == '\\' \ + || (isalpha((f)[0]) && (f)[1] == ':')) +#define CASE_INSENSITIVE_FILENAMES +#define REORDER_ARGS +#define CASE_INSENSITIVE_OPTIONS + +#define MAXFONTS 256 +#define HAVE_ISATTY + +#ifdef __STDC__ + +#define PROTO +/* #define BROKEN_PROTO */ +#define HAVE_SETVBUF +#define STDARG +#include <limits.h> +#include <stddef.h> +#else +#define UCHAR_MAX 255 +#define USHRT_MAX 0xffff +#define SHRT_MAX 32767 +#define UINT_MAX 0xffff +#define INT_MAX 32767 +#define LONG_MAX 2147483647L + +#define const +typedef unsigned long size_t; +typedef long time_t; + +#endif /* __STDC__ */ + +#define SWITCHAR diff --git a/dviware/dvitops/pfbtops.c b/dviware/dvitops/pfbtops.c new file mode 100644 index 0000000000..dd76b81abc --- /dev/null +++ b/dviware/dvitops/pfbtops.c @@ -0,0 +1,91 @@ +/* this translates Adobe fonts in IBM PC format (.pfb) to plain PostScript */ + +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/pfbtops.c,v 1.2 90/08/14 13:04:24 jjc Rel $"; + +#include "util.h" + +char *program_name = "pfbtops"; + +int main(argc, argv) +int argc; +char **argv; +{ + int c; + int err; + FILE *fp, *outfp; + char filename[FILENAME_MAX]; + if (argc < 2 || argc > 3) + message(FATAL_ERROR, "usage: pfbtops pfbfile [psfile]"); + if (strlen(filename) > FILENAME_MAX - 5) + message(FATAL_ERROR, "file name too long"); + strcpy(filename, argv[1]); + if (strchr(filename, '.') == NULL) + strcat(filename, ".pfb"); + if ((fp = FOPEN_RB(filename)) == NULL) + message(FATAL_ERROR, "can't open %s", filename); + if (argc == 3) { + if (strlen(filename) > FILENAME_MAX - 5) + message(FATAL_ERROR, "filename too long"); + strcpy(filename, argv[2]); + if (strchr(filename, '.') == NULL) + strcat(filename, ".ps"); + } + else + strcpy(strchr(filename, '.'), ".ps"); + if ((outfp = fopen(filename, "w")) == NULL) + message(FATAL_ERROR, "can't open %s", filename); + for (;;) { + long n; + c = getc(fp); + if (c != 128) + goto bad; + c = getc(fp); + if (c == 3) { + (void)getc(fp); + if (!feof(fp) || ferror(fp)) + goto bad; + fclose(fp); + break; + } + n = (unsigned long)getc(fp); + n |= (unsigned long)getc(fp) << 8; + n |= (unsigned long)getc(fp) << 16; + n |= (unsigned long)getc(fp) << 24; + if (n < 0) + { err =1; goto bad;} + if (c == 1) { + while (n--) { + c = getc(fp); + if (c == '\r') + putc('\n', outfp); + else + putc(c, outfp); + } + if (ferror(fp) || feof(fp)) + { err = 2; goto bad;} + } + else if (c == 2) { + int cols = 0; + putc('\n', outfp); + while (n--) { + static char hexdigits[] = "0123456789ABCDEF"; + c = getc(fp); + if ((cols += 2) > 70) { + putc('\n', outfp); + cols = 0; + } + putc(hexdigits[(unsigned)c >> 4], outfp); + putc(hexdigits[c & 15], outfp); + } + putc('\n', outfp); + if (ferror(fp) || feof(fp)) + {err = 3 ; goto bad;} + } + else + {err = 4 ; goto bad;} + } + exit(history); +bad: + fprintf(stderr,"Error: %d\n",err); + message(FATAL_ERROR, "bad font file"); +} diff --git a/dviware/dvitops/picture.ps b/dviware/dvitops/picture.ps new file mode 100644 index 0000000000..861d9bb5a5 --- /dev/null +++ b/dviware/dvitops/picture.ps @@ -0,0 +1,639 @@ +%!PS-Adobe-2.0 EPSF-1.2 +%%Creator:Adobe Illustrator(TM) 1.1 0000000000 +%%For: +%%Title:elephant.ps +%%CreationDate:25/4/88 7:57 pm +%%DocumentProcSets:Adobe_Illustrator_1.1 0 0 +%%DocumentSuppliedProcSets:Adobe_Illustrator_1.1 0 0 +%%DocumentFonts:Courier +%%BoundingBox:40 -505 507 -87 +%%TemplateBox:0 -720 576 0 +%%EndComments +%%BeginProcSet:Adobe_Illustrator_1.1 0 0 +% Copyright (C) 1987 Adobe Systems Incorporated. +% All Rights Reserved. +% Adobe Illustrator is a trademark of Adobe Systems Incorporated. +/Adobe_Illustrator_1.1 dup 100 dict def load begin +/Version 0 def +/Revision 0 def +% definition operators +/bdef {bind def} bind def +/ldef {load def} bdef +/xdef {exch def} bdef +% graphic state operators +/_K {3 index add neg dup 0 lt {pop 0} if 3 1 roll} bdef +/_k /setcmybcolor where +{/setcmybcolor get} {{1 sub 4 1 roll _K _K _K setrgbcolor pop} bind} ifelse def +/g {/_b xdef /p {_b setgray} def} bdef +/G {/_B xdef /P {_B setgray} def} bdef +/k {/_b xdef /_y xdef /_m xdef /_c xdef /p {_c _m _y _b _k} def} bdef +/K {/_B xdef /_Y xdef /_M xdef /_C xdef /P {_C _M _Y _B _k} def} bdef +/d /setdash ldef +/_i currentflat def +/i {dup 0 eq {pop _i} if setflat} bdef +/j /setlinejoin ldef +/J /setlinecap ldef +/M /setmiterlimit ldef +/w /setlinewidth ldef +% path construction operators +/_R {.25 sub round .25 add} bdef +/_r {transform _R exch _R exch itransform} bdef +/c {_r curveto} bdef +/C /c ldef +/v {currentpoint 6 2 roll _r curveto} bdef +/V /v ldef +/y {_r 2 copy curveto} bdef +/Y /y ldef +/l {_r lineto} bdef +/L /l ldef +/m {_r moveto} bdef +% error operators +/_e [] def +/_E {_e length 0 ne {gsave 0 g 0 G 0 i 0 J 0 j 1 w 10 M [] 0 d +/Courier 20 0 0 1 z [0.966 0.259 -0.259 0.966 +_e 0 get _e 2 get add 2 div _e 1 get _e 3 get add 2 div] e _f t T grestore} if} bdef +/_fill {{fill} stopped +{/_e [pathbbox] def /_f (ERROR: can't fill, increase flatness) def n _E} if} bdef +/_stroke {{stroke} stopped +{/_e [pathbbox] def /_f (ERROR: can't stroke, increase flatness) def n _E} if} bdef +% path painting operators +/n /newpath ldef +/N /n ldef +/F {p _fill} bdef +/f {closepath F} bdef +/S {P _stroke} bdef +/s {closepath S} bdef +/B {gsave F grestore S} bdef +/b {closepath B} bdef +% text block construction and painting operators +/_s /ashow ldef +/_S {(?) exch {2 copy 0 exch put pop dup false charpath currentpoint _g setmatrix +_stroke _G setmatrix moveto 3 copy pop rmoveto} forall pop pop pop n} bdef +/_A {_a moveto _t exch 0 exch} bdef +/_L {0 _l neg translate _G currentmatrix pop} bdef +/_w {dup stringwidth exch 3 -1 roll length 1 sub _t mul add exch} bdef +/_z [{0 0} bind {dup _w exch neg 2 div exch neg 2 div} bind {dup _w exch neg exch neg} bind] def +/z {_z exch get /_a xdef /_t xdef /_l xdef exch findfont exch scalefont setfont} bdef +/_g matrix def +/_G matrix def +/_D {_g currentmatrix pop gsave concat _G currentmatrix pop} bdef +/e {_D p /t {_A _s _L} def} bdef +/r {_D P /t {_A _S _L} def} bdef +/a {_D /t {dup p _A _s P _A _S _L} def} bdef +/o {_D /t {pop _L} def} bdef +/T {grestore} bdef +% group construction operators +/u {} bdef +/U {} bdef +% font construction operators +/Z {findfont begin currentdict dup length dict begin +{1 index /FID ne {def} {pop pop} ifelse} forall /FontName exch def dup length 0 ne +{/Encoding Encoding 256 array copy def 0 exch {dup type /nametype eq +{Encoding 2 index 2 index put pop 1 add} {exch pop} ifelse} forall} if pop +currentdict dup end end /FontName get exch definefont pop} bdef +end +%%EndProcSet +%%EndProlog +%%BeginSetup +Adobe_Illustrator_1.1 begin +n +%%EndSetup +0 g +0 G +1 i +0 J +0 j +0.7 w +10 M +[]0 d +%%Note: +90.632 -245.419 m +86.134 -229.425 95.131 -228.926 96.63 -221.429 c +98.129 -213.932 107.126 -212.932 109.125 -202.936 c +111.124 -192.94 119.121 -183.944 125.618 -176.947 c +132.116 -169.949 146.61 -163.952 156.106 -168.45 c +165.602 -172.948 169.102 -174.947 178.598 -176.447 c +188.094 -177.946 195.591 -179.945 208.086 -176.947 c +220.581 -173.948 226.578 -171.949 237.074 -172.948 c +247.569 -173.948 277.557 -172.948 290.052 -171.949 c +302.547 -170.949 335.034 -171.449 345.53 -171.449 c +356.026 -171.449 374.019 -177.446 388.012 -182.444 c +402.006 -187.442 426.996 -197.438 439.491 -204.435 c +451.986 -211.433 469.979 -230.425 479.476 -238.422 c +488.972 -246.418 497.969 -243.42 499.968 -278.905 c +501.967 -314.39 499.968 -334.882 498.968 -346.377 c +497.969 -357.872 492.971 -371.367 491.971 -382.862 c +490.971 -394.358 490.971 -399.356 490.971 -410.851 c +490.971 -422.346 490.971 -433.342 492.471 -442.338 c +493.97 -451.336 494.47 -457.333 494.97 -461.332 c +495.47 -465.33 491.971 -464.83 489.472 -465.83 c +486.973 -466.829 483.474 -462.331 481.975 -458.333 c +480.476 -454.334 481.475 -444.837 481.475 -441.339 c +481.475 -437.84 483.474 -434.841 483.974 -427.844 c +484.474 -420.847 485.474 -386.861 482.975 -378.364 c +480.476 -369.868 484.974 -364.37 485.973 -354.374 c +486.973 -344.378 491.971 -311.391 489.972 -308.392 c +487.973 -305.394 484.474 -327.885 478.475 -333.882 c +472.478 -339.88 471.478 -346.377 471.478 -351.875 c +471.478 -357.373 467.48 -363.37 464.981 -365.869 c +462.482 -368.368 461.982 -374.366 457.984 -380.863 c +453.985 -387.36 450.987 -394.857 450.487 -402.854 c +449.987 -410.851 451.486 -436.341 450.487 -440.839 c +449.487 -445.337 447.988 -447.836 446.988 -448.836 c +445.989 -449.835 451.486 -448.336 451.486 -453.835 c +451.486 -459.332 449.987 -459.832 449.487 -468.329 c +448.987 -476.825 447.488 -479.324 447.488 -484.322 c +447.488 -489.32 447.488 -495.318 445.489 -495.818 c +443.49 -496.317 437.492 -498.317 433.494 -498.816 c +429.495 -499.316 420.999 -499.816 419.999 -499.316 c +419 -498.816 419.499 -495.318 420.999 -494.318 c +422.498 -493.319 424.746 -490.011 y +417.5 -495.818 415.501 -496.817 v +413.502 -497.817 410.003 -499.816 407.004 -499.316 c +404.006 -498.816 402.506 -498.317 401.507 -496.817 c +400.507 -495.318 397.508 -496.817 394.509 -494.818 c +391.511 -492.819 392.01 -490.82 393.01 -489.32 c +394.01 -487.821 399.507 -482.323 y +394.01 -483.323 392.51 -483.323 v +391.011 -483.323 377.017 -484.322 374.019 -484.322 c +371.02 -484.322 364.023 -485.322 363.023 -484.822 c +362.024 -484.322 361.024 -483.323 361.024 -482.823 c +361.024 -482.323 356.526 -482.823 356.026 -482.823 c +355.526 -482.823 353.027 -480.324 353.527 -479.324 c +354.027 -478.325 357.525 -473.327 359.525 -471.827 c +361.524 -470.328 365.022 -466.329 368.021 -465.33 c +371.02 -464.33 371.52 -459.832 373.019 -457.333 c +374.518 -454.834 375.018 -451.336 375.518 -447.836 c +376.018 -444.337 377.017 -433.342 377.017 -427.844 c +377.017 -422.346 379.516 -406.353 382.015 -399.356 c +384.514 -392.358 386.514 -386.861 385.514 -381.363 c +384.514 -375.865 381.016 -368.368 381.016 -366.369 c +381.016 -364.37 381.016 -358.872 y +377.517 -358.872 371.02 -361.371 v +364.523 -363.87 348.529 -368.368 342.531 -367.369 c +336.534 -366.369 308.044 -365.369 306.545 -362.371 c +305.046 -359.372 289.552 -353.374 289.052 -352.874 c +288.552 -352.375 288.052 -359.872 289.552 -367.369 c +291.051 -374.866 292.551 -382.362 294.55 -389.36 c +296.549 -396.357 298.548 -425.345 300.048 -433.842 c +301.547 -442.338 307.545 -449.335 310.044 -453.335 c +312.542 -457.333 313.542 -460.332 313.042 -464.83 c +312.542 -469.328 311.043 -475.326 310.543 -477.825 c +310.044 -480.324 306.045 -484.322 303.046 -483.822 c +300.048 -483.323 291.051 -480.824 289.552 -481.323 c +288.052 -481.823 285.054 -485.322 284.054 -485.822 c +283.055 -486.321 277.557 -486.321 274.558 -487.321 c +271.559 -488.321 263.063 -489.82 261.563 -488.321 c +260.064 -486.821 262.063 -493.319 249.568 -491.319 c +246.078 -490.761 239.072 -491.819 235.075 -492.819 c +231.077 -493.818 224.579 -492.319 224.079 -492.319 c +223.58 -492.319 215.583 -491.819 214.083 -490.82 c +212.584 -489.82 204.087 -489.82 204.087 -487.321 c +204.087 -484.822 208.586 -482.823 211.085 -480.324 c +213.584 -477.825 220.581 -472.827 221.081 -470.328 c +221.58 -467.829 221.081 -461.332 221.081 -458.333 c +221.081 -455.334 219.081 -449.335 217.082 -445.337 c +215.083 -441.339 213.584 -427.344 213.084 -424.845 c +212.584 -422.346 214.583 -415.349 213.584 -413.35 c +212.584 -411.351 210.085 -398.356 209.085 -395.357 c +208.086 -392.358 206.087 -385.361 205.587 -379.364 c +205.087 -373.366 202.088 -354.874 201.089 -351.875 c +200.089 -348.876 198.59 -335.881 199.089 -331.883 c +199.589 -327.885 192.092 -314.89 191.592 -312.391 c +191.093 -309.892 188.594 -305.394 188.594 -300.895 c +188.594 -296.397 184.096 -294.898 181.597 -294.898 c +179.098 -294.898 170.101 -291.899 169.102 -290.899 c +168.102 -289.9 159.105 -293.398 155.606 -293.898 c +152.107 -294.398 140.112 -296.897 139.613 -296.397 c +139.113 -295.897 135.114 -303.894 134.615 -306.393 c +134.115 -308.892 132.615 -313.39 131.116 -313.89 c +129.617 -314.39 126.118 -318.888 126.118 -320.388 c +126.118 -321.887 122.12 -317.889 y +122.12 -312.391 121.62 -308.392 v +121.12 -304.394 124.619 -300.895 125.118 -298.396 c +125.618 -295.897 131.116 -287.901 130.616 -286.401 c +130.116 -284.902 128.131 -286.36 125.118 -288.4 c +121.244 -291.026 118.121 -310.392 115.622 -313.39 c +113.123 -316.389 106.626 -331.383 105.126 -333.882 c +103.627 -336.381 103.127 -363.87 102.128 -372.866 c +101.128 -381.863 103.127 -397.356 104.627 -401.355 c +106.126 -405.353 107.625 -409.352 106.626 -409.851 c +105.626 -410.351 112.623 -403.354 118.121 -403.854 c +123.619 -404.354 130.616 -408.352 131.616 -413.85 c +132.615 -419.348 131.116 -428.844 127.617 -431.343 c +124.119 -433.842 110.624 -436.341 108.125 -433.842 c +105.626 -431.343 94.631 -427.844 90.632 -418.848 c +89.333 -415.924 80.137 -391.859 79.637 -384.861 c +79.202 -378.776 76.514 -369.619 76.638 -367.868 c +76.673 -367.37 64.143 -379.364 61.644 -380.863 c +59.145 -382.362 50.149 -389.859 48.15 -387.86 c +46.15 -385.861 50.649 -383.362 52.148 -381.363 c +53.647 -379.364 61.144 -372.866 63.143 -371.367 c +65.143 -369.868 55.147 -374.866 51.148 -375.365 c +47.15 -375.865 45.151 -373.866 46.15 -373.366 c +47.15 -372.866 57.146 -368.368 62.144 -364.87 c +67.142 -361.371 74.139 -355.873 74.639 -353.374 c +75.139 -350.875 74.139 -326.885 73.139 -319.888 c +72.14 -312.891 77.138 -296.397 77.638 -287.401 c +78.137 -278.405 82.136 -267.91 84.135 -262.412 c +86.134 -256.914 90.824 -246.099 90.632 -245.419 c +s +262.063 -478.325 m +263.562 -474.326 271.059 -469.828 272.559 -467.829 c +274.058 -465.83 274.558 -460.332 272.559 -457.833 c +270.56 -455.334 267.561 -446.836 266.561 -444.837 c +265.562 -442.838 264.562 -437.34 263.562 -433.842 c +262.563 -430.343 262.063 -423.846 261.063 -421.347 c +260.064 -418.848 257.065 -412.35 256.565 -411.351 c +256.065 -410.351 254.066 -418.848 254.066 -422.346 c +254.066 -425.845 257.565 -430.343 257.565 -433.842 c +257.565 -437.34 258.065 -439.839 257.065 -443.338 c +256.065 -446.836 254.566 -450.836 255.066 -455.334 c +255.566 -459.832 256.565 -465.33 258.065 -468.828 c +259.564 -472.327 261.814 -478.986 262.063 -478.325 c +s +114.374 -421.846 m +114.123 -422.846 117.122 -422.597 118.621 -421.846 c +120.12 -421.098 121.371 -418.848 119.871 -417.348 c +118.372 -415.849 117.405 -416.194 116.122 -416.6 c +113.748 -417.348 114.509 -421.305 114.374 -421.846 c +s +121.871 -294.148 m +119.372 -291.65 119.121 -289.4 y +108.789 -290.299 108.625 -293.898 v +107.625 -315.889 64.143 -370.867 63.143 -371.367 c +S +76.638 -367.868 m +83.635 -362.371 105.126 -333.382 105.126 -333.882 c +S +164.602 -189.442 m +172.1 -193.44 172.6 -194.939 178.098 -194.939 c +183.596 -194.939 186.595 -191.441 191.592 -197.438 c +196.59 -203.436 198.59 -210.433 199.589 -217.43 c +200.589 -224.427 198.59 -229.425 194.591 -232.924 c +190.593 -236.422 194.091 -240.921 192.592 -242.42 c +191.093 -243.919 190.593 -248.418 190.593 -250.417 c +190.593 -252.416 182.845 -253.666 181.346 -254.665 c +179.846 -255.665 174.635 -263.779 173.849 -263.162 c +166.852 -257.664 168.351 -252.416 165.853 -250.417 c +163.354 -248.418 158.605 -239.921 157.105 -238.921 c +155.606 -237.922 148.021 -233.866 148.021 -231.367 c +148.021 -228.868 149.109 -219.166 148.609 -216.667 c +148.109 -214.168 152.107 -209.433 152.107 -208.434 c +S +159.781 -179.035 m +164.485 -180.211 169.189 -181.975 172.717 -182.563 c +176.245 -183.151 185.653 -186.091 188.593 -187.267 c +191.533 -188.443 198.001 -193.735 199.765 -197.263 c +201.529 -200.791 202.117 -206.671 202.705 -209.023 c +203.293 -211.375 203.293 -219.607 202.117 -221.371 c +200.941 -223.135 197.413 -231.955 196.237 -232.543 c +S +108.097 -233.86 m +112.167 -236.446 116.296 -237.525 120.179 -236.971 c +125.831 -236.166 128.942 -227.524 129.27 -225.841 c +S +109.73 -237.489 m +111.163 -238.845 115.233 -241.43 117.92 -241.079 c +120.607 -240.727 123.178 -240.834 125.479 -238.64 c +127.339 -236.869 130.379 -228.116 130.528 -226.81 c +S +108.46 -230.129 m +110.117 -226.085 113.633 -223.711 115.101 -223.019 c +120.739 -220.367 127.21 -223.619 127.234 -224.548 c +S +108.8 -230.633 m +111.01 -231.549 112.29 -232.49 113.598 -232.64 c +116.814 -233.01 120.042 -233.379 122.149 -230.779 c +123.23 -229.447 123.643 -229.297 125.175 -227.488 c +126.707 -225.678 126.557 -225.264 127.234 -224.548 c +S +u +117.144 -223.904 m +118.708 -223.335 120.422 -224.096 120.972 -225.607 c +121.522 -227.117 120.699 -228.804 119.135 -229.373 c +117.57 -229.943 115.856 -229.179 115.307 -227.669 c +114.757 -226.159 115.58 -224.472 117.144 -223.904 c +f +118.14 -226.638 m +F +U +129.952 -224.71 m +130.389 -223.353 131.426 -223.641 129.289 -222.158 c +128.199 -221.4 122.082 -217.838 119.797 -218.137 c +117.44 -218.445 114.876 -219.824 113.16 -222.044 c +S +109.974 -231.066 m +110.638 -229.885 111.271 -230.044 110.638 -229.885 c +110.188 -229.77 109.038 -229.138 y +S +125.118 -288.4 m +132.615 -282.903 135.114 -282.903 138.113 -276.906 c +141.112 -270.909 139.613 -259.413 137.613 -255.915 c +135.614 -252.416 133.615 -244.919 y +S +128.971 -242.98 m +126.971 -247.478 124.472 -253.975 120.973 -255.475 c +117.474 -256.974 111.477 -257.974 109.478 -258.473 c +S +129.823 -220.573 m +126.834 -218.203 123.007 -214.64 121.267 -214.609 c +119.528 -214.578 116.234 -213.677 113.623 -215.785 c +111.96 -217.128 108.602 -222.181 107.962 -223.343 c +S +73.139 -317.889 m +82.136 -309.392 94.631 -316.389 y +S +74.139 -305.394 m +77.638 -301.395 78.137 -298.396 85.135 -299.396 c +92.132 -300.396 97.13 -303.894 97.63 -303.894 c +S +74.139 -331.883 m +77.138 -329.384 83.635 -327.385 85.135 -327.885 c +86.634 -328.384 92.632 -329.884 y +S +74.639 -345.877 m +76.638 -343.878 83.635 -343.878 y +S +77.138 -371.367 m +80.137 -369.368 86.01 -366.119 90.008 -366.869 c +92.204 -367.28 99.629 -370.867 y +S +79.512 -382.114 m +82.011 -380.614 89.633 -374.866 96.63 -380.863 c +S +83.635 -399.356 m +92.383 -389.611 99.129 -397.356 y +S +86.885 -408.603 m +93.131 -400.355 101.628 -407.352 y +S +89.384 -414.6 m +94.631 -407.852 104.127 -413.35 y +S +93.631 -423.597 m +94.631 -420.598 104.378 -417.848 104.627 -417.848 c +S +106.877 -420.347 m +103.127 -423.097 102.128 -429.594 y +S +117.872 -422.097 m +116.873 -431.343 124.869 -432.093 y +S +112.375 -420.847 m +106.877 -427.844 114.374 -434.841 y +S +120.371 -419.348 m +125.118 -425.596 131.616 -419.099 y +S +119.871 -417.348 m +127.118 -416.6 124.619 -406.104 y +S +118.372 -416.349 m +123.119 -408.603 114.374 -404.354 y +S +116.122 -416.6 m +114.874 -409.103 106.126 -410.351 106.626 -409.851 c +106.877 -409.602 103.878 -416.849 105.377 -420.347 c +108.125 -413.85 114.374 -421.846 v +114.528 -422.044 109.876 -419.598 105.377 -420.347 c +S +114.623 -418.848 m +111.875 -411.851 104.878 -415.1 105.126 -415.1 c +S +74.639 -356.373 m +74.763 -354.498 74.639 -353.374 v +S +81.012 -390.235 m +83.511 -388.735 91.132 -382.987 98.129 -388.984 c +S +95.506 -346.127 m +95.881 -346.127 99.629 -347.377 y +S +77.388 -352.75 m +76.388 -352.125 74.639 -352.874 74.639 -352.75 c +S +89.384 -353.998 m +91.507 -353.75 97.88 -356.249 y +S +78.137 -279.904 m +84.135 -277.405 89.133 -276.406 94.131 -277.905 c +99.129 -279.405 107.126 -285.402 y +S +83.635 -265.411 m +88.133 -262.412 95.131 -262.912 99.629 -263.412 c +104.127 -263.911 113.623 -270.909 y +121.62 -276.406 l +S +77.388 -352.75 m +S +74.639 -352.75 m +S +256.565 -411.351 m +262.563 -398.856 259.564 -384.362 261.563 -374.866 c +263.562 -365.369 263.063 -354.374 267.561 -348.376 c +272.059 -342.379 281.555 -321.387 283.554 -314.89 c +285.553 -308.392 276.057 -271.908 273.059 -264.911 c +270.06 -257.914 265.562 -248.917 264.562 -244.419 c +263.562 -239.921 261.563 -225.927 263.562 -221.928 c +S +1 w +291.198 -93.775 m +S +0.7 w +289.052 -352.874 m +284.554 -343.878 266.561 -350.875 y +S +242.394 -491.555 m +242.394 -488.056 239.469 -483.145 238.221 -482.896 c +236.972 -482.645 231.474 -483.645 231.474 -483.896 c +231.474 -484.145 228.225 -480.897 226.976 -479.898 c +225.726 -478.898 221.727 -480.146 220.728 -480.646 c +219.728 -481.146 217.229 -479.398 216.729 -478.898 c +216.23 -478.398 212.951 -478.957 212.701 -479.207 c +S +219.728 -480.397 m +220.479 -483.896 212.701 -490.085 y +S +231.474 -483.896 m +231.723 -486.395 224.079 -492.319 y +S +261.872 -477.736 m +264.621 -485.233 260.622 -487.483 y +S +284.054 -485.822 m +280.556 -485.572 268.369 -482.734 267.869 -481.485 c +267.37 -480.235 262.622 -480.486 y +S +288.552 -482.073 m +285.054 -478.075 279.806 -473.826 278.057 -473.826 c +276.307 -473.826 268.854 -481.809 268.854 -481.559 c +S +269.06 -470.828 m +272.559 -470.328 275.807 -475.076 y +S +358.525 -473.327 m +362.272 -472.577 366.271 -474.326 367.27 -475.576 c +368.27 -476.825 361.524 -482.823 361.024 -482.823 c +S +367.374 -474.988 m +369.623 -474.237 372.622 -474.988 374.371 -476.236 c +376.121 -477.487 379.869 -483.484 y +S +390.275 -261.943 m +380.278 -279.436 357.347 -332.502 384.015 -355.373 c +398.54 -367.832 399.507 -387.86 404.505 -393.358 c +409.503 -398.856 405.005 -410.351 406.005 -416.849 c +407.004 -423.346 410.003 -429.843 410.003 -439.839 c +410.003 -449.835 408.004 -460.832 408.504 -465.33 c +409.004 -469.828 405.005 -475.826 404.006 -477.825 c +403.006 -479.824 398.008 -483.323 y +403.506 -482.823 407.504 -486.821 407.755 -487.071 c +408.004 -487.321 401.007 -496.067 y +S +407.269 -487.071 m +415.017 -483.821 423.513 -490.319 y +432.259 -485.321 441.006 -497.067 y +S +381.016 -358.872 m +382.337 -358.961 385.277 -357.197 y +S +489.972 -308.392 m +491.998 -302.514 496.114 -294.87 496.114 -293.106 c +S +490.234 -445.397 m +490.234 -453.629 493.762 -464.213 y +S +487.882 -446.573 m +487.882 -450.101 489.299 -465.683 489.472 -465.83 c +S +484.942 -443.045 m +483.178 -447.749 484.354 -461.273 y +S +421.439 -452.453 m +431.435 -455.981 446.668 -448.747 446.988 -448.836 c +S +376.163 -444.221 m +383.219 -451.277 401.447 -451.277 y +S +377.927 -423.641 m +382.043 -426.581 397.331 -425.993 y +S +406.739 -407.765 m +417.323 -418.349 438.491 -410.117 y +S +370.871 -461.861 m +376.163 -468.917 397.331 -471.857 y +S +409.679 -434.225 m +416.735 -440.693 439.079 -431.285 y +S +406.739 -396.593 m +414.383 -398.945 433.787 -391.301 y +S +448.487 -477.737 m +430.847 -486.557 412.031 -479.501 y +S +312.072 -455.981 m +306.78 -462.449 281.496 -464.213 y +S +300.048 -433.842 m +295.608 -439.517 276.792 -439.517 y +S +295.608 -395.417 m +290.904 -392.477 263.856 -397.769 y +S +297.96 -413.057 m +293.844 -417.173 268.56 -420.113 y +S +291.492 -374.249 m +287.376 -372.485 261.623 -374.307 261.563 -374.866 c +S +250.92 -424.229 m +247.392 -444.221 217.993 -435.401 y +S +253.272 -430.109 m +250.92 -448.337 223.285 -454.217 y +S +256.8 -461.861 m +245.04 -473.033 225.637 -468.329 y +S +213.584 -413.35 m +220.933 -420.701 239.16 -413.645 y +S +236.809 -380.129 m +232.693 -386.597 205.645 -383.657 y +S +238.572 -389.537 m +245.04 -387.185 260.328 -394.829 y +S +237.985 -371.897 m +240.924 -370.133 261.504 -378.365 y +S +237.985 -358.961 m +235.045 -362.489 202.705 -361.901 y +S +199.177 -335.442 m +215.641 -344.262 248.568 -327.21 y +S +192.709 -314.274 m +201.529 -306.63 238.572 -311.334 y +S +149.785 -246.655 m +158.605 -263.707 138.025 -287.814 y +S +160.957 -258.415 m +166.837 -267.823 146.257 -288.402 y +S +174.481 -270.763 m +178.597 -277.818 167.425 -290.166 y +S +191.533 -259.591 m +200.353 -270.175 183.889 -294.87 y +S +206.233 -247.243 m +212.113 -269.587 187.418 -299.865 188.594 -300.895 c +S +159.193 -201.379 m +162.133 -207.259 161.545 -215.491 161.545 -217.255 c +161.545 -219.019 153.313 -227.251 153.901 -230.779 c +S +237.985 -176.095 m +244.452 -180.799 251.508 -187.855 254.448 -192.559 c +257.388 -197.263 253.861 -213.37 253.566 -214.431 c +251.359 -222.372 242.571 -252.416 244.57 -262.412 c +246.569 -272.408 251.567 -282.403 252.567 -295.398 c +253.566 -308.392 253.566 -320.388 246.569 -331.383 c +239.572 -342.379 236.574 -357.373 237.574 -368.368 c +238.572 -379.364 235.575 -404.354 245.57 -422.346 c +S +457.895 -360.725 m +464.951 -348.378 464.363 -327.798 469.067 -315.45 c +473.77 -303.102 477.886 -295.458 477.298 -278.994 c +476.71 -262.531 473.77 -263.119 y +S +410.267 -370.133 m +402.035 -357.197 396.155 -340.734 394.979 -328.974 c +394.151 -320.699 409.091 -287.814 y +S +u +116.786 -223.328 m +119.079 -222.493 121.637 -223.74 122.502 -226.115 c +123.365 -228.487 122.208 -231.089 119.915 -231.922 c +117.621 -232.757 115.064 -231.51 114.199 -229.135 c +113.335 -226.763 114.493 -224.163 116.786 -223.328 c +s +118.351 -227.626 m +S +U +118.294 -232.651 m +116.002 -233.016 113.653 -232.151 112.636 -230.643 c +111.618 -229.137 111.9 -227.548 112.377 -226.28 c +112.854 -225.01 114.424 -223.735 114.926 -223.396 c +115.428 -223.057 118.062 -222.269 119.178 -222.397 c +122.279 -222.753 123.831 -224.223 124.232 -225.328 c +124.635 -226.433 124.862 -227.915 124.723 -227.965 c +S +%%Trailer +_E end + diff --git a/dviware/dvitops/pk.c b/dviware/dvitops/pk.c new file mode 100644 index 0000000000..123eb6964f --- /dev/null +++ b/dviware/dvitops/pk.c @@ -0,0 +1,523 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/pk.c,v 1.7 90/10/19 09:54:55 jjc Exp $"; + +#include "dvitops.h" + +#define pk_id 89 + +#if 0 +enum pk_command { pk_xxx1 = 240, pk_xxx2 = 241, pk_xxx3 = 242, pk_xxx4 = 243, +pk_yyy = 244, pk_post = 245, pk_no_op = 246, pk_pre = 247 }; +#else +#define pk_xxx1 240 +#define pk_xxx2 241 +#define pk_xxx3 242 +#define pk_xxx4 243 +#define pk_yyy 244 +#define pk_post 245 +#define pk_no_op 246 +#define pk_pre 247 + +#endif +static struct { + integer llx, lly, urx, ury; +} bb; /* bounding box for the entire font */ +#ifdef PROTO +static void out_byte(PROMOTED_UNSIGNED_CHAR c, FILE *psfp); +static void blacken(integer start, integer n, unsigned char *buf); +static integer packed_num(int dyn_f); +static void bitmap_char(integer h, integer w, FILE *psfp); +static integer makeinteger(unsigned char *p); +static int generate_char(PROMOTED_UNSIGNED_CHAR flag, unsigned char *data, + size_t len, FILE *psfp); +#else +static void out_byte(); +static void blacken(); +static integer packed_num(); +static void bitmap_char(); +static integer makeinteger(); +static int generate_char(); +#endif + +static struct pk_info { + integer ds; + integer hppp; + integer vppp; + unsigned char flag[MAXCHARS]; + size_t len[MAXCHARS]; + unsigned char *data[MAXCHARS]; +} *pk_table[MAXFONTS]; + +static integer nbytes; + +char *find_pk_file(name, mag) +char *name; +int mag; +{ + FILE *pkfp; + int i; + static char buf[10*FILENAME_MAX]; + char *ptr = buf; + static char sep[2] = {AREA_LIST_SEP, '\0'}; + for (i = 0; texpk[i] != '\0'; i++) + if (texpk[i] == '%') { + switch(texpk[i+1]) { + case 'f': case 'F': + strcpy(ptr, name); + break; + case 'd': case 'D': + sprintf(ptr, "%d", mag); + break; + default: + sprintf(ptr, "%c", texpk[i+1]); + } + ++i; + ptr += strlen(ptr); + } + else + *ptr++ = texpk[i]; + *ptr = '\0'; + for (ptr = strtok(buf, sep); ptr != NULL; ptr = strtok((char *)NULL, sep)) { + if ((pkfp = FOPEN_RB(ptr)) != NULL) { + fclose(pkfp); + return ptr; + } + } + return NULL; +} + + +int load_pk_font(f, name, used, at_size, checksum, width, rounded_width) +int f; +char *name, *used; +integer at_size, checksum, *width, *rounded_width; +{ + FILE *pkfp; + integer n; + integer cs; + double sppp; + int i; + if ((pkfp = FOPEN_RB(name)) == NULL) { + message(ERROR, + "can't find pk file for %s: using white space instead", name); + return 0; + } +#ifdef HAVE_SETVBUF + setvbuf(pkfp, (char *)NULL, _IOFBF, 8192); +#endif + if ((pk_table[f] = (struct pk_info *) + calloc(1, sizeof(struct pk_info))) == NULL) + out_of_memory(); + if (uread1(pkfp) != pk_pre) + goto bad; + if (uread1(pkfp) != pk_id) + goto bad; + n = uread1(pkfp); + fseek(pkfp, n, 1); + pk_table[f]->ds = sread4(pkfp); + cs = sread4(pkfp); + pk_table[f]->hppp = sread4(pkfp); + pk_table[f]->vppp = sread4(pkfp); + /* sppp = scaled points per pixel + sppp*dx = width in scaled points */ + sppp = (double)at_size*1048576.0*65536.0 + /((double)pk_table[f]->ds*(double)pk_table[f]->hppp); + + if (cs != checksum) + message(WARNING, "%s: checksums don't match\n", name); + for (;;) { + unsigned char command = uread1(pkfp); + if (feof(pkfp) || ferror(pkfp)) + goto bad; + if (((unsigned)command >> 4) == 15) { + switch (command) { + case pk_xxx1 : + n = uread1(pkfp); break; + case pk_xxx2 : + n = uread2(pkfp); break; + case pk_xxx3 : + n = uread3(pkfp); break; + case pk_xxx4 : + n = sread4(pkfp); break; + case pk_yyy : + (void) sread4(pkfp); break; + case pk_post : + for (i = 0; i < MAXCHARS; i++) + if (used[i] && width[i] == (integer) LONG_MAX) + goto bad; + fclose(pkfp); + return 1; + case pk_no_op : + break; + default: + goto bad; + } + if (pk_xxx1 <= command && command <= pk_xxx4) + fseek(pkfp, n, 1); + } + else { + integer cc, pl; + integer tfm; + double dx; + unsigned char c; + size_t len; + unsigned char flag = command; + command &= 0x07; + if (command == 0x07) { + pl = sread4(pkfp); + cc = sread4(pkfp); + tfm = sread4(pkfp); + dx = (double)sread4(pkfp)/65536.0; + fseek(pkfp, -4L, 1); + pl -= 4; + } + else if (command & 0x04) { + pl = uread2(pkfp); + pl |= (integer)(command & 0x03) << 16; + cc = uread1(pkfp); + tfm = uread3(pkfp); + dx = (double)uread2(pkfp); + fseek(pkfp, -2L, 1); + pl -= 3; + } + else { + pl = uread1(pkfp); + pl |= (command & 0x03) << 8; + cc = uread1(pkfp); + tfm = uread3(pkfp); + dx = (double)uread1(pkfp); + fseek(pkfp, -1L, 1); + pl -= 3; + } + if (cc < 0 || cc >= MAXCHARS) { + fseek(pkfp, pl, SEEK_CUR); + continue; + } + c = (unsigned char)cc; + if (!used[c]) { + pk_table[f]->data[c] = NULL; + fseek(pkfp, pl, SEEK_CUR); + } + else { + if (pl < 0 || pl > SIZE_MAX) + goto bad; + len = (size_t)pl; + width[c] = scale(tfm, at_size); + rounded_width[c] = (integer)(dx*sppp); + pk_table[f]->flag[c] = flag; + pk_table[f]->len[c] = len; + if ((pk_table[f]->data[c] = (unsigned char *)malloc(len)) + == NULL) + out_of_memory(); + if (fread((char *)pk_table[f]->data[c], 1, len, pkfp) != len) + goto bad; + } + } + } + /* can't get here */ +bad: + message(ERROR, "%s: bad pk file: using white space instead", name); + return 0; +} + +static unsigned char *ptr; +static char biti; +static integer rc; + +#define get_nyb() (biti == 0 ? (biti=4, (unsigned)*ptr>>4) \ +: (biti = 0, *ptr++ & 0x0f)) + + +static integer packed_num(dyn_f) +int dyn_f; +{ + integer i, j; + integer n; + i = get_nyb(); + if (i == 0) { + do { + j = get_nyb(); + i++; + } while (j == 0); + while (i > 0) { + j = (j << 4) + get_nyb(); + i--; + } + n = (j - 15 + ((13 - dyn_f) << 4) + dyn_f); + } + else if (i <= dyn_f) + n = i; + else if (i < 14) + n = ((i - dyn_f - 1) << 4) + get_nyb() + dyn_f + 1; + else { + rc = i == 14 ? packed_num(dyn_f) : 1; + n = packed_num(dyn_f); + } + return n; +} + +/* this can be made a lot more efficient later */ + +static void blacken(start, n, buf) +integer start, n; +unsigned char *buf; +{ + integer i; + for (i = start; i < start + n; i++) + buf[(size_t)(i/8)] |= (unsigned)128 >> (int)(i & 7); +} + + +static char *hex = "0123456789ABCDEF"; + +static void out_byte(c, psfp) +unsigned char c; +FILE *psfp; +{ + static int cols = 0; + putc(hex[(unsigned)(c) >> 4],psfp); + putc(hex[(c) & 15],psfp); + if ((cols += 2) > 70) { + cols = 0; + putc('\n', psfp); + } + ++nbytes; +} + +/* postscript requires that the bitmap of each row be padded out to an +integral number of bytes, so unfortunately we can't just copy the bitmap +in the pk file; this function could probably be made faster, but most +of the characters that pk format represents by bitmaps are fairly small */ + +static void bitmap_char(h, w, psfp) +integer h, w; +FILE *psfp; +{ + integer i, j; + unsigned mask = 0x80; + unsigned char curbyte = 0; + unsigned curmask = 0x80; + for (i = 0; i < h; i++) + for (j = 0; j < w; j++) { + if (*ptr & mask) + curbyte |= curmask; + if ((mask >>= 1) == 0) { + mask = 0x80; + ptr++; + } + if ((curmask >>= 1) == 0 || j == w - 1) { + out_byte(curbyte, psfp); + curbyte = 0; + curmask = 0x80; + } + } +/* the value of ptr is checked on return to make sure we have used the right +number of bytes */ + if (mask != 0x80) + ptr++; +} + +static integer makeinteger(p) +unsigned char *p; +{ + return (((integer)p[0]<<24) | ((integer)p[1]<<16) | (p[2]<<8) | p[3]); +} + +/* +output strings have one of the following forms: +(4 byte integers are always signed) +flag[1] dm[1] w[1] h[1] hoff[+1] voff[+1] flag = 0 +flag[1] dm[2] w[2] h[2] hoff[+2] voff[+2] flag = 1 +flag[1] dx[4] dy[4] w[4] h[4] hoff[4] voff[4] flag = 2 +*/ + +/* returns 0 on error != 0 otherwise */ +static int generate_char(flag, data, len, psfp) +unsigned char flag; +unsigned char *data; +size_t len; +FILE *psfp; +{ + int black = (flag & 0x08) != 0; + integer h, w; + int dyn_f; + integer hoff, voff; + integer curcol, currow; + unsigned char *rowbuf; + size_t buflen; + dyn_f = (unsigned)flag >> 4; + ptr = data; + rc = 0; + biti = 0; + fputc('<',psfp); + if ((flag & 0x07) == 0x07) { + int i; + out_byte(2, psfp); + for (i = 0; i < 24; i++) + out_byte(ptr[i], psfp); + ptr += 8; + w = makeinteger(ptr); ptr += 4; + h = makeinteger(ptr); ptr += 4; + hoff = makeinteger(ptr); ptr += 4; + voff = makeinteger(ptr); ptr += 4; + } + else if (flag & 0x04) { + int i; + out_byte(1, psfp); + for (i = 0; i < 10; i++) + out_byte(ptr[i], psfp); + ptr += 2; + w = (ptr[0] << 8) | ptr[1]; ptr += 2; + h = (ptr[0] << 8) | ptr[1]; ptr += 2; + hoff = *ptr++; + if (hoff >= 128) + hoff -= 256; + hoff <<= 8; + hoff |= *ptr++; + voff = *ptr++; + if (voff >= 128) + voff -= 256; + voff <<= 8; + voff |= *ptr++; + } + else { + int i; + out_byte(0, psfp); + for (i = 0; i < 5; i++) + out_byte(ptr[i], psfp); + ptr++; + w = *ptr++; + h = *ptr++; + hoff = *ptr++; + if (hoff >= 128) + hoff -= 256; + voff = *ptr++; + if (voff >= 128) + voff -= 256; + } + if (-hoff < bb.llx) + bb.llx = -hoff; + if (w-hoff > bb.urx) + bb.urx = w-hoff; + if (voff + 1 - h < bb.lly) + bb.lly = voff + 1 - h; + if (voff + 1 > bb.ury) + bb.ury = voff + 1; + if (dyn_f == 14) { + bitmap_char(h, w, psfp); + if (data + len != ptr) + return 0; + fputc('>',psfp); + return 1; + } + currow = curcol = 0; + buflen = (size_t)((w + 7) / 8); + if (buflen == SIZE_MAX) /* we'd get an infinite loop if we allowed this */ + return 0; + rowbuf = (unsigned char *)calloc(1, buflen); + if (rowbuf == NULL) + out_of_memory(); + while (currow < h) { + integer run = packed_num(dyn_f); + while (curcol + run >= w) { + size_t i; + integer j; + if (black) + blacken(curcol, w - curcol, rowbuf); + for (j = 0; j <= rc; j++) { + for (i = 0; i < buflen; i++) + out_byte(rowbuf[i],psfp); + } + for (i = 0; i < buflen; i++) + rowbuf[i] = 0; + currow++; currow += rc; rc = 0; + run -= w - curcol; + curcol = 0; + } + if (black) + blacken(curcol, run, rowbuf); + curcol += run; + black = !black; + } + if (biti > 0) + ptr++; + if (data + len != ptr) + return 0; + fputc('>',psfp); + free((char *)rowbuf); + return 1; +} + + +integer emit_pk_font(f, name, used, psfp) +int f; +char *name; +char *used; +FILE *psfp; +{ + int i, nused; + nbytes = 0; + if (pk_table[f] == NULL) + cant_happen(); + fprintf(psfp, "%%%%BeginFont: %s\n", name); + fprintf(psfp, "/%s %ld %ld %ld\n", name, (long)(pk_table[f]->ds), + (long)(pk_table[f]->hppp), (long)(pk_table[f]->vppp)); + bb.llx = bb.lly = bb.urx = bb.ury = 0; + nused = 0; + fputs("EmptyEncoding 256 array copy\n", psfp); + for (i = 0; i < MAXCHARS; i++) + if (used[i]) { + fprintf(psfp, "dup %d /c%d put\n", i, i); + ++nused; + } + /* allow room for /.notdef */ + fprintf(psfp, "\n%d dict dup begin\n", nused+1); + for (i = 0; i < MAXCHARS; i++) + if (used[i]) { + if (pk_table[f]->data[i] == NULL) + cant_happen(); + fprintf(psfp, "/c%d", i); + if (!generate_char(pk_table[f]->flag[i], pk_table[f]->data[i], + pk_table[f]->len[i], psfp)) + message(FATAL_ERROR, + "char %d in the .pk file for %s is bad: use pktype", + i, name); + fputs("def\n", psfp); + } + fprintf(psfp, "end %ld %ld %ld %ld DefinePKFont\n", (long)(bb.llx), + (long)(bb.lly), (long)(bb.urx), (long)(bb.ury)); + fputs("%%EndFont\n", psfp); + /* this is a fairly good estimate of the overhead for each font */ + return nbytes + 1024 + 2000 + 20*(nused+1); + /* nbytes for the strings, 1024 for the encoding vector, + 20 for each of the nused+1 entries in the dictionary + plus 2000 for general overhead */ +} + + + + +void free_pk_font(n) +int n; +{ + int i; + struct pk_info *p = pk_table[n]; + if (pk_table[n] == NULL) + cant_happen(); + for (i = 0; i < MAXCHARS; i++) + if (p->data[i] != NULL) + free((char *)(p->data[i])); + free((char *)p); + pk_table[n] = NULL; +} + +/* +Local Variables: +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +tab-width: 4 +End: +*/ + diff --git a/dviware/dvitops/primos.h b/dviware/dvitops/primos.h new file mode 100644 index 0000000000..1300dec6b0 --- /dev/null +++ b/dviware/dvitops/primos.h @@ -0,0 +1,43 @@ +/* Primos support */ + +#define PAPER "a4" + +#define TEXFONTS "*;TeX>fonts" +#define TEXINPUTS "*;TeX>inputs" +#define TEXPK "%f.%dpk;TeX>pxl12>%f.%dpk" +#define TEXMAGS 214,240,257,270,300,329,360,432,518,622,746,896,1075,1290 +#define PSFONTS "*;TeX>psfonts" +/*#define HAVE_REDIRECTION*/ +/*#define HAVE_SETVBUF*/ +#define NEED_MEM_FUNCTIONS +#define NEED_QSORT +#define NEED_STRTOK +#define FOPEN_RB(file) (fopen((file), "i") +#define DPI 300 +#define FILENAME_MAX 128 +#define AREA_LIST_SEP ';' +#define AREA_SEP '>' +#define FILENAME_HAS_AREA(f) (strchr(f,'>') != NULL) +#define CASE_INSENSITIVE_FILENAMES +#define CASE_INSENSITIVE_OPTIONS +#define REORDER_ARGS +#define MAXFONTS 256 + +#define UCHAR_MAX 255 +#define USHRT_MAX 0xffff +#define SHRT_MAX 32767 +#define UINT_MAX 0xffff +#define INT_MAX 32767 +#define LONG_MAX 2147483647L +#define size_t unsigned long + +#define XCHAR(ch) (((ch) & 0377) | 0200) + +#define WARNING_EXIT_CODE -1 +#define ERROR_EXIT_CODE 1 +#define FATAL_ERROR_EXIT_CODE 1 + +#define PRIMOS_GETENV + +char *ctime(); /* not declared anywhere else */ +typedef long time_t; diff --git a/dviware/dvitops/printafm.ps b/dviware/dvitops/printafm.ps new file mode 100644 index 0000000000..fadd755271 --- /dev/null +++ b/dviware/dvitops/printafm.ps @@ -0,0 +1,136 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/printafm.ps,v 1.1 89/02/01 09:19:41 jjc Rel $ +% written by James Clark <jjc@jclark.uucp> +% print an afm file on the standard output +% usage is `fontname printafm' eg `/Times-Roman printafm' + +/buf 256 string def +/onechar 1 string def +/box 4 array def + +% c toupper - c +/toupper { + dup dup 8#141 ge exch 8#172 le and { + 8#40 sub + } if +} bind def + + +% dict printinfo - +/printinfo { + /FontInfo get { + exch + buf cvs dup dup 0 get 0 exch toupper put print + ( ) print + buf cvs = + } forall +} bind def + +% dict printbbox - + +/printbbox { + (FontBBox) print + /FontBBox get { + ( ) print + round cvi buf cvs print + } forall + (\n) print +} bind def + +% dict printcharmetrics - + +/printcharmetrics { + /d exch def + (StartCharMetrics ) print + d /CharStrings get dup length exch /.notdef known { 1 sub } if = + d 1000 scalefont setfont 0 0 moveto + /e d /Encoding get def + 0 1 255 { + dup e exch get + dup /.notdef ne { + exch dup printmetric + } { + pop pop + } ifelse + } for + % s contains an entry for each name in the original encoding vector + /s 256 dict def + e { + s exch true put + } forall + % v is the new encoding vector + /v 256 array def + 0 1 255 { + v exch /.notdef put + } for + % fill up v with names in CharStrings + /i 0 def + d /CharStrings get { + pop + i 255 le { + v i 3 -1 roll put + /i i 1 add def + } { + pop + } ifelse + } forall + % define a new font with v as its encoding vector + d maxlength dict /f exch def + d { + exch dup dup /FID ne exch /Encoding ne and { + exch f 3 1 roll put + } { + pop pop + } ifelse + } forall + f /Encoding v put + f /FontName /temp put + % make this new font the current font + /temp f definefont /d exch def + d 1000 scalefont setfont + % print a entry for each character not in old vector + /e d /Encoding get def + 0 1 255 { + dup e exch get + dup dup /.notdef ne exch s exch known not and { + exch -1 printmetric + } { + pop pop + } ifelse + } for + (EndCharMetrics) = +} bind def + +% name actual_code normal_code printmetric - + +/printmetric { + /saved save def + (C ) print + buf cvs print + ( ; WX ) print + onechar 0 3 -1 roll put + onechar stringwidth pop round cvi buf cvs print + ( ; N ) print + buf cvs print + ( ; B ) print + onechar false charpath flattenpath pathbbox box astore { + round cvi buf cvs print + ( ) print + } forall + (;) = + saved restore +} bind def + +% fontname printafm - + +/printafm { + findfont /d exch def + (StartFontMetrics 2.0) = + (FontName ) print d /FontName get = + d printinfo + d printbbox + d printcharmetrics + (EndFontMetrics) = +} bind def + + diff --git a/dviware/dvitops/ps.sty b/dviware/dvitops/ps.sty new file mode 100644 index 0000000000..bbfbfaa987 --- /dev/null +++ b/dviware/dvitops/ps.sty @@ -0,0 +1,280 @@ +% $Header: /usr/jjc/dvitops/RCS/ps.sty,v 1.3 89/12/11 20:35:55 jjc Exp $ +% adapt LaTeX to use PostScript fonts +% you'll need a lot of font memory to use this +% math accents haven't been done yet + +% you can choose here which PostScript fonts will be used + +\def\roman@#1{Times-Roman at #1} +\def\mathitalic@#1{Times-Italic at #1} % should produce a proper mi font +\def\italic@#1{Times-Italic at #1} +\def\bold@#1{Times-Bold at #1} +\def\symbol@#1{Symbol at #1} +\def\extension@#1{timesex at #1} +\def\greekl@#1{symbolsl at #1} % lower case greek letters +\def\smallcaps@#1{timessc at #1} +\def\slanted@#1{timessl at #1} +\def\typewriter@#1{Courier-Bold at #1} + +%% preloaded fonts +\newdimen\psdimen + +\def\dopreload#1#2{% +\expandafter\font\csname #1psrm\endcsname=\roman@{#2}% +\expandafter\font\csname #1psmi\endcsname=\mathitalic@{#2}% +\expandafter\font\csname #1pssy\endcsname=\symbol@{#2}% +\expandafter\font\csname #1psex\endcsname=\extension@{#2}% +\psdimen=#2 \multiply\psdimen by 9\divide\psdimen by 10 %use Symbol-Slanted +\expandafter\font\csname #1psgrl\endcsname=\greekl@{\psdimen}% +\expandafter\font\csname #1sc\endcsname=\smallcaps@{#2}% +\expandafter\font\csname #1bf\endcsname=\bold@{#2}% +\expandafter\font\csname #1it\endcsname=\italic@{#2}% +\expandafter\font\csname #1sl\endcsname=\slanted@{#2}% +\expandafter\font\csname #1tt\endcsname=\typewriter@{#2}% +} + +\dopreload{fiv}{5pt} +\dopreload{six}{6pt} +\dopreload{sev}{7pt} +\dopreload{egt}{8pt} +\dopreload{nin}{9pt} +\dopreload{ten}{10pt} +\dopreload{elv}{11pt} +\dopreload{twl}{12pt} +\dopreload{frtn}{14pt} +\dopreload{svtn}{17pt} +\dopreload{twty}{20pt} +\dopreload{twfv}{25pt} + +\newfam\psrmfam +\newfam\psmifam +\newfam\pssyfam +\newfam\psexfam +\newfam\psgrlfam + +\def\addinfo#1#2#3#4{\@addfontinfo#4{% +\textfont\psrmfam=\csname #1psrm\endcsname +\scriptfont\psrmfam=\csname #2psrm\endcsname +\scriptscriptfont\psrmfam=\csname #3psrm\endcsname +\textfont\psmifam=\csname #1psmi\endcsname +\scriptfont\psmifam=\csname #2psmi\endcsname +\scriptscriptfont\psmifam=\csname #3psmi\endcsname +\textfont\pssyfam=\csname #1pssy\endcsname +\scriptfont\pssyfam=\csname #2pssy\endcsname +\scriptscriptfont\pssyfam=\csname #3pssy\endcsname +\textfont\psexfam=\csname #1psex\endcsname +\scriptfont\psexfam=\csname #2psex\endcsname +\scriptscriptfont\psexfam=\csname #3psex\endcsname +\textfont\psgrlfam=\csname #1psgrl\endcsname +\scriptfont\psgrlfam=\csname #2psgrl\endcsname +\scriptscriptfont\psgrlfam=\csname #3psgrl\endcsname +\def\prm{\fam\psrmfam\csname#1psrm\endcsname}% +\def\pit{\fam\itfam\csname#1it\endcsname}% +\def\pbf{\fam\bffam\csname#1bf\endcsname}% +\def\psc{\fam\scfam\csname#1sc\endcsname}% +\def\psl{\fam\slfam\csname#1sl\endcsname}% +\def\ptt{\fam\ttfam\csname#1tt\endcsname}% +\@prtct\rm}} + +\addinfo{fiv}{fiv}{fiv}\@vpt +\addinfo{six}{six}{six}\@vipt +\addinfo{sev}{six}{fiv}\@viipt +\addinfo{egt}{six}{fiv}\@viiipt +\addinfo{nin}{six}{fiv}\@ixpt +\addinfo{ten}{sev}{fiv}\@xpt +\addinfo{elv}{egt}{six}\@xipt +\addinfo{twl}{egt}{six}\@xiipt +\addinfo{frtn}{ten}{sev}\@xivpt +\addinfo{svtn}{twl}{ten}\@xviipt +\addinfo{twty}{frtn}{twl}\@xxpt +\addinfo{twfv}{twty}{svtn}\@xxvpt + + +%% math mode stuff + +\def\hexnumber@#1{\ifcase#1 0\or1\or2\or3\or4\or5\or6\or7\or8\or9\or + A\or B\or C\or D\or E\or F\fi} +\edef\bffam@{\hexnumber@\bffam} + +\edef\psrmfam@{\hexnumber@\psrmfam} +\edef\psmifam@{\hexnumber@\psmifam} +\edef\pssyfam@{\hexnumber@\pssyfam} +\edef\psexfam@{\hexnumber@\psexfam} +\edef\psgrlfam@{\hexnumber@\psgrlfam} + +% numerals come from psrmfam + +\mathcode"30="7\psrmfam@ 30 +\mathcode"31="7\psrmfam@ 31 +\mathcode"32="7\psrmfam@ 32 +\mathcode"33="7\psrmfam@ 33 +\mathcode"34="7\psrmfam@ 34 +\mathcode"35="7\psrmfam@ 35 +\mathcode"36="7\psrmfam@ 36 +\mathcode"37="7\psrmfam@ 37 +\mathcode"38="7\psrmfam@ 38 +\mathcode"39="7\psrmfam@ 39 +\mathcode"3A="7\psrmfam@ 3A + +% upper case letters from psmifam + +\mathcode"41="7\psmifam@ 41 +\mathcode"42="7\psmifam@ 42 +\mathcode"43="7\psmifam@ 43 +\mathcode"44="7\psmifam@ 44 +\mathcode"45="7\psmifam@ 45 +\mathcode"46="7\psmifam@ 46 +\mathcode"47="7\psmifam@ 47 +\mathcode"48="7\psmifam@ 48 +\mathcode"49="7\psmifam@ 49 +\mathcode"4A="7\psmifam@ 4A +\mathcode"4B="7\psmifam@ 4B +\mathcode"4C="7\psmifam@ 4C +\mathcode"4D="7\psmifam@ 4D +\mathcode"4E="7\psmifam@ 4E +\mathcode"4F="7\psmifam@ 4F +\mathcode"51="7\psmifam@ 51 +\mathcode"52="7\psmifam@ 52 +\mathcode"53="7\psmifam@ 53 +\mathcode"54="7\psmifam@ 54 +\mathcode"55="7\psmifam@ 55 +\mathcode"56="7\psmifam@ 56 +\mathcode"57="7\psmifam@ 57 +\mathcode"58="7\psmifam@ 58 +\mathcode"59="7\psmifam@ 59 +\mathcode"5A="7\psmifam@ 5A + + +% lower case letters from psmifam + +\mathcode"61="7\psmifam@ 61 +\mathcode"62="7\psmifam@ 62 +\mathcode"63="7\psmifam@ 63 +\mathcode"64="7\psmifam@ 64 +\mathcode"65="7\psmifam@ 65 +\mathcode"66="7\psmifam@ 66 +\mathcode"67="7\psmifam@ 67 +\mathcode"68="7\psmifam@ 68 +\mathcode"69="7\psmifam@ 69 +\mathcode"6A="7\psmifam@ 6A +\mathcode"6B="7\psmifam@ 6B +\mathcode"6C="7\psmifam@ 6C +\mathcode"6D="7\psmifam@ 6D +\mathcode"6E="7\psmifam@ 6E +\mathcode"6F="7\psmifam@ 6F +\mathcode"71="7\psmifam@ 71 +\mathcode"72="7\psmifam@ 72 +\mathcode"73="7\psmifam@ 73 +\mathcode"74="7\psmifam@ 74 +\mathcode"75="7\psmifam@ 75 +\mathcode"76="7\psmifam@ 76 +\mathcode"77="7\psmifam@ 77 +\mathcode"78="7\psmifam@ 78 +\mathcode"79="7\psmifam@ 79 +\mathcode"7A="7\psmifam@ 7A + +% upper case Greek letters from pssyfam + +\mathchardef\Gamma="7\pssyfam@ 47 +\mathchardef\Delta="7\pssyfam@ 44 +\mathchardef\Theta="7\pssyfam@ 51 +\mathchardef\Lambda="7\pssyfam@ 4C +\mathchardef\Xi="7\pssyfam@ 58 +\mathchardef\Pi="7\pssyfam@ 50 +\mathchardef\Sigma="7\pssyfam@ 53 +\mathchardef\Upsilon="7\pssyfam@ A1 +\mathchardef\Phi="7\pssyfam@ 46 +\mathchardef\Psi="7\pssyfam@ 59 +\mathchardef\Omega="7\pssyfam@ 57 + +% lower case Greek letters from psgrlfam + +\mathchardef\alpha="0\psgrlfam@ 61 +\mathchardef\beta="0\psgrlfam@ 62 +\mathchardef\gamma="0\psgrlfam@ 67 +\mathchardef\delta="0\psgrlfam@ 64 +\mathchardef\epsilon="0\psgrlfam@ 65 +\mathchardef\zeta="0\psgrlfam@ 7A +\mathchardef\eta="0\psgrlfam@ 68 +\mathchardef\theta="0\psgrlfam@ 71 +\mathchardef\iota="0\psgrlfam@ 69 +\mathchardef\kappa="0\psgrlfam@ 6B +\mathchardef\lambda="0\psgrlfam@ 6C +\mathchardef\mu="0\psgrlfam@ 6D +\mathchardef\nu="0\psgrlfam@ 6E +\mathchardef\xi="0\psgrlfam@ 78 +\mathchardef\pi="0\psgrlfam@ 70 +\mathchardef\rho="0\psgrlfam@ 72 +\mathchardef\sigma="0\psgrlfam@ 73 +\mathchardef\tau="0\psgrlfam@ 74 +\mathchardef\upsilon="0\psgrlfam@ 75 +\mathchardef\phi="0\psgrlfam@ 66 +\mathchardef\chi="0\psgrlfam@ 63 +\mathchardef\psi="0\psgrlfam@ 79 +\mathchardef\omega="0\psgrlfam@ 77 +\mathchardef\varepsilon="0\psgrlfam@ 65 +\mathchardef\vartheta="0\psgrlfam@ 4A +\mathchardef\varpi="0\psgrlfam@ 76 +\mathchardef\varrho="0\psgrlfam@ 72 +\mathchardef\varsigma="0\psgrlfam@ 56 +\mathchardef\varphi="0\psgrlfam@ 6A + + +% psexfam + +\mathchardef\sum="1\psexfam@ 50 +\mathchardef\prod="1\psexfam@ 51 +\mathchardef\coprod="1\psexfam@ 60 + + +%% text mode stuff + +\chardef\%=`\% +\chardef\&=`\& +\chardef\#=`\# +\chardef\$=`\$ +\chardef\ss="FB +\chardef\ae="F1 +\chardef\oe="FA +\chardef\o="F9 +\chardef\AE="E1 +\chardef\OE="EA +\chardef\O="E9 +\chardef\i="F5 +\let\j=\undefined +\def\aa{\accent'312a} + +\chardef\l="F8 +\chardef\L="E8 +%\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em}} +\chardef\_=`\_ +\def\AA{\accent'312A} +\chardef\dag="B2 +\chardef\ddag="B3 +\chardef\S="A7 +\chardef\P="B6 + +\ifx\protect\undefined\let\protect=\relax\fi +\def\pd#1{\oalign{#1\crcr\hidewidth.\hidewidth}} +\def\d{\protect\pd} +\def\pb#1{\oalign{#1\crcr\hidewidth + \vbox to.2ex{\hbox{\char'305}\vss}\hidewidth}} +\def\b{\protect\pb} + +\def\pc#1{\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent'313 #1% + \else{\ooalign{\hidewidth\char'313\hidewidth\crcr\unhbox\z@}}\fi} +\def\c{\protect\pc} + +\def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX} + +\def\`#1{{\accent'301 #1}} +\def\'#1{{\accent'302 #1}} +\def\v#1{{\accent'317 #1}} \let\^^_=\v +\def\u#1{{\accent'306 #1}} \let\^^S=\u +\def\=#1{{\accent'305 #1}} +\def\^#1{{\accent'303 #1}} \let\^^D=\^ +\def\.#1{{\accent'307 #1}} +\def\H#1{{\accent'315 #1}} +\def\~#1{{\accent'304 #1}} +\def\"#1{{\accent'310 #1}} + diff --git a/dviware/dvitops/psfont.1 b/dviware/dvitops/psfont.1 new file mode 100644 index 0000000000..b032783a9e --- /dev/null +++ b/dviware/dvitops/psfont.1 @@ -0,0 +1,59 @@ +.\" $Header: /usr/jjc/dvitops/RCS/psfont.1,v 1.1 89/02/01 09:20:15 jjc Rel $ +.TH PSFONT L "10 December 1988" +.SH NAME +psfont \- add fonts to PostScript document +.SH SYNOPSIS +.B psfont +.SH DESCRIPTION +.LP +.B psfont +reads a PostScript document from its standard input, determines which +downloadable fonts it requires, adds those fonts to the document, and +writes the result to the standard output. +The document must comply with the Adobe Structuring Conventions. +The +.B %%DocumentFonts +comment must not use the +.B (atend) +notation. +.LP +For each font +.I font +mentioned in the +.B %%DocumentFonts +comment +.B psfont +will look for the file +.IB font .ps +in the list of directories contained in the environment variable +.SB PSFONTS +and, if it finds it, will include it in the document. +If +.SB PSFONTS +is not set, it will look in a system-dependent list of directories. +If your file system does not permit long file names, +you can use the file +.BR psfonts.map , +which should be installed in the same directory as the fonts, +to map PostScript font names to file names. +For example, if this file contains a line +.RB ` "Times-Roman timesr" ' +then +.B psfont +will look for +.B timesr.ps +instead of +.BR Times-Roman.ps. +Fonts must be in a format suitable for inclusion in the document without +any further processing. +.SH FILES +.TP +.B /usr/local/psfonts/*.ps +font files +.TP +.B /usr/local/psfonts/psfonts.map +maps PostScript names to file names +.SH BUGS +It does not understand version 2.0 of the Structuring Conventions. +.SH AUTHOR +James Clark <jjc@jclark.uucp> diff --git a/dviware/dvitops/psfont.c b/dviware/dvitops/psfont.c new file mode 100644 index 0000000000..3589fb3f42 --- /dev/null +++ b/dviware/dvitops/psfont.c @@ -0,0 +1,145 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/psfont.c,v 1.2 89/02/20 14:24:06 jjc Rel $"; + +#include "util.h" + +#define LINE_MAX 512 +char *program_name = "psfont"; +static char *ws = " \n\r\t"; /* white space */ +static char *psfonts; + +#ifdef PROTO +int strprefix(char *s1, char *s2); +void fcopy(FILE *in, FILE *out); +void process_fonts(void); +#endif + +/* is s1 a prefix of s2? */ +int strprefix(s1, s2) +char *s1, *s2; +{ + while (*s1++ == *s2++) + ; + return s1[-1] == '\0'; +} + +/* copy infp to outfp */ +void fcopy(infp, outfp) +FILE *infp, *outfp; +{ + int c; + while ((c = getc(infp)) != EOF) + putc(c, outfp); +} + +struct string_list { + struct string_list *next; + char *s; + char *t; +}; +struct string_list *document_fonts = NULL; + +/* map PostScript names to file names */ + +void process_fonts() +{ + char buf[LINE_MAX]; + FILE *fp; + fp = xfopen("psfonts.map", FALSE, psfonts, NULL); + if (fp == 0) + return; + while (fgets(buf, LINE_MAX, fp) != 0) { + char *s, *t; + s = strchr(buf, '%'); + if (s != NULL) + *s = '\0'; + s = strtok(buf, ws); + t = strtok(NULL, ws); + if (s != 0 && t != 0) { + struct string_list *q; + for (q = document_fonts; q != NULL; q = q->next) + if (strcmp(q->s, s) == 0) { + q->t = malloc(strlen(t) + 1); + if (q->t == NULL) + out_of_memory(); + strcpy(q->t, t); + } + } + } + fclose(fp); +} + + +int main(argc, argv) +int argc; +char **argv; +{ + int flag = FALSE; + int cont = FALSE; + char *ptr; + char buf[LINE_MAX]; + psfonts = getenv("PSFONTS"); + if (psfonts == NULL) + psfonts = PSFONTS; + if (fgets(buf, LINE_MAX, stdin) == 0) + exit(0); + fputs(buf, stdout); + if (strprefix("%!PS-Adobe-", buf)) + while (fgets(buf, LINE_MAX, stdin) != 0) { + if (!strprefix("%%", buf)) { + flag = TRUE; + fputs("%%EndComments\n", stdout); + break; + } + fputs(buf, stdout); + if (strprefix("%%EndComments", buf)) + break; + if (document_fonts == NULL && strprefix("%%DocumentFonts:", buf)) + ptr = strchr(buf, ':') + 1; + else if (cont && strprefix("%%+", buf)) + ptr = buf + 3; + else + ptr = NULL; + if (ptr != NULL) { + for (ptr = strtok(ptr, ws); + ptr != 0; + ptr = strtok(NULL, ws)) { + struct string_list *p; + p = (struct string_list *) + malloc(sizeof(struct string_list)); + if (p == 0) + out_of_memory(); + p->s = malloc(strlen(ptr) + 1); + p->t = NULL; + if (p->s == 0) + out_of_memory(); + strcpy(p->s, ptr); + p->next = document_fonts; + document_fonts = p; + } + cont = TRUE; + } + else + cont = FALSE; + } + process_fonts(); + while (document_fonts != 0) { + FILE *fp; + char *s; + if (document_fonts->t != NULL) + s = document_fonts->t; + else + s = document_fonts->s; + fp = xfopen(s, FALSE, psfonts, NULL); + if (fp != 0) { + printf("%%%%BeginFont: %s\n", document_fonts->s); + fcopy(fp, stdout); + fclose(fp); + printf("%%%%EndFont\n"); + } + document_fonts = document_fonts->next; + } + if (flag) + fputs(buf, stdout); + fcopy(stdin, stdout); + exit(history); +} diff --git a/dviware/dvitops/psfonts.map b/dviware/dvitops/psfonts.map new file mode 100644 index 0000000000..b68ffc8d93 --- /dev/null +++ b/dviware/dvitops/psfonts.map @@ -0,0 +1,4 @@ +Times-Slanted timessl.ps +Times-SmallCaps timessc.ps +Times-Extension timesex.ps +Symbol-Slanted symbolsl.ps diff --git a/dviware/dvitops/pspict.ps b/dviware/dvitops/pspict.ps new file mode 100644 index 0000000000..ec89398950 --- /dev/null +++ b/dviware/dvitops/pspict.ps @@ -0,0 +1,142 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/pspict.ps,v 1.2 89/02/20 14:22:58 jjc Rel $ + +/min { 2 copy gt {exch} if pop } bind def +% x y roundpoint -- rx ry +/roundpoint { transform round exch round exch itransform } bind def + +% x y sign -- (y < 0 ? -x : x) +/sign { 0 lt { neg } if } bind def + +% x y len endpoint -- endx endy +/endpoint { %def + /len exch def + /y exch def + /x exch def + x 0 eq { %ifelse + currentpoint len y sign sub + } { %else + currentpoint len x abs div y mul sub exch len x sign add exch + } ifelse +} bind def + +% linewidth diameter circle -- +/circle { %def + gsave + currentpoint newpath roundpoint 3 -1 roll 2 div 0 360 arc + setlinewidth + stroke + grestore +} bind def + +% diameter dot -- +/dot { %def + gsave + % a zero-length line is a convenient way to draw a solid circle + 1 setlinecap + [] 0 setdash + setlinewidth + currentpoint roundpoint moveto 0 0 rlineto stroke + grestore +} bind def + +% linewidth dx dy len line -- +/line { %def + gsave + 1 setlinecap + endpoint roundpoint + currentpoint roundpoint + moveto lineto + setlinewidth + stroke + grestore +} bind def + +% arrowlength arrowheight linewidth dx dy len vector -- +/vector { %def + 4 copy line + 3 copy endpoint moveto pop arrowhead +} bind def + +/char 1 string def + +% linewidth width height ([tblr]*) oval -- +/oval { %def + gsave + 1 setlinecap 1 setlinejoin + /t false def + /b false def + /l false def + /r false def + { char exch 0 exch put char cvn true def } forall + 2 div /halfheight exch def + 2 div /halfwidth exch def + halfheight halfwidth min /radius exch def + currentpoint roundpoint translate newpath + % we are assuming y coordinates increase down the page + % this code won't print a dashed [l] oval as well as it might + l t or not { %ifelse + % bottom right quadrant + halfwidth 0 moveto + halfwidth radius sub halfheight radius sub radius 0 90 arc + 0 halfheight lineto + } { %else + 0 halfheight moveto + } ifelse + r t or not { %ifelse + % bottom left quadrant + halfwidth neg radius add halfheight radius sub + radius 90 180 arc + halfwidth neg 0 lineto + } { %else + halfwidth neg 0 moveto + } ifelse + r b or not { %ifelse + % top left quadrant + halfwidth neg radius add halfheight neg radius add + radius 180 270 arc + 0 halfheight neg lineto + } { %else + 0 halfheight neg moveto + } ifelse + l b or not { %if + % top right quadrant + halfwidth radius sub halfheight neg radius add + radius 270 360 arc + halfwidth 0 lineto + } if + setlinewidth + stroke + grestore +} bind def + + +% length height linewidth dx dy arrowhead -- +/arrowhead { %def + gsave + 1 setlinejoin 1 setlinecap + neg exch atan rotate + currentpoint roundpoint moveto + setlinewidth + 2 div + 1 index neg 1 index neg rmoveto + 2 copy rlineto + exch neg exch rlineto + closepath + gsave [] 0 setdash stroke grestore + fill + grestore +} bind def + +% linewidth width height ellipse -- +/tempmatrix matrix def +/ellipse { %def + tempmatrix currentmatrix pop + currentpoint roundpoint translate newpath + scale + 0 0 1 0 360 arc + tempmatrix setmatrix + setlinewidth + stroke +} bind def + diff --git a/dviware/dvitops/pspict.sty b/dviware/dvitops/pspict.sty new file mode 100644 index 0000000000..8088d5599d --- /dev/null +++ b/dviware/dvitops/pspict.sty @@ -0,0 +1,89 @@ +% $Header: /usr/jjc/dvitops/RCS/pspict.sty,v 1.2 90/08/14 13:02:13 jjc Rel $ +% modify the picture environment to use PostScript +% for LaTeX 2.09 + +\def\@prolog{pspict.ps} % the file containing the PostScript definitions +\newcount\arg@one +\newcount\arg@two +\newcount\arg@three +\newcount\arg@four +\newcount\arg@five +\newcount\arg@six +\newdimen\arrow@length +\newdimen\arrow@height +\newdimen\arg@temp +\arrow@length 4pt +\arrow@height 4pt + +\def\line(#1,#2)#3{% + \special{dvitops: prolog \@prolog}% + \arg@one=#1\relax + \arg@two=#2\relax + \arg@temp=#3\unitlength\relax + \arg@three=\arg@temp\relax + \arg@four=\@wholewidth\relax + \special{dvitops: inline + \the\arg@four\space\the\arg@one\space\the\arg@two\space\the\arg@three\space line}} + +\def\vector(#1,#2)#3{% + \special{dvitops: prolog \@prolog}% + \arg@one=#1\relax + \arg@two=#2\relax + \arg@temp=#3\unitlength\relax + \arg@three=\arg@temp\relax + \arg@four=\@wholewidth\relax + \arg@five=\arrow@length\relax + \arg@six=\arrow@height\relax + \special{dvitops: inline + \the\arg@five\space\the\arg@six\space\the\arg@four\space\the\arg@one\space + \the\arg@two\space\the\arg@three\space vector}} + +\def\arrowhead(#1,#2)#3#4{% + \special{dvitops: prolog \@prolog}% + \arg@one=#1\relax + \arg@two=#2\relax + \arg@temp=#3\unitlength\relax + \arg@three=\arg@temp\relax + \arg@temp=#4\unitlength\relax + \arg@four=\arg@temp\relax + \arg@five=\@wholewidth\relax + \special{dvitops: inline + \the\arg@three\space\the\arg@four\space\the\arg@five\space + \the\arg@one\space\the\arg@two\space arrowhead}} + +\def\circle{\@ifstar{\@dot}{\@circle}} +\def\@circle#1{% + \special{dvitops: prolog \@prolog}% + \arg@temp=#1\unitlength\relax + \arg@one=\arg@temp\relax + \arg@four=\@wholewidth\relax + \special{dvitops: inline \the\arg@four\space\the\arg@one\space circle}} + +\def\@dot#1{% + \special{dvitops: prolog \@prolog}% + \arg@temp=#1\unitlength\relax + \arg@one=\arg@temp\relax + \special{dvitops: inline \the\arg@one\space dot}} + +\def\oval(#1,#2){\@ifnextchar[{\@oval(#1,#2)}{\@oval(#1,#2)[]}} + +\def\@oval(#1,#2)[#3]{% + \special{dvitops: prolog \@prolog}% + \arg@temp=#1\unitlength\relax + \arg@one=\arg@temp\relax + \arg@temp=#2\unitlength\relax + \arg@two=\arg@temp\relax + \arg@four=\@wholewidth\relax + \special{dvitops: inline + \the\arg@four\space\the\arg@one\space\the\arg@two\space (#3) oval}} + +\def\ellipse(#1,#2){% + \special{dvitops: prolog \@prolog}% + \arg@temp=#1\unitlength\relax + \arg@one=\arg@temp\relax + \arg@temp=#2\unitlength\relax + \arg@two=\arg@temp\relax + \arg@three=\@wholewidth\relax + \special{dvitops: inline + \the\arg@three\space\the\arg@one\space\the\arg@two\space ellipse}} + diff --git a/dviware/dvitops/read.c b/dviware/dvitops/read.c new file mode 100644 index 0000000000..1d808aa318 --- /dev/null +++ b/dviware/dvitops/read.c @@ -0,0 +1,78 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/read.c,v 1.1 89/02/01 09:27:31 jjc Rel $"; + +#include "dvitops.h" + +integer sread4(fp) +FILE *fp; +{ + integer n; + n = uread1(fp); + if (n >= 128) + n -= 256; + n <<= 8; + n |= uread1(fp); + n <<= 8; + n |= uread1(fp); + n <<= 8; + n |= uread1(fp); + return n; +} + +integer sread3(fp) +FILE *fp; +{ + integer n; + n = uread1(fp); + if (n >= 128) + n -= 256; + n <<= 8; + n |= uread1(fp); + n <<= 8; + n |= uread1(fp); + return n; +} + +int sread2(fp) +FILE *fp; +{ + int n; + n = uread1(fp); + if (n >= 128) + n -= 256; + n <<= 8; + n |= uread1(fp); + return n; +} + +int sread1(fp) +FILE *fp; +{ + int n; + n = uread1(fp); + if (n >= 128) + n -= 256; + return n; +} + +integer uread3(fp) +FILE *fp; +{ + integer n; + n = uread1(fp); + n <<= 8; + n |= uread1(fp); + n <<= 8; + n |= uread1(fp); + return n; +} + +integer uread2(fp) +FILE *fp; +{ + integer n; + n = uread1(fp); + n <<= 8; + n |= uread1(fp); + return n; +} + diff --git a/dviware/dvitops/readme b/dviware/dvitops/readme new file mode 100644 index 0000000000..f88530d2da --- /dev/null +++ b/dviware/dvitops/readme @@ -0,0 +1,30 @@ +This is the README file for dvitops, version 1.2. + +See the file INSTALL, for information on installation. + +dvitops translates dvi files output by TeX into PostScript. + +dvitops is not copyrighted; you can do with it exactly as you please. +I would, however, ask that if you make improvements or modifications, +you ask me before distributing them to others. + +Besides dvitops itself, this distribution contains three other +programs: psfont, which is a very simple-minded filter to handle +font-downlaoding; pfbtops, which unpacks PostScript fonts from the +format in which they are supplied by Adobe for the IBM PC; aftopl, +which converts afm files to pl files. There is also a style file +(ps.sty) and some PostScript code which sets up LaTeX to use +PostScript. + +Please report any bugs you find. If you report a bug, please say what +version of dvitops you are using. + +James Clark +jjc@jclark.uucp +ukc.ac.uk!jclark!jjc + +30 Peel Street +London W8 7PD +England + +$Header: /usr/jjc/dvitops/RCS/README,v 1.7 90/10/27 11:44:42 jjc Exp $ diff --git a/dviware/dvitops/special.c b/dviware/dvitops/special.c new file mode 100644 index 0000000000..bad23d8882 --- /dev/null +++ b/dviware/dvitops/special.c @@ -0,0 +1,1050 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/special.c,v 1.9 90/08/14 13:56:04 jjc Rel $"; + +#include "dvitops.h" + +struct bounding_box { double llx, lly, urx, ury; }; + +#ifdef PROTO +static void do_import(char *arg, integer x, integer y, + int region, struct page_info *page, FILE *psfp); +int strprefix(char *prefix, char *s); +static void read_import_file(char *filename); +#else +static void do_import(); +int strprefix(); +static void read_import_file(); +#endif + +/* this holds the list of files to be imported on the current page */ +static struct import { + integer x, y; + int region; + struct import *next; + char arg[1]; +} *import_list; + + +static struct import_file { + struct bounding_box bb; + struct depend_list *font; + struct import_file *next; + char file[1]; +} *doc_import_list; + +/* this routine is used to include a PostScript file +it will be enhanced later to be quicker and possibly to support +%%IncludeFont and %%IncludeFile comments +return 0 on success, -1 on error +*/ + +int include_file(filename, psfp) +char *filename; +FILE *psfp; +{ + char buf[256]; + FILE *infp; + if ((infp = xfopen(filename, FALSE, texinputs, (char *)NULL)) == NULL) + return EOF; +#ifdef HAVE_SETVBUF + setvbuf(infp, (char *)NULL, _IOFBF, 16384); +#endif + while (fgets(buf, sizeof(buf), infp) != NULL) + if (buf[0] != '%') + fputs(buf, psfp); + fclose(infp); + return 0; +} + +/* return 0 on error */ + +int bigpoint(str, ptr, val) +char *str, **ptr; +double *val; +{ + double x; + int n; + while (isspace(*str)) + ++str; + if (sscanf(str, "%lf", &x) != 1) + goto bad; + while (isdigit(*str) || *str == '.') + str++; + while (isspace(*str)) + str++; + n = isupper(str[0]) ? tolower(str[0]) : str[0]; + n <<= 8; + n |= isupper(str[1]) ? tolower(str[1]) : str[1]; + switch (n) { + case ('b' << 8) + 'p' : + break; + case ('i' << 8) + 'n' : + x *= 72.0; + break; + case ('c' << 8) + 'm' : + x *= 72.0/2.54; + break; + case ('m' << 8) + 'm' : + x *= 72.0/25.4; + break; + case ('s' << 8) + 'p' : + x *= 72.0/(72.27*65536.0); + break; + case ('c' << 8) + 'c' : + x *= 12.0*1238.0*72.0/(1157.0*72.27); + break; + case ('d' << 8) + 'd' : + x *= 1238.0*72.0/(1157.0*72.27); + break; + case ('p' << 8) + 't' : + x *= 72.0/72.27; + break; + case ('p' << 8) + 'c' : + x *= 12.0*72.0/72.27; + break; + default: + goto bad; + } + str += 2; + if (ptr != NULL) + *ptr = str; + *val = x; + return 1; +bad: + if (ptr != NULL) + *ptr = str; + return 0; +} + +static void do_import(arg, x, y, region, page, psfp) +char *arg; +integer x, y; +int region; +struct page_info *page; +FILE *psfp; +{ + double xscale, yscale; + integer gap; + double h, w; + integer width, height; + char *filename; + struct import_file *p; + struct depend_list *q; + struct bounding_box bb; + integer llx, lly, urx, ury; + double sf = (double)page->den*254000.0/((double)page->num*72.0); + char *ptr = arg; + typedef enum { CENTER, LEFT, RIGHT, TOP, BOTTOM, FILL } adjust_t; + adjust_t hadj = CENTER, vadj = CENTER; + while (isspace(*ptr)) + ptr++; + filename = ptr; + while (!isspace(*ptr) && *ptr != '\0') + ptr++; + if (*ptr == '\0') { + message(ERROR, "import \\special syntax error: abandoning import"); + return; + } + *ptr++ = '\0'; + if (bigpoint(ptr, &ptr, &w) == 0 + || bigpoint(ptr, &ptr, &h) == 0) { + message(ERROR, "special import syntax error: abandoning import"); + return; + } + ptr = strtok(ptr, "\r\n\t "); + while (ptr != NULL) { + int i; + for (i = 0; ptr[i] != '\0'; i++) + ptr[i] = isupper(ptr[i]) ? tolower(ptr[i]) : ptr[i]; + if (strcmp(ptr, "top") == 0) + vadj = TOP; + else if (strcmp(ptr, "bottom") == 0) + vadj = BOTTOM; + else if (strcmp(ptr, "fill") == 0) + hadj = vadj = FILL; + else if (strcmp(ptr, "left") == 0) + hadj = LEFT; + else if (strcmp(ptr, "right") == 0) + hadj = RIGHT; + else + message(ERROR, "bad option in import \\special: %s: ignored",ptr); + ptr = strtok((char *)NULL, " \r\n\t"); + } + /* convert to dvi units */ + width = (integer)(w*sf); + height = (integer)(h*sf); + for (p = doc_import_list; p != NULL; p = p->next) + if (strcmp(p->file, filename) == 0) + break; + if (p == NULL) { + message(ERROR, "can't import %s", filename); + return; + } + fputs("BO /showpage {} def\n", psfp); + for (q = p->font; q != NULL; q = q->next) + if (!q->f->in_prolog) + emit_ps_font(q->f->s, psfp); + if (region != NO_REGION) { + integer ox = 0, oy = 0; + do_transform(region, &ox, &oy, psfp); + x -= ox; + y -= oy; + } + bb = p->bb; + if (bb.urx == bb.llx) { + message(ERROR, "bad bounding box: no width"); + return; + } + if (bb.ury == bb.lly) { + message(ERROR, "bad bounding box: no height"); + return; + } + xscale = width/(bb.urx - bb.llx); + yscale = height/(bb.ury - bb.lly); + if (xscale > yscale) { + lly = y; + ury = y - height; + gap = (integer)(width - yscale*(bb.urx - bb.llx)); + switch(hadj) { + case CENTER : + llx = x + gap/2; + urx = x + width - gap/2; + break; + case LEFT : + llx = x; + urx = x + width - gap; + break; + case RIGHT : + llx = x + gap; + urx = x + width; + break; + case FILL : + llx = x; + urx = x + width; + break; + default : + cant_happen(); + } + } + else { + llx = x; + urx = x + width; + gap = (integer)(height - xscale*(bb.ury - bb.lly)); + switch(vadj) { + case CENTER : + lly = y - gap/2; + ury = y - height + gap/2; + break; + case TOP : + lly = y - gap; + ury = y - height; + break; + case BOTTOM : + lly = y; + ury = y - height + gap; + break; + case FILL : + lly = y; + ury = y - height; + break; + default : + cant_happen(); + } + } + fprintf(psfp, "%lg %lg %lg %lg ", bb.llx, bb.lly, bb.urx, bb.ury); + + put_dim((long)llx, psfp); + putc(' ', psfp); + put_dim((long)lly, psfp); + putc(' ', psfp); + put_dim((long)urx, psfp); + putc(' ', psfp); + put_dim((long)ury, psfp); + fputs(" Locate\n", psfp); + fprintf(psfp, "%%%%BeginDocument: %s\n", filename); + if (include_file(filename, psfp) == EOF) + message(ERROR, "can't find import file %s: abandoning import", + filename); + fputs("\n%%EndDocument\nEO\n", psfp); +} + +/* this is called at the end of each page by eop to deal with +any import specials on the current page; it calls do_import to do +the real work */ + +void p_import_list(psfp, page) +FILE *psfp; +struct page_info *page; +{ + if (import_list == NULL) + return; + while (import_list != NULL) { + struct import *q = import_list; + do_import(import_list->arg, import_list->x, import_list->y, + import_list->region, page, psfp); + import_list = import_list->next; + free((char *)q); + } +} + + + +/* this holds a list of all the pieces of inline code for the current page */ + +static struct inline_code { + int region; + integer h, v; + struct inline_code *next; + char s[1]; +} *inline_list = NULL; + +/* this is called by eop at the end of every page to emit any inline +specials */ + +void p_inline_list(psfp) +FILE *psfp; +{ + struct inline_code *p = NULL; + integer ox = 0, oy = 0; + int r = NO_REGION; + /* reverse the list */ + if (inline_list == NULL) + return; + fputs("BO\n", psfp); + while (inline_list != NULL) { + struct inline_code *q = inline_list; + inline_list = inline_list->next; + q->next = p; + p = q; + } + while (p != NULL) { + struct inline_code *q = p; + if (p->region != r) { + fprintf(psfp, "%% region %d\n", p->region); + if (r != NO_REGION) + fputs("grestore\n", psfp); + if (p->region != NO_REGION) { + fputs("gsave\n", psfp); + do_transform(p->region, &ox, &oy, psfp); + } + else + ox = oy = 0; + r = p->region; + } + put_dim((long)(p->h-ox), psfp); + putc(' ', psfp); + put_dim((long)(p->v-oy), psfp); + fputs(" M\n", psfp); + fputs("gsave\n", psfp); + put_dim(1L, psfp); + fputs(" dup scale\n", psfp); + fputs(p->s, psfp); + putc('\n', psfp); + fputs("grestore\n", psfp); + p = p->next; + free((char *)q); + } + inline_list = NULL; + if (r != NO_REGION) + fputs("grestore\n", psfp); + fputs("EO\n", psfp); +} +/* this list is used during pass 1 to hold a list of all prologue files */ + +struct string_list { + struct string_list *next; + char s[1]; +}; + +static struct string_list *prologue_list; + +/* this is called by special during pass 1 to add a prologue file to +prologue_list */ + + +/* this is called while the prologue is being written to include all the +prologue files that have been specified in the document */ + +void p_special_prologues(psfp) +FILE *psfp; +{ + while (prologue_list != NULL) { + struct string_list *temp = prologue_list; + if (include_file(prologue_list->s, psfp) == EOF) + message(ERROR, "can't open prologue file %s: ignoring it", + prologue_list->s); + prologue_list = prologue_list->next; + free((char *)temp); + } +} + +#ifdef PROTO +typedef void special_t(int pass, char *arg, integer x, integer y); +static special_t landscape_special; +static special_t magnification_special; +static special_t prolog_special; +static special_t inline_special; +static special_t import_special; +static special_t rotate_special; +static special_t transform_special; +static special_t origin_special; +static special_t begin_special; +static special_t end_special; +static special_t form_special; +static special_t hsbcolor_special; +static special_t rgbcolor_special; +static special_t gray_special; +#else +static void landscape_special(); +static void magnification_special(); +static void prolog_special(); +static void inline_special(); +static void import_special(); +static void rotate_special(); +static void transform_special(); +static void origin_special(); +static void begin_special(); +static void end_special(); +static void form_special(); +static void hsbcolor_special(); +static void rgbcolor_special(); +static void gray_special(); +#endif + + +static struct { + char *name; +#ifdef PROTO + special_t *proc; +#else + void (*proc)(); +#endif +} special_table[] = { + "landscape", landscape_special, + "magnification", magnification_special, + "prolog", prolog_special, + "inline", inline_special, + "import", import_special, + "rotate", rotate_special, + "transform", transform_special, + "origin", origin_special, + "begin", begin_special, + "end", end_special, + "form", form_special, + "rgbcolor", rgbcolor_special, + "hsbcolor", hsbcolor_special, + "gray", gray_special, + NULL +}; + +static void landscape_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + if (pass == PASS2) + landscape = TRUE; +} + +static void magnification_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + if (pass == PASS2) { + int n; + n = atoi(arg); + if (n <= 0) + message(ERROR, "bad magnification"); + else + magnification = n; + } +} + + +static void prolog_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + char *p = arg; + struct string_list *ptr; + if (pass != PASS1) + return; + while (!isspace(*p) && *p != '\0') + p++; + *p = '\0'; + for (ptr = prologue_list; ptr != NULL; ptr = ptr->next) + if (strcmp(arg, ptr->s) == 0) + return; + if ((ptr = (struct string_list *) + malloc(sizeof(struct string_list) + strlen(arg))) == NULL) + out_of_memory(); + strcpy(ptr->s, arg); + ptr->next = prologue_list; + prologue_list = ptr; +} + + +static void inline_special(pass, arg, x, y) +int pass; +char *arg; +integer x; +integer y; +{ + struct inline_code *p; + if (pass != PASS2) + return; + p = (struct inline_code *) + malloc(sizeof(struct inline_code) + strlen(arg)); + if (p == NULL) + out_of_memory(); + p->h = x; + p->v = y; + p->region = current_region; + strcpy(p->s, arg); + p->next = inline_list; + inline_list = p; +} + + + +static void import_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + if (pass == PASS2) { + struct import *p; + if ((p = (struct import *) + malloc(sizeof(struct import)+strlen(arg))) == NULL) + out_of_memory(); + p->x = x; + p->y = y; + p->region = current_region; + strcpy(p->arg, arg); + p->next = import_list; + import_list = p; + } + else + read_import_file(strtok(arg, " \n\t\r")); +} + +/* x and y are 0 on PASS1 */ + +void special(pass, s, x, y) +int pass; +char *s; +integer x, y; +{ + char *q; + int i; + char *p = s; + if (pass != PASS1 && pass != PASS2) + cant_happen(); +#ifdef TPIC_SUPPORT + if (tpic_special(pass, s, x, y)) + return; +#endif + while (isspace(*p)) + p++; + q = p; + while (*q != '\0' && *q != ':') { + *q = isupper(*q) ? tolower(*q) : *q; + q++; + } + if (*q == '\0') { + if (pass == PASS2) + message(WARNING, + "a \\special without the `dvitops:' tag was ignored"); + return; + } + *q++ = '\0'; + if (strcmp(p, "dvitops") != 0) { + if (pass == PASS2) + message(WARNING, + "a \\special without the `dvitops:' tag was ignored"); + return; + } + while (isspace(*q)) + q++; + p = q; + while (*q != '\0' && !isspace(*q)) { + *q = isupper(*q) ? tolower(*q) : *q; + q++; + } + if (*q != '\0') + *q++ = '\0'; + for (i = 0; special_table[i].name != NULL; i++) + if (strcmp(p, special_table[i].name) == 0) { + (*special_table[i].proc)(pass, q, x, y); + return; + } + if (pass == PASS2) + message(ERROR, "\\special keyword not recognised: %s", p); +} + + +#ifndef M_PI +#define M_PI 3.14159265358979324 +#endif + +#define REGION_MAX 256 +#define RNAME_MAX 128 +static char *WS = " \n\r\t"; +/* we represent a two-dimensional transformation with the `matrix' +structure; it represents the matrix +|a b | +|c d | +*/ + +typedef struct { + double a, b, c, d; +} matrix_t; + + +enum color_type { NO_COLOR, RGB_COLOR, HSB_COLOR, GRAY_COLOR }; + +typedef struct { + char name[RNAME_MAX]; + integer origin_x; + integer origin_y; + matrix_t matrix; + enum color_type color_type; + double color[3]; +} region_t; + +static region_t *region[REGION_MAX]; +#ifdef PROTO +static int lookup_region(char *name); +static void multiply(matrix_t *m, matrix_t *n, matrix_t *mn); +#else +static int lookup_region(); +static void multiply(); +#endif + +/* m, n and mn must all be distinct */ + +static void multiply(m, n, mn) +matrix_t *m, *n, *mn; +{ + mn->a = m->a*n->a + m->b*n->c; + mn->b = m->a*n->b + m->b*n->d; + mn->c = m->c*n->a + m->d*n->c; + mn->d = m->c*n->b + m->d*n->d; +} + + +static int lookup_region(name) +char *name; +{ + int i; + for (i = 0; i < nregions; i++) { + if (region[i] == NULL) + cant_happen(); + if (strncmp(region[i]->name, name, RNAME_MAX) == 0) + return i; + } + if (nregions >= REGION_MAX) + message(FATAL_ERROR, "too many regions"); + if (region[nregions] == NULL + && (region[nregions] = (region_t *) + malloc(sizeof(region_t))) == NULL) + out_of_memory(); + strncpy(region[nregions]->name, name, RNAME_MAX); + region[nregions]->origin_x = 0; + region[nregions]->origin_y = 0; + region[nregions]->matrix.a = 1.0; + region[nregions]->matrix.b = 0.0; + region[nregions]->matrix.c = 0.0; + region[nregions]->matrix.d = 1.0; + region[nregions]->color_type = NO_COLOR; + return nregions++; +} + + +static void rotate_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + char name[128]; + int n; + double theta; + matrix_t m; + matrix_t temp; + if (pass != PASS2) + return; + if (sscanf(arg, "%127s %lf", name, &theta) != 2) { + message(ERROR, "rotate \\special syntax error"); + return; + } + n = lookup_region(name); + theta *= M_PI/180.0; + m.a = cos(theta); + m.b = sin(theta); + m.c = -sin(theta); + m.d = cos(theta); + multiply(&(region[n]->matrix), &m, &temp); + memcpy((char *)&(region[n]->matrix), (char *)&temp, sizeof(matrix_t)); +} + + +static void transform_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + char name[128]; + int n; + matrix_t m, temp; + if (pass != PASS2) + return; + if (sscanf(arg, " %127s %lf %lf %lf %lf", name, + &m.a, &m.b, &m.c, &m.d) != 5) { + message(ERROR, "transform \\special syntax error"); + return; + } + n = lookup_region(name); + multiply(&(region[n]->matrix), &m, &temp); + memcpy((char *)&(region[n]->matrix), (char *)&temp, sizeof(matrix_t)); +} + +static void rgbcolor_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + double color[3]; + char name[128]; + int i, n; + int bad = FALSE; + if (pass != PASS2) + return; + if (sscanf(arg, "%127s %lf %lf %lf", name, color, color + 1, color + 2) + != 4) { + message(ERROR, "rgbcolor \\special syntax error"); + return; + } + n = lookup_region(name); + for (i = 0; i < 3 && !bad; i++) + if (color[i] < 0.0 || color[i] > 1.0) { + bad = TRUE; + message(ERROR, "color parameter must be between 0.0 and 1.0"); + } + else + region[n]->color[i] = color[i]; + region[n]->color_type = bad ? NO_COLOR : RGB_COLOR; +} + +static void hsbcolor_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + double color[3]; + char name[128]; + int i, n; + int bad = FALSE; + if (pass != PASS2) + return; + if (sscanf(arg, "%127s %lf %lf %lf", name, color, color + 1, color + 2) + != 4) { + message(ERROR, "rgbcolor \\special syntax error"); + return; + } + n = lookup_region(name); + for (i = 0; i < 3 && !bad; i++) + if (color[i] < 0.0 || color[i] > 1.0) { + bad = TRUE; + message(ERROR, "color parameter must be between 0.0 and 1.0"); + } + else + region[n]->color[i] = color[i]; + region[n]->color_type = bad ? NO_COLOR : RGB_COLOR; +} + +static void gray_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + double gray; + char name[128]; + int n; + if (pass != PASS2) + return; + if (sscanf(arg, "%127s %lf", name, &gray) != 2) { + message(ERROR, "gray \\special syntax error"); + return; + } + n = lookup_region(name); + if (gray < 0.0 || gray > 1.0) { + message(ERROR, "gray parameter must be between 0.0 and 1.0"); + region[n]->color_type = NO_COLOR; + } + else { + region[n]->color[0] = gray; + region[n]->color_type = GRAY_COLOR; + } +} + + +static void origin_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + int n; + if (pass != PASS2) + return; + arg = strtok(arg, WS); + if (arg == NULL) + message(ERROR, "origin \\special syntax error"); + n = lookup_region(arg); + if (region[n]->origin_x != 0 || region[n]->origin_y != 0) + message(WARNING, "multiple origins for object %s", arg); + region[n]->origin_x = x; + region[n]->origin_y = y; +} + + + +static void begin_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + if (pass != PASS2) + return; + arg = strtok(arg, WS); + if (current_region != NO_REGION) + message(ERROR, "can't have nested begin \\special"); + current_region = lookup_region(arg); +} + +static void end_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + if (pass != PASS2) + return; + if (current_region == NO_REGION) + message(ERROR, "end with no begin"); + else + current_region = NO_REGION; +} + +void do_transform(n, origin_x, origin_y, psfp) +int n; +integer *origin_x, *origin_y; +FILE *psfp; +{ + if (n >= nregions) + message(FATAL_ERROR, "too many regions"); + *origin_x = region[n]->origin_x; + *origin_y = region[n]->origin_y; + if (*origin_x != 0 || *origin_y != 0) { + put_dim((long)*origin_x, psfp); + putc(' ', psfp); + put_dim((long)*origin_y, psfp); + fputs(" translate\n", psfp); + } + fprintf(psfp, "[%g %g %g %g 0 0] concat\n", + region[n]->matrix.a, region[n]->matrix.b, + region[n]->matrix.c, region[n]->matrix.d); + switch(region[n]->color_type) { + case GRAY_COLOR: + fprintf(psfp, "%g setgray\n", region[n]->color[0]); + break; + case RGB_COLOR: + fprintf(psfp, "%g %g %g setrgbcolor\n", region[n]->color[0], + region[n]->color[1], region[n]->color[2]); + break; + case HSB_COLOR: + fprintf(psfp, "%g %g %g sethsbcolor\n", region[n]->color[0], + region[n]->color[1], region[n]->color[2]); + break; + case NO_COLOR: + break; + default: + cant_happen(); + } +} + +int strprefix(prefix, s) +char *prefix, *s; +{ + while (*prefix != '\0') + if (*prefix++ != *s++) + return FALSE; + return TRUE; +} + +/* this needs rewriting */ + +static void read_import_file(filename) +char *filename; +{ + FILE *fp; + char buf[256]; + struct import_file *p; + struct depend_list *q; + int atend = FALSE, had_bb = FALSE, in_body = FALSE; + int in_trailer = FALSE; + p = (struct import_file *) + malloc(sizeof(struct import_file) + strlen(filename)); + if (p == NULL) + out_of_memory(); + strcpy(p->file, filename); + p->font = NULL; + p->next = doc_import_list; + if ((fp = xfopen(filename, FALSE, texinputs, (char *)NULL)) == NULL) { + message(ERROR, "can't open %s", filename); + return; + } + if (fgets(buf, sizeof(buf), fp) == NULL) { + message(WARNING, "empty import file %s", filename); + fclose(fp); + return; + } + if (!strprefix("%!", buf)) { + message(ERROR, "%s not PostScript: doesn't start with %%!", filename); + fclose(fp); + return; + } + if (fgets(buf, sizeof(buf), fp) == NULL) { + message(WARNING, "empty import file %s", filename); + fclose(fp); + return; + } + for (;;) { + char *k; + k = strtok(buf + 2, ": \t\r\n"); + if (k == NULL || !strprefix("%%", buf) + || strcmp(k, "EndComments") == 0) { + if (atend) { + in_body = TRUE; + } + else + break; + } + else if (in_body && !in_trailer) { + if (strcmp(k, "Trailer") == 0) + in_trailer = TRUE; + } + else if (strcmp(k, "DocumentFonts") == 0) { + for (;;) { + struct postscript_f_list *f; + char *ptr = strtok((char *)NULL, " \t\r\n"); + if (ptr != NULL && strcmp(ptr, "(atend)") == 0) { + atend = TRUE; + break; + } + while (ptr == NULL) { + if (fgets(buf, sizeof(buf), fp) == NULL) { + buf[0] = '\0'; + goto out; + } + if (memcmp(buf, "%%+", 3) != 0) + goto out; + ptr = strtok(buf+3, "\n\r\t "); + } + f = add_postscript_font(ptr); + q = (struct depend_list *)malloc(sizeof(struct depend_list)); + q->f = f; + q->next = p->font; + p->font = q; + } + out: continue; /* don't read a line */ + } + else if (strcmp(k, "BoundingBox") == 0) { + int i; + for (i = 0; i < 4; i++) { + char *ptr = strtok((char *)NULL, "\r\t\n "); + double x; + if (ptr == NULL) { + message(ERROR, "BoundingBox comment empty"); + fclose(fp); + return; + } + if (i == 0 && strcmp(ptr, "(atend)") == 0) { + atend = TRUE; + break; + } + had_bb = TRUE; + x = atof(ptr); + switch(i) { + case 0: + p->bb.llx = x; + break; + case 1: + p->bb.lly = x; + break; + case 2: + p->bb.urx = x; + break; + case 3: + p->bb.ury = x; + break; + default: + cant_happen(); + } + } + } + if (fgets(buf, sizeof(buf), fp) == NULL) + break; + } + if (!had_bb) { + message(ERROR, "%s: no BoundingBox comment", filename); + fclose(fp); + return; + } + doc_import_list = p; + fclose(fp); +} + +static struct string_list *form_list; + +static void form_special(pass, arg, x, y) +int pass; +char *arg; +integer x; +integer y; +{ + struct string_list *s; + if (pass != PASS2) + return; + if ((s = (struct string_list *)malloc(sizeof(struct string_list) + strlen(arg))) == NULL) + out_of_memory(); + s->next = form_list; + form_list = s; + strcpy(s->s, arg); +} + +void p_form_list(psfp) +FILE *psfp; +{ + while (form_list != NULL) { + struct string_list *s = form_list; + fputs("/showpage {} def\n", psfp); + fprintf(psfp, "/--save-- save def\n%%%%BeginDocument: %s\n", s->s); + if (include_file(s->s, psfp) == EOF) + message(ERROR, "can't find %s", s->s); + fputs("\n%%EndDocument\n--save-- restore\n", psfp); + form_list = s->next; + free((char *)s); + } +} + +/* +Local Variables: +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +tab-width: 4 +End: +*/ + diff --git a/dviware/dvitops/symbolsl.afm b/dviware/dvitops/symbolsl.afm new file mode 100644 index 0000000000..3e1ddee04e --- /dev/null +++ b/dviware/dvitops/symbolsl.afm @@ -0,0 +1,204 @@ +StartFontMetrics 2.0 +Comment $Header: /usr/jjc/dvitops/RCS/symbolsl.afm,v 1.1 89/02/01 16:42:12 jjc Rel $ +FontName Symbol-Slanted +Version 001.001 +FamilyName Symbol +ItalicAngle 0 +IsFixedPitch false +UnderlineThickness 54 +Weight Medium +UnderlinePosition -98 +FullName Symbol +FontBBox -261 -293 1370 1010 +StartCharMetrics 189 +C 32 ; WX 250 ; N space ; B 250 0 250 0 ; +C 33 ; WX 333 ; N exclam ; B 137 -17 409 673 ; +C 34 ; WX 713 ; N universal ; B 226 0 876 705 ; +C 35 ; WX 500 ; N numbersign ; B 73 -17 610 673 ; +C 36 ; WX 549 ; N existential ; B 25 0 674 707 ; +C 37 ; WX 833 ; N percent ; B 166 -36 840 655 ; +C 38 ; WX 778 ; N ampersand ; B 73 -18 823 662 ; +C 39 ; WX 439 ; N suchthat ; B 49 -17 494 499 ; +C 40 ; WX 333 ; N parenleft ; B 97 -191 482 673 ; +C 41 ; WX 333 ; N parenright ; B -18 -191 367 674 ; +C 42 ; WX 500 ; N asteriskmath ; B 134 134 547 551 ; +C 43 ; WX 549 ; N plus ; B 77 0 622 533 ; +C 44 ; WX 250 ; N comma ; B 15 -152 204 104 ; +C 45 ; WX 549 ; N minus ; B 76 233 615 288 ; +C 46 ; WX 250 ; N period ; B 78 -17 194 95 ; +C 47 ; WX 278 ; N slash ; B -5 -17 433 646 ; +C 48 ; WX 500 ; N zero ; B 94 -17 587 685 ; +C 49 ; WX 500 ; N one ; B 120 0 484 673 ; +C 50 ; WX 500 ; N two ; B 25 0 569 686 ; +C 51 ; WX 500 ; N three ; B 62 -18 552 687 ; +C 52 ; WX 500 ; N four ; B 60 0 572 685 ; +C 53 ; WX 500 ; N five ; B 39 -17 632 685 ; +C 54 ; WX 500 ; N six ; B 92 -18 637 685 ; +C 55 ; WX 500 ; N seven ; B 166 -17 635 673 ; +C 56 ; WX 500 ; N eight ; B 89 -18 582 686 ; +C 57 ; WX 500 ; N nine ; B 59 -17 584 685 ; +C 58 ; WX 278 ; N colon ; B 90 -17 307 460 ; +C 59 ; WX 278 ; N semicolon ; B 42 -152 318 460 ; +C 60 ; WX 549 ; N less ; B 90 0 668 522 ; +C 61 ; WX 549 ; N equal ; B 50 141 645 390 ; +C 62 ; WX 549 ; N greater ; B 26 0 604 522 ; +C 63 ; WX 444 ; N question ; B 183 -17 562 685 ; +C 64 ; WX 549 ; N congruent ; B 11 0 655 475 ; +C 65 ; WX 722 ; N Alpha ; B 4 0 689 673 ; +C 66 ; WX 667 ; N Beta ; B 29 0 706 672 ; +C 67 ; WX 722 ; N Chi ; B -9 0 874 673 ; +C 68 ; WX 612 ; N Delta ; B 6 0 608 688 ; +C 69 ; WX 611 ; N Epsilon ; B 32 0 750 673 ; +C 70 ; WX 763 ; N Phi ; B 109 0 842 672 ; +C 71 ; WX 603 ; N Gamma ; B 35 0 779 673 ; +C 72 ; WX 722 ; N Eta ; B 39 0 916 673 ; +C 73 ; WX 333 ; N Iota ; B 32 0 503 673 ; +C 74 ; WX 631 ; N theta1 ; B 110 -17 714 689 ; +C 75 ; WX 722 ; N Kappa ; B 35 0 851 672 ; +C 76 ; WX 686 ; N Lambda ; B 6 0 685 688 ; +C 77 ; WX 889 ; N Mu ; B 31 0 1072 673 ; +C 78 ; WX 722 ; N Nu ; B 29 -8 907 673 ; +C 79 ; WX 722 ; N Omicron ; B 118 -17 823 685 ; +C 80 ; WX 768 ; N Pi ; B 25 0 929 673 ; +C 81 ; WX 741 ; N Theta ; B 118 -17 823 685 ; +C 82 ; WX 556 ; N Rho ; B 28 0 706 673 ; +C 83 ; WX 592 ; N Sigma ; B 5 0 722 673 ; +C 84 ; WX 611 ; N Tau ; B 172 0 789 673 ; +C 85 ; WX 690 ; N Upsilon ; B 174 0 881 673 ; +C 86 ; WX 439 ; N sigma1 ; B 84 -233 537 500 ; +C 87 ; WX 768 ; N Omega ; B 34 0 837 688 ; +C 88 ; WX 645 ; N Xi ; B 40 0 763 672 ; +C 89 ; WX 795 ; N Psi ; B 196 0 970 683 ; +C 90 ; WX 611 ; N Zeta ; B 44 0 792 673 ; +C 91 ; WX 333 ; N bracketleft ; B 43 -155 486 673 ; +C 92 ; WX 863 ; N therefore ; B 179 0 721 478 ; +C 93 ; WX 333 ; N bracketright ; B -10 -155 433 673 ; +C 94 ; WX 658 ; N perpendicular ; B 15 0 667 674 ; +C 95 ; WX 500 ; N underscore ; B -72 -252 445 -206 ; +C 96 ; WX 500 ; N radicalex ; B 724 881 1344 917 ; +C 97 ; WX 631 ; N alpha ; B 90 -17 722 500 ; +C 98 ; WX 549 ; N beta ; B 0 -222 628 741 ; +C 99 ; WX 549 ; N chi ; B -47 -231 627 500 ; +C 100 ; WX 494 ; N delta ; B 88 -18 619 740 ; +C 101 ; WX 439 ; N epsilon ; B 52 -19 512 502 ; +C 102 ; WX 521 ; N phi ; B 82 -224 569 670 ; +C 103 ; WX 411 ; N gamma ; B 93 -225 621 499 ; +C 104 ; WX 603 ; N eta ; B 100 -202 609 514 ; +C 105 ; WX 329 ; N iota ; B 107 -18 329 503 ; +C 106 ; WX 603 ; N phi1 ; B 97 -224 668 499 ; +C 107 ; WX 549 ; N kappa ; B 119 0 683 502 ; +C 108 ; WX 549 ; N lambda ; B 24 -18 590 739 ; +C 109 ; WX 576 ; N mu ; B -14 -223 595 500 ; +C 110 ; WX 521 ; N nu ; B 118 -17 599 507 ; +C 111 ; WX 549 ; N omicron ; B 91 -19 580 499 ; +C 112 ; WX 549 ; N pi ; B 64 -20 657 486 ; +C 113 ; WX 521 ; N theta ; B 110 -18 605 690 ; +C 114 ; WX 549 ; N rho ; B -14 -230 574 499 ; +C 115 ; WX 603 ; N sigma ; B 91 -21 727 500 ; +C 116 ; WX 439 ; N tau ; B 96 -18 557 500 ; +C 117 ; WX 576 ; N upsilon ; B 106 -17 615 507 ; +C 118 ; WX 713 ; N omega1 ; B 84 -17 832 583 ; +C 119 ; WX 686 ; N omega ; B 91 -18 761 500 ; +C 120 ; WX 493 ; N xi ; B 73 -225 555 766 ; +C 121 ; WX 686 ; N psi ; B 142 -228 836 501 ; +C 122 ; WX 494 ; N zeta ; B 108 -225 628 756 ; +C 123 ; WX 480 ; N braceleft ; B 122 -183 584 673 ; +C 124 ; WX 200 ; N bar ; B 16 -177 322 673 ; +C 125 ; WX 480 ; N braceright ; B 28 -183 490 673 ; +C 126 ; WX 549 ; N similar ; B 80 203 607 307 ; +C 161 ; WX 620 ; N Upsilon1 ; B 151 0 777 684 ; +C 162 ; WX 247 ; N minute ; B 159 459 418 735 ; +C 163 ; WX 549 ; N lessequal ; B 29 0 703 639 ; +C 164 ; WX 167 ; N fraction ; B -183 -12 528 677 ; +C 165 ; WX 713 ; N infinity ; B 94 124 767 404 ; +C 166 ; WX 500 ; N florin ; B -36 -194 668 687 ; +C 167 ; WX 753 ; N club ; B 129 -26 717 533 ; +C 168 ; WX 753 ; N diamond ; B 213 -36 671 550 ; +C 169 ; WX 753 ; N heart ; B 219 -33 748 532 ; +C 170 ; WX 753 ; N spade ; B 145 -36 672 548 ; +C 171 ; WX 1042 ; N arrowboth ; B 93 -15 1093 511 ; +C 172 ; WX 987 ; N arrowleft ; B 101 -15 1019 511 ; +C 173 ; WX 603 ; N arrowup ; B 228 0 754 910 ; +C 174 ; WX 987 ; N arrowright ; B 110 -15 1028 511 ; +C 175 ; WX 603 ; N arrowdown ; B 109 -22 635 888 ; +C 176 ; WX 400 ; N degree ; B 193 385 504 684 ; +C 177 ; WX 549 ; N plusminus ; B 10 0 652 645 ; +C 178 ; WX 411 ; N second ; B 152 459 606 737 ; +C 179 ; WX 549 ; N greaterequal ; B 29 0 640 639 ; +C 180 ; WX 549 ; N multiply ; B 29 8 668 524 ; +C 181 ; WX 713 ; N proportional ; B 94 123 737 404 ; +C 182 ; WX 494 ; N partialdiff ; B 66 -21 591 745 ; +C 183 ; WX 460 ; N bullet ; B 124 113 498 473 ; +C 184 ; WX 549 ; N divide ; B 75 71 617 456 ; +C 185 ; WX 549 ; N notequal ; B 53 -25 647 549 ; +C 186 ; WX 549 ; N equivalence ; B 37 82 661 443 ; +C 187 ; WX 549 ; N approxequal ; B 59 135 630 394 ; +C 188 ; WX 1000 ; N ellipsis ; B 119 -17 902 95 ; +C 189 ; WX 603 ; N arrowvertex ; B 247 -120 616 1010 ; +C 190 ; WX 1000 ; N arrowhorizex ; B 1 220 1127 276 ; +C 191 ; WX 658 ; N carriagereturn ; B 41 -16 776 629 ; +C 192 ; WX 823 ; N aleph ; B 179 -18 812 658 ; +C 193 ; WX 686 ; N Ifraktur ; B 28 -53 746 740 ; +C 194 ; WX 795 ; N Rfraktur ; B 79 -15 916 734 ; +C 195 ; WX 987 ; N weierstrass ; B 130 -211 973 573 ; +C 196 ; WX 768 ; N circlemultiply ; B 121 -17 837 673 ; +C 197 ; WX 768 ; N circleplus ; B 121 -15 838 675 ; +C 198 ; WX 823 ; N emptyset ; B 43 -24 970 719 ; +C 199 ; WX 768 ; N intersection ; B 40 0 793 509 ; +C 200 ; WX 768 ; N union ; B 115 -17 868 492 ; +C 201 ; WX 713 ; N propersuperset ; B 20 0 748 470 ; +C 202 ; WX 713 ; N reflexsuperset ; B -15 -125 747 470 ; +C 203 ; WX 713 ; N notsubset ; B 92 -70 820 540 ; +C 204 ; WX 713 ; N propersubset ; B 92 0 820 470 ; +C 205 ; WX 713 ; N reflexsubset ; B 22 -125 820 470 ; +C 206 ; WX 713 ; N element ; B 99 0 635 468 ; +C 207 ; WX 713 ; N notelement ; B 85 -58 635 555 ; +C 208 ; WX 768 ; N angle ; B 26 0 914 673 ; +C 209 ; WX 713 ; N gradient ; B 235 -19 880 718 ; +C 210 ; WX 790 ; N registerserif ; B 127 -20 843 670 ; +C 211 ; WX 790 ; N copyrightserif ; B 129 -15 846 675 ; +C 212 ; WX 890 ; N trademarkserif ; B 178 293 1041 673 ; +C 213 ; WX 823 ; N product ; B -3 -101 1008 751 ; +C 214 ; WX 549 ; N radical ; B 135 -38 768 917 ; +C 215 ; WX 250 ; N dotmath ; B 139 210 243 310 ; +C 216 ; WX 713 ; N logicalnot ; B 80 0 760 288 ; +C 217 ; WX 603 ; N logicaland ; B 23 0 583 454 ; +C 218 ; WX 603 ; N logicalor ; B 154 0 702 477 ; +C 219 ; WX 1042 ; N arrowdblboth ; B 95 -20 1091 510 ; +C 220 ; WX 987 ; N arrowdblleft ; B 99 -15 1045 513 ; +C 221 ; WX 603 ; N arrowdblup ; B 171 2 751 911 ; +C 222 ; WX 987 ; N arrowdblright ; B 76 -20 1022 508 ; +C 223 ; WX 603 ; N arrowdbldown ; B 108 -19 688 890 ; +C 224 ; WX 494 ; N lozenge ; B 122 0 570 745 ; +C 225 ; WX 329 ; N angleleft ; B 101 -198 506 746 ; +C 226 ; WX 790 ; N registersans ; B 127 -20 843 670 ; +C 227 ; WX 790 ; N copyrightsans ; B 127 -15 844 675 ; +C 228 ; WX 786 ; N trademarksans ; B 180 293 912 673 ; +C 229 ; WX 713 ; N summation ; B -14 -108 824 752 ; +C 230 ; WX 384 ; N parenlefttp ; B -41 -293 690 926 ; +C 231 ; WX 384 ; N parenleftex ; B 17 -85 349 925 ; +C 232 ; WX 384 ; N parenleftbt ; B 123 -293 358 926 ; +C 233 ; WX 384 ; N bracketlefttp ; B -22 -80 598 926 ; +C 234 ; WX 384 ; N bracketleftex ; B -22 -79 312 925 ; +C 235 ; WX 384 ; N bracketleftbt ; B -22 -80 333 926 ; +C 236 ; WX 494 ; N bracelefttp ; B 180 -75 696 926 ; +C 237 ; WX 494 ; N braceleftmid ; B 127 -85 514 935 ; +C 238 ; WX 494 ; N braceleftbt ; B 242 -70 512 926 ; +C 239 ; WX 494 ; N braceex ; B 179 -80 514 935 ; +C 241 ; WX 329 ; N angleright ; B -27 -198 378 746 ; +C 242 ; WX 274 ; N integral ; B -13 -107 531 916 ; +C 243 ; WX 686 ; N integraltp ; B 309 -83 951 922 ; +C 244 ; WX 686 ; N integralex ; B 308 -88 685 975 ; +C 245 ; WX 686 ; N integralbt ; B 35 -81 670 921 ; +C 246 ; WX 384 ; N parenrighttp ; B 308 -293 543 926 ; +C 247 ; WX 384 ; N parenrightex ; B 374 -85 706 925 ; +C 248 ; WX 384 ; N parenrightbt ; B -25 -293 707 926 ; +C 249 ; WX 384 ; N bracketrighttp ; B 264 -80 617 926 ; +C 250 ; WX 384 ; N bracketrightex ; B 283 -79 617 925 ; +C 251 ; WX 384 ; N bracketrightbt ; B -2 -80 617 926 ; +C 252 ; WX 494 ; N bracerighttp ; B 180 -75 451 926 ; +C 253 ; WX 494 ; N bracerightmid ; B 177 -85 565 935 ; +C 254 ; WX 494 ; N bracerightbt ; B -3 -70 512 926 ; +C -1 ; WX 790 ; N apple ; B 145 -2 862 808 ; +EndCharMetrics +EndFontMetrics diff --git a/dviware/dvitops/symbolsl.ps b/dviware/dvitops/symbolsl.ps new file mode 100644 index 0000000000..a92398d484 --- /dev/null +++ b/dviware/dvitops/symbolsl.ps @@ -0,0 +1,33 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/symbolsl.ps,v 1.1 89/02/01 16:41:50 jjc Rel $ + +/slantmatrix matrix def + +% oldfontname newfontname angle MakeSlantedFont + +/MakeSlantedFont { + slantmatrix exch dup sin exch cos div 2 exch put + exch + findfont dup maxlength dict begin + dup { + exch dup dup /FID ne exch /UniqueID ne and { + exch def + } { + pop pop + } ifelse + } forall + dup + /FontBBox + exch /FontBBox get aload pop + slantmatrix transform 4 2 roll slantmatrix transform 4 2 roll + 4 array astore + def + /FontMatrix exch /FontMatrix get slantmatrix matrix concatmatrix def + dup /FontName exch def + currentdict end + definefont pop +} bind def + + +/Symbol /Symbol-Slanted 15.5 MakeSlantedFont + diff --git a/dviware/dvitops/tex.enc b/dviware/dvitops/tex.enc new file mode 100644 index 0000000000..a6a9e4dc47 --- /dev/null +++ b/dviware/dvitops/tex.enc @@ -0,0 +1,19 @@ +Gamma Delta Theta Lambda Xi Pi Sigma Upsilon +Phi Psi Omega ff fi fl ffi ffl +dotlessi dotlessj grave acute caron breve macron ring +cedilla germandbls ae oe oslash AE OE Oslash + +slashaccent exclam quotedblright numbersign dollar percent ampersand quoteright +parenleft parenright asterisk plus comma hyphen period slash +zero one two three four five six seven +eight nine colon semicolon exclamdown equal questiondown question + +at A B C D E F G +H I J K L M N O +P Q R S T U V W +X Y Z bracketleft quotedblleft bracketright circumflex dotaccent + +quoteleft a b c d e f g +h i j k l m n o +p q r s t u v w +x y z endash emdash hungarumlaut tilde dieresis diff --git a/dviware/dvitops/timesex.pl b/dviware/dvitops/timesex.pl new file mode 100644 index 0000000000..5c0da724cb --- /dev/null +++ b/dviware/dvitops/timesex.pl @@ -0,0 +1,58 @@ +(FAMILY TIMES) +(CODINGSCHEME UNSPECIFIED) +(DESIGNSIZE R 10.0) +(COMMENT DESIGNSIZE IS IN POINTS) +(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE) +(CHECKSUM O 10722236641) +(SEVENBITSAFEFLAG TRUE) +(FONTDIMEN + (SLANT R 0.0) + (SPACE R 0.25) + (STRETCH R 0.125) + (SHRINK R 0.083333) + (XHEIGHT R 0.0) + (QUAD R 0.75) + (EXTRASPACE R 0.125) + ) +(CHARACTER O 40 + (CHARWD R 0.25) + (CHARIC R 0.020833) + ) +(CHARACTER C P + (CHARWD R 0.713) + (CHARHT R 0.752) + (CHARDP R 0.108) + (CHARIC R 0.002833) + (NEXTLARGER C X) + ) +(CHARACTER C Q + (CHARWD R 0.751) + (CHARHT R 0.751) + (CHARDP R 0.101) + (CHARIC R 0.072833) + (NEXTLARGER C Y) + ) +(CHARACTER C X + (CHARWD R 0.998) + (CHARHT R 1.053) + (CHARDP R 0.151) + ) +(CHARACTER C Y + (CHARWD R 1.051) + (CHARHT R 1.051) + (CHARDP R 0.141) + (CHARIC R 0.093833) + ) +(CHARACTER O 140 + (CHARWD R 0.751) + (CHARHT R 0.101) + (CHARDP R 0.751) + (CHARIC R 0.072833) + (NEXTLARGER C a) + ) +(CHARACTER C a + (CHARWD R 1.051) + (CHARHT R 0.141) + (CHARDP R 1.051) + (CHARIC R 0.093833) + ) diff --git a/dviware/dvitops/timesex.ps b/dviware/dvitops/timesex.ps new file mode 100644 index 0000000000..f023baa191 --- /dev/null +++ b/dviware/dvitops/timesex.ps @@ -0,0 +1,53 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/timesex.ps,v 1.1 89/02/01 16:41:37 jjc Rel $ + +/Times-Extension 12 dict dup begin + /FontType 3 def +% /UniqueID 1 def % how is one supposed to choose this? + /FontMatrix [.001 0 0 .001 0 0] def + /FontName /Extension def + /Encoding 256 array def + /FontBBox [0 0 0 0] def + 0 1 255 { + Encoding exch /.notdef put + } for + Encoding 8#040 /space put + Encoding 8#120 /sum put + Encoding 8#121 /product put + Encoding 8#130 /bigsum put + Encoding 8#131 /bigproduct put + Encoding 8#140 /coproduct put + Encoding 8#141 /bigcoproduct put + /BaseFonts [ + /Symbol findfont 1000 scalefont + dup 1.4 scalefont + /Symbol findfont [1000 0 0 -1000 0 0] makefont + dup 1.4 scalefont + ] def + /CharStrings 8 dict dup begin + /.notdef [(\040) 0 250] def + /space [(\040) 0 250] def + /sum [(\345) 0 713] def + /product [(\325) 0 751] def + /bigsum [(\345) 1 713 1.4 mul] def + /bigproduct [(\325) 1 751 1.4 mul] def + /coproduct [(\325) 2 751] def + /bigcoproduct [(\325) 3 751 1.4 mul] def + end def + /BuildChar { + exch begin + Encoding exch get + CharStrings exch get + dup 2 get 0 setcharwidth + dup 1 get BaseFonts exch get setfont + 0 0 moveto + 0 get show + end + } bind def + /FontInfo 3 dict dup begin + /FullName (Extension) def + /ItalicAngle 0 def + /isFixedPitch false def + end def +end definefont pop + diff --git a/dviware/dvitops/timessc.afm b/dviware/dvitops/timessc.afm new file mode 100644 index 0000000000..79ea5814bc --- /dev/null +++ b/dviware/dvitops/timessc.afm @@ -0,0 +1,387 @@ +StartFontMetrics 2.0 +Comment $Header: /usr/jjc/dvitops/RCS/timessc.afm,v 1.1 89/02/01 09:25:14 jjc Rel $ +FontName Times-SmallCaps +Version 001.001 +FamilyName Times +ItalicAngle 0 +IsFixedPitch false +UnderlinePosition -109 +UnderlineThickness 49 +Weight Roman +Notice Times Roman is a trademark of Allied Corporation. +FullName Times Roman +FontBBox -170 -223 1024 896 +StartCharMetrics 210 +C 32 ; WX 250 ; N space ; B 250 0 250 0 ; +C 33 ; WX 333 ; N exclam ; B 109 -14 224 676 ; +C 34 ; WX 408 ; N quotedbl ; B 70 445 337 685 ; +C 35 ; WX 500 ; N numbersign ; B 4 0 495 662 ; +C 36 ; WX 500 ; N dollar ; B 44 -87 456 727 ; +C 37 ; WX 833 ; N percent ; B 61 -14 772 676 ; +C 38 ; WX 778 ; N ampersand ; B 42 -14 750 676 ; +C 39 ; WX 333 ; N quoteright ; B 103 432 242 676 ; +C 40 ; WX 333 ; N parenleft ; B 49 -177 304 676 ; +C 41 ; WX 333 ; N parenright ; B 29 -177 284 676 ; +C 42 ; WX 500 ; N asterisk ; B 64 265 437 683 ; +C 43 ; WX 564 ; N plus ; B 30 7 534 512 ; +C 44 ; WX 250 ; N comma ; B 63 -143 202 101 ; +C 45 ; WX 333 ; N hyphen ; B 43 194 289 257 ; +C 46 ; WX 250 ; N period ; B 68 -14 183 101 ; +C 47 ; WX 278 ; N slash ; B -12 -108 302 682 ; +C 48 ; WX 500 ; N zero ; B 24 -14 476 676 ; +C 49 ; WX 500 ; N one ; B 111 0 394 676 ; +C 50 ; WX 500 ; N two ; B 30 0 475 676 ; +C 51 ; WX 500 ; N three ; B 44 -14 431 676 ; +C 52 ; WX 500 ; N four ; B 12 0 472 676 ; +C 53 ; WX 500 ; N five ; B 31 -14 438 688 ; +C 54 ; WX 500 ; N six ; B 35 -14 468 682 ; +C 55 ; WX 500 ; N seven ; B 20 -14 449 662 ; +C 56 ; WX 500 ; N eight ; B 53 -14 442 676 ; +C 57 ; WX 500 ; N nine ; B 30 -22 460 676 ; +C 58 ; WX 278 ; N colon ; B 81 -14 196 458 ; +C 59 ; WX 278 ; N semicolon ; B 63 -143 202 458 ; +C 60 ; WX 564 ; N less ; B 27 0 536 522 ; +C 61 ; WX 564 ; N equal ; B 30 132 534 390 ; +C 62 ; WX 564 ; N greater ; B 27 0 536 522 ; +C 63 ; WX 444 ; N question ; B 49 -14 395 676 ; +C 64 ; WX 921 ; N at ; B 0 -155 819 675 ; +C 65 ; WX 722 ; N A ; B 15 0 706 676 ; +C 66 ; WX 667 ; N B ; B 20 0 596 662 ; +C 67 ; WX 667 ; N C ; B 33 -14 637 676 ; +C 68 ; WX 722 ; N D ; B 20 0 689 662 ; +C 69 ; WX 611 ; N E ; B 12 0 597 662 ; +C 70 ; WX 556 ; N F ; B 12 0 544 662 ; +C 71 ; WX 722 ; N G ; B 27 -14 704 676 ; +C 72 ; WX 722 ; N H ; B 20 0 703 662 ; +C 73 ; WX 333 ; N I ; B 18 0 316 662 ; +C 74 ; WX 389 ; N J ; B 10 -14 376 662 ; +C 75 ; WX 722 ; N K ; B 20 0 709 662 ; +C 76 ; WX 611 ; N L ; B 12 0 598 662 ; +C 77 ; WX 889 ; N M ; B 19 0 871 662 ; +C 78 ; WX 722 ; N N ; B 12 -14 709 662 ; +C 79 ; WX 722 ; N O ; B 33 -14 688 676 ; +C 80 ; WX 556 ; N P ; B 11 0 542 662 ; +C 81 ; WX 722 ; N Q ; B 33 -177 701 676 ; +C 82 ; WX 667 ; N R ; B 12 0 654 662 ; +C 83 ; WX 556 ; N S ; B 42 -14 491 676 ; +C 84 ; WX 611 ; N T ; B 18 0 594 662 ; +C 85 ; WX 722 ; N U ; B 16 -14 705 662 ; +C 86 ; WX 722 ; N V ; B 20 -14 701 662 ; +C 87 ; WX 944 ; N W ; B 9 -14 936 662 ; +C 88 ; WX 722 ; N X ; B 12 0 706 662 ; +C 89 ; WX 722 ; N Y ; B 22 0 703 662 ; +C 90 ; WX 611 ; N Z ; B 7 0 597 662 ; +C 91 ; WX 333 ; N bracketleft ; B 88 -156 299 662 ; +C 92 ; WX 278 ; N backslash ; B -83 0 361 682 ; +C 93 ; WX 333 ; N bracketright ; B 34 -156 245 662 ; +C 94 ; WX 469 ; N asciicircum ; B 13 256 456 662 ; +C 95 ; WX 500 ; N underscore ; B 0 -133 500 -84 ; +C 96 ; WX 333 ; N quoteleft ; B 91 432 230 676 ; +C 97 ; WX 650 ; N a ; B 13 0 635 530 ; +C 98 ; WX 600 ; N b ; B 18 0 536 519 ; +C 99 ; WX 600 ; N c ; B 30 -11 573 530 ; +C 100 ; WX 650 ; N d ; B 18 0 620 519 ; +C 101 ; WX 550 ; N e ; B 11 0 537 519 ; +C 102 ; WX 500 ; N f ; B 11 0 490 519 ; +C 103 ; WX 650 ; N g ; B 24 -11 634 530 ; +C 104 ; WX 650 ; N h ; B 18 0 633 519 ; +C 105 ; WX 300 ; N i ; B 16 0 284 519 ; +C 106 ; WX 350 ; N j ; B 9 -11 338 519 ; +C 107 ; WX 650 ; N k ; B 18 0 638 519 ; +C 108 ; WX 550 ; N l ; B 11 0 538 519 ; +C 109 ; WX 800 ; N m ; B 17 0 784 519 ; +C 110 ; WX 650 ; N n ; B 11 -11 638 519 ; +C 111 ; WX 650 ; N o ; B 30 -11 619 531 ; +C 112 ; WX 500 ; N p ; B 10 0 488 519 ; +C 113 ; WX 650 ; N q ; B 30 -139 631 530 ; +C 114 ; WX 600 ; N r ; B 11 0 589 519 ; +C 115 ; WX 500 ; N s ; B 38 -11 442 530 ; +C 116 ; WX 550 ; N t ; B 16 0 535 519 ; +C 117 ; WX 650 ; N u ; B 14 -11 634 519 ; +C 118 ; WX 650 ; N v ; B 18 -11 631 519 ; +C 119 ; WX 850 ; N w ; B 8 -11 842 519 ; +C 120 ; WX 650 ; N x ; B 11 0 636 519 ; +C 121 ; WX 650 ; N y ; B 20 0 633 519 ; +C 122 ; WX 550 ; N z ; B 6 0 537 519 ; +C 123 ; WX 480 ; N braceleft ; B 110 -165 341 682 ; +C 124 ; WX 200 ; N bar ; B 68 0 132 682 ; +C 125 ; WX 480 ; N braceright ; B 139 -165 370 682 ; +C 126 ; WX 541 ; N asciitilde ; B 18 176 522 347 ; +C 161 ; WX 333 ; N exclamdown ; B 109 -217 224 458 ; +C 162 ; WX 500 ; N cent ; B 53 -138 448 579 ; +C 163 ; WX 500 ; N sterling ; B 11 -14 491 676 ; +C 164 ; WX 167 ; N fraction ; B -170 -14 346 676 ; +C 165 ; WX 500 ; N yen ; B -43 0 502 662 ; +C 166 ; WX 500 ; N florin ; B 6 -185 490 676 ; +C 167 ; WX 500 ; N section ; B 72 -148 426 676 ; +C 168 ; WX 500 ; N currency ; B -2 99 503 600 ; +C 169 ; WX 180 ; N quotesingle ; B 47 445 133 685 ; +C 170 ; WX 444 ; N quotedblleft ; B 27 432 399 676 ; +C 171 ; WX 500 ; N guillemotleft ; B 32 35 449 423 ; +C 172 ; WX 333 ; N guilsinglleft ; B 45 35 271 423 ; +C 173 ; WX 333 ; N guilsinglright ; B 62 35 288 422 ; +C 174 ; WX 556 ; N fi ; B 33 0 521 678 ; +C 175 ; WX 556 ; N fl ; B 29 0 521 682 ; +C 177 ; WX 500 ; N endash ; B -7 201 507 250 ; +C 178 ; WX 500 ; N dagger ; B 54 -149 440 676 ; +C 179 ; WX 500 ; N daggerdbl ; B 54 -153 439 676 ; +C 180 ; WX 250 ; N periodcentered ; B 68 204 183 319 ; +C 182 ; WX 453 ; N paragraph ; B 0 -207 373 662 ; +C 183 ; WX 350 ; N bullet ; B 50 175 300 425 ; +C 184 ; WX 333 ; N quotesinglbase ; B 103 -143 242 101 ; +C 185 ; WX 444 ; N quotedblbase ; B 45 -143 417 101 ; +C 186 ; WX 444 ; N quotedblright ; B 45 432 417 676 ; +C 187 ; WX 500 ; N guillemotright ; B 51 34 468 421 ; +C 188 ; WX 1000 ; N ellipsis ; B 110 -14 891 101 ; +C 189 ; WX 1000 ; N perthousand ; B 2 -14 1024 676 ; +C 191 ; WX 444 ; N questiondown ; B 49 -217 395 458 ; +C 193 ; WX 333 ; N grave ; B 16 507 243 678 ; +C 194 ; WX 333 ; N acute ; B 93 507 317 678 ; +C 195 ; WX 333 ; N circumflex ; B 11 507 323 674 ; +C 196 ; WX 333 ; N tilde ; B 1 532 332 638 ; +C 197 ; WX 333 ; N macron ; B 11 547 323 601 ; +C 198 ; WX 333 ; N breve ; B 26 507 308 664 ; +C 199 ; WX 333 ; N dotaccent ; B 116 523 216 623 ; +C 200 ; WX 333 ; N dieresis ; B 18 523 316 623 ; +C 202 ; WX 333 ; N ring ; B 67 483 266 682 ; +C 203 ; WX 333 ; N cedilla ; B 53 -215 262 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 8 528 372 700 ; +C 206 ; WX 333 ; N ogonek ; B 68 -155 245 -10 ; +C 207 ; WX 333 ; N caron ; B 11 507 323 674 ; +C 208 ; WX 1000 ; N emdash ; B -8 201 1007 250 ; +C 225 ; WX 889 ; N AE ; B 5 0 869 662 ; +C 227 ; WX 276 ; N ordfeminine ; B 15 307 278 676 ; +C 232 ; WX 611 ; N Lslash ; B 12 0 598 662 ; +C 233 ; WX 722 ; N Oslash ; B 33 -80 688 734 ; +C 234 ; WX 889 ; N OE ; B 21 -7 877 669 ; +C 235 ; WX 310 ; N ordmasculine ; B 15 307 301 676 ; +C 241 ; WX 800 ; N ae ; B 4 0 782 519 ; +C 245 ; WX 278 ; N dotlessi ; B 22 0 259 458 ; +C 248 ; WX 550 ; N lslash ; B 11 0 538 519 ; +C 249 ; WX 650 ; N oslash ; B 30 -63 619 576 ; +C 250 ; WX 800 ; N oe ; B 19 -5 789 525 ; +C 251 ; WX 500 ; N germandbls ; B 12 -10 468 682 ; +C -1 ; WX 611 ; N Eacute ; B 12 0 597 892 ; +C -1 ; WX 550 ; N ecircumflex ; B 11 0 537 697 ; +C -1 ; WX 722 ; N Acircumflex ; B 15 0 706 888 ; +C -1 ; WX 722 ; N Aacute ; B 15 0 706 892 ; +C -1 ; WX 722 ; N Odieresis ; B 33 -14 688 837 ; +C -1 ; WX 564 ; N logicalnot ; B 30 120 534 390 ; +C -1 ; WX 650 ; N atilde ; B 13 0 635 668 ; +C -1 ; WX 611 ; N Zcaron ; B 7 0 597 888 ; +C -1 ; WX 722 ; N Adieresis ; B 15 0 706 837 ; +C -1 ; WX 333 ; N Icircumflex ; B 11 0 323 888 ; +C -1 ; WX 650 ; N uacute ; B 14 -11 634 700 ; +C -1 ; WX 333 ; N Igrave ; B 16 0 316 892 ; +C -1 ; WX 650 ; N ydieresis ; B 20 0 633 656 ; +C -1 ; WX 550 ; N zcaron ; B 6 0 537 696 ; +C -1 ; WX 550 ; N edieresis ; B 11 0 537 656 ; +C -1 ; WX 650 ; N ucircumflex ; B 14 -11 634 697 ; +C -1 ; WX 650 ; N otilde ; B 30 -11 619 668 ; +C -1 ; WX 600 ; N ccedilla ; B 30 -169 573 530 ; +C -1 ; WX 650 ; N adieresis ; B 13 0 635 656 ; +C -1 ; WX 722 ; N Oacute ; B 33 -14 688 892 ; +C -1 ; WX 722 ; N Otilde ; B 33 -14 688 852 ; +C -1 ; WX 550 ; N egrave ; B 11 0 537 700 ; +C -1 ; WX 300 ; N iacute ; B 16 0 285 700 ; +C -1 ; WX 760 ; N registered ; B 43 -14 718 676 ; +C -1 ; WX 722 ; N Ntilde ; B 12 -14 709 852 ; +C -1 ; WX 564 ; N minus ; B 30 229 534 293 ; +C -1 ; WX 722 ; N Ograve ; B 33 -14 688 892 ; +C -1 ; WX 650 ; N ugrave ; B 14 -11 634 700 ; +C -1 ; WX 650 ; N ograve ; B 30 -11 619 700 ; +C -1 ; WX 650 ; N ntilde ; B 11 -11 638 668 ; +C -1 ; WX 650 ; N aring ; B 13 0 635 703 ; +C -1 ; WX 650 ; N acircumflex ; B 13 0 635 697 ; +C -1 ; WX 300 ; N idieresis ; B 16 0 284 656 ; +C -1 ; WX 722 ; N Agrave ; B 15 0 706 892 ; +C -1 ; WX 722 ; N Udieresis ; B 16 -14 705 837 ; +C -1 ; WX 650 ; N aacute ; B 13 0 635 700 ; +C -1 ; WX 611 ; N Egrave ; B 12 0 597 892 ; +C -1 ; WX 611 ; N Edieresis ; B 12 0 597 837 ; +C -1 ; WX 722 ; N Ocircumflex ; B 33 -14 688 888 ; +C -1 ; WX 650 ; N ocircumflex ; B 30 -11 619 697 ; +C -1 ; WX 980 ; N trademark ; B 35 258 945 662 ; +C -1 ; WX 333 ; N Iacute ; B 18 0 317 892 ; +C -1 ; WX 333 ; N Idieresis ; B 18 0 316 837 ; +C -1 ; WX 722 ; N Atilde ; B 15 0 706 852 ; +C -1 ; WX 760 ; N copyright ; B 42 -14 717 676 ; +C -1 ; WX 667 ; N Ccedilla ; B 33 -215 637 676 ; +C -1 ; WX 650 ; N agrave ; B 13 0 635 700 ; +C -1 ; WX 722 ; N Ucircumflex ; B 16 -14 705 888 ; +C -1 ; WX 500 ; N scaron ; B 38 -11 442 696 ; +C -1 ; WX 650 ; N udieresis ; B 14 -11 634 656 ; +C -1 ; WX 722 ; N Aring ; B 15 0 706 896 ; +C -1 ; WX 300 ; N icircumflex ; B 10 0 291 697 ; +C -1 ; WX 722 ; N Ugrave ; B 16 -14 705 892 ; +C -1 ; WX 556 ; N Scaron ; B 42 -14 491 888 ; +C -1 ; WX 722 ; N Ydieresis ; B 22 0 703 837 ; +C -1 ; WX 650 ; N odieresis ; B 30 -11 619 656 ; +C -1 ; WX 650 ; N oacute ; B 30 -11 619 700 ; +C -1 ; WX 550 ; N eacute ; B 11 0 537 700 ; +C -1 ; WX 300 ; N igrave ; B 14 0 284 700 ; +C -1 ; WX 722 ; N Uacute ; B 16 -14 705 892 ; +C -1 ; WX 611 ; N Ecircumflex ; B 12 0 597 888 ; +EndCharMetrics +StartKernData +StartKernPairs 154 + +KPX A space -55 +KPX A quoteright -111 +KPX A Y -92 +KPX A W -80 +KPX A V -129 +KPX A T -111 +KPX A y -83 +KPX A w -72 +KPX A v -116 +KPX A t -100 +KPX a space -49 +KPX a quoteright -100 +KPX a Y -83 +KPX a W -72 +KPX a V -116 +KPX a T -100 +KPX a y -83 +KPX a w -72 +KPX a v -116 +KPX a t -100 +KPX F period -80 +KPX F comma -80 +KPX F A -74 +KPX F a -67 +KPX f period -72 +KPX f comma -72 +KPX f A -67 +KPX f a -67 +KPX L space -37 +KPX L quoteright -92 +KPX L Y -100 +KPX L W -74 +KPX L V -92 +KPX L T -92 +KPX L y -90 +KPX L w -67 +KPX L v -83 +KPX L t -83 +KPX l space -33 +KPX l quoteright -83 +KPX l Y -90 +KPX l W -67 +KPX l V -83 +KPX l T -83 +KPX l y -90 +KPX l w -67 +KPX l v -83 +KPX l t -83 +KPX P space -37 +KPX P period -111 +KPX P comma -111 +KPX P A -92 +KPX P a -83 +KPX p space -33 +KPX p period -100 +KPX p comma -100 +KPX p A -83 +KPX p a -83 +KPX R Y -55 +KPX R W -55 +KPX R V -80 +KPX R T -60 +KPX R y -50 +KPX R w -50 +KPX R v -72 +KPX R t -54 +KPX R Y -50 +KPX R W -50 +KPX R V -72 +KPX R T -54 +KPX R y -50 +KPX R w -50 +KPX R v -72 +KPX R t -54 +KPX T space -18 +KPX T semicolon -55 +KPX T period -74 +KPX T hyphen -92 +KPX T comma -74 +KPX T colon -50 +KPX T O -18 +KPX T A -80 +KPX T o -16 +KPX T a -72 +KPX t space -16 +KPX t semicolon -50 +KPX t period -67 +KPX t hyphen -83 +KPX t comma -67 +KPX t colon -45 +KPX t O -16 +KPX t A -72 +KPX t o -16 +KPX t a -72 +KPX V space -18 +KPX V semicolon -74 +KPX V period -129 +KPX V hyphen -92 +KPX V comma -129 +KPX V colon -74 +KPX V A -129 +KPX V a -116 +KPX V space -16 +KPX V semicolon -67 +KPX V period -116 +KPX V hyphen -83 +KPX V comma -116 +KPX V colon -67 +KPX V A -116 +KPX V a -116 +KPX W space -18 +KPX W semicolon -37 +KPX W period -92 +KPX W hyphen -55 +KPX W comma -92 +KPX W colon -37 +KPX W A -111 +KPX W a -100 +KPX W space -16 +KPX W semicolon -33 +KPX W period -83 +KPX W hyphen -50 +KPX W comma -83 +KPX W colon -33 +KPX W A -100 +KPX W a -90 +KPX Y space -37 +KPX Y semicolon -92 +KPX Y period -129 +KPX Y hyphen -111 +KPX Y comma -129 +KPX Y colon -92 +KPX Y a -100 +KPX Y space -33 +KPX Y semicolon -83 +KPX Y period -116 +KPX Y hyphen -100 +KPX Y comma -116 +KPX Y colon -83 +KPX Y a -90 +KPX one one -37 +KPX quoteleft quoteleft -74 +KPX quoteright space -74 +KPX quoteright quoteright -74 +KPX space Y -37 +KPX space W -18 +KPX space V -18 +KPX space T -18 +KPX space A -55 +KPX space y -33 +KPX space w -16 +KPX space v -16 +KPX space t -16 +KPX space a -50 + +EndKernPairs +EndKernData +EndFontMetrics + diff --git a/dviware/dvitops/timessc.ps b/dviware/dvitops/timessc.ps new file mode 100644 index 0000000000..ec6dd67136 --- /dev/null +++ b/dviware/dvitops/timessc.ps @@ -0,0 +1,163 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/timessc.ps,v 1.1 89/02/01 09:24:29 jjc Rel $ +% implements Times-SmallCaps + +/scdict 25 dict def + +scdict begin + +/buf 256 string def + +% c islower - bool + +/islower { %def + dup 8#141 ge exch 8#172 le and +} bind def + + +% c toupper - c + +/toupper { %def + dup islower { %if + 8#40 sub + } if +} bind def + +% string proc mapstring - string + +/mapstring { + cvx /proc exch def + /s exch def + 0 1 s length 1 sub { + dup s exch get proc s 3 1 roll put + } for + s +} bind def + +/name1 256 string def +/name2 256 string def + +/concatname { %def + name2 cvs /s2 exch def + name1 cvs /s1 exch def + buf 0 s1 length s2 length add getinterval + dup 0 s1 putinterval + dup s1 length s2 putinterval + cvn +} def + +end %scdict + +% oldname newname uniqueid MakeSmallCapsFont - + +/MakeSmallCapsFont { % def + scdict begin + /uid exch def + /newname exch def + findfont /olddict exch def + /cs olddict /CharStrings get def + + % build enc and data from cs + /enc 256 array def + 0 1 255 { %for + enc exch /.notdef put + } for + /i 1 def + /data cs length dict def + cs { % forall + pop + /c exch def + c buf cvs dup dup 0 get toupper 0 exch put cvn /C exch def + cs C known c C ne and { % ifelse (if) + data c C put + } { % ifelse (else) + c buf cvs /toupper mapstring cvn /C exch def + cs C known c C ne and { % ifelse (if) + data c C put + } { % ifelse (else) + data c i put + enc i c put + /i i 1 add def + } ifelse + } ifelse + } forall + data /.notdef 0 put + + % reencode the base font + /basename /$!# newname concatname def + basename + olddict maxlength dict begin + olddict { % forall + exch dup dup /FID ne exch /Encoding ne and { % ifelse (if) + exch def + } { % ifelse (else) + pop pop + } ifelse + } forall + /Encoding enc def + /FontName basename def + currentdict end + definefont pop + + 20 dict begin + /UniqueID uid def + [/FontInfo /FontBBox /Encoding] { %forall + dup olddict exch get def + } forall + /CharStrings data def + /FontMatrix matrix def + /FontName newname def + /BaseFont basename findfont def + /XScale .9 def + gsave + initgraphics % this is necessary; I don't understand why + olddict setfont + newpath 0 0 moveto + (X) true charpath flattenpath pathbbox 4 1 roll pop pop pop + dup + 3 div + newpath 0 0 moveto + (x) true charpath flattenpath pathbbox 4 1 roll pop pop pop + 2 mul 3 div + add + exch div + /YScale exch def + grestore + /SmallBaseFont BaseFont [XScale 0 0 YScale 0 0] makefont def + /OneCharString 1 string def + /FontType 3 def + /Widths 256 array def + gsave + initgraphics % this is necessary; I don't understand why + BaseFont setfont 0 0 moveto + 0 1 255 { % for + dup + OneCharString 0 3 -1 roll put + OneCharString stringwidth pop + Widths + 3 1 roll + put + } for + grestore + /BuildChar { % def + exch begin + Encoding exch get CharStrings exch get + dup type /integertype eq { % ifelse (if) + dup Widths exch get 0 setcharwidth + BaseFont setfont + } { % ifelse (else) + CharStrings exch get + dup Widths exch get XScale mul 0 setcharwidth + SmallBaseFont setfont + } ifelse + 0 0 moveto + OneCharString 0 3 -1 roll put + OneCharString show + end + } bind def + currentdict end + newname exch definefont pop + end +} bind def + +/Times-Roman /Times-SmallCaps 1573 MakeSmallCapsFont diff --git a/dviware/dvitops/timessl.afm b/dviware/dvitops/timessl.afm new file mode 100644 index 0000000000..b48185e861 --- /dev/null +++ b/dviware/dvitops/timessl.afm @@ -0,0 +1,362 @@ +StartFontMetrics 2.0 +Comment $Header: /usr/jjc/dvitops/RCS/timessl.afm,v 1.1 89/02/01 09:33:59 jjc Rel $ +FontName Times-Slanted +Version 001.001 +FamilyName Times +ItalicAngle 10 +IsFixedPitch false +UnderlinePosition -109 +UnderlineThickness 49 +Weight Roman +Notice Times Roman is a trademark of Allied Corporation. +FullName Times Slanted +FontBBox -210 -223 1182 896 +StartCharMetrics 210 +C 32 ; WX 250 ; N space ; B 250 0 250 0 ; +C 33 ; WX 333 ; N exclam ; B 116 -14 328 676 ; +C 34 ; WX 408 ; N quotedbl ; B 181 445 452 685 ; +C 35 ; WX 500 ; N numbersign ; B 42 0 576 662 ; +C 36 ; WX 500 ; N dollar ; B 53 -87 533 727 ; +C 37 ; WX 833 ; N percent ; B 132 -14 817 676 ; +C 38 ; WX 778 ; N ampersand ; B 64 -14 786 676 ; +C 39 ; WX 333 ; N quoteright ; B 200 432 346 676 ; +C 40 ; WX 333 ; N parenleft ; B 86 -177 420 676 ; +C 41 ; WX 333 ; N parenright ; B 1 -177 333 676 ; +C 42 ; WX 500 ; N asterisk ; B 132 265 534 683 ; +C 43 ; WX 564 ; N plus ; B 70 7 586 512 ; +C 44 ; WX 250 ; N comma ; B 58 -143 205 101 ; +C 45 ; WX 333 ; N hyphen ; B 77 194 334 257 ; +C 46 ; WX 250 ; N period ; B 75 -14 191 101 ; +C 47 ; WX 278 ; N slash ; B -31 -108 422 682 ; +C 48 ; WX 500 ; N zero ; B 73 -14 544 676 ; +C 49 ; WX 500 ; N one ; B 119 0 418 676 ; +C 50 ; WX 500 ; N two ; B 30 0 515 676 ; +C 51 ; WX 500 ; N three ; B 51 -14 495 676 ; +C 52 ; WX 500 ; N four ; B 41 0 513 676 ; +C 53 ; WX 500 ; N five ; B 39 -14 558 688 ; +C 54 ; WX 500 ; N six ; B 76 -14 566 682 ; +C 55 ; WX 500 ; N seven ; B 111 -14 566 662 ; +C 56 ; WX 500 ; N eight ; B 77 -14 518 676 ; +C 57 ; WX 500 ; N nine ; B 55 -22 534 676 ; +C 58 ; WX 278 ; N colon ; B 88 -14 268 458 ; +C 59 ; WX 278 ; N semicolon ; B 58 -143 253 458 ; +C 60 ; WX 564 ; N less ; B 68 0 628 522 ; +C 61 ; WX 564 ; N equal ; B 53 132 603 390 ; +C 62 ; WX 564 ; N greater ; B 27 0 587 522 ; +C 63 ; WX 444 ; N question ; B 142 -14 488 676 ; +C 64 ; WX 921 ; N at ; B 39 -155 886 675 ; +C 65 ; WX 722 ; N A ; B 15 0 709 676 ; +C 66 ; WX 667 ; N B ; B 20 0 652 662 ; +C 67 ; WX 667 ; N C ; B 84 -14 735 676 ; +C 68 ; WX 722 ; N D ; B 20 0 754 662 ; +C 69 ; WX 611 ; N E ; B 12 0 660 662 ; +C 70 ; WX 556 ; N F ; B 12 0 661 662 ; +C 71 ; WX 722 ; N G ; B 79 -14 767 676 ; +C 72 ; WX 722 ; N H ; B 20 0 820 662 ; +C 73 ; WX 333 ; N I ; B 18 0 433 662 ; +C 74 ; WX 389 ; N J ; B 20 -14 493 662 ; +C 75 ; WX 722 ; N K ; B 20 0 778 662 ; +C 76 ; WX 611 ; N L ; B 12 0 629 662 ; +C 77 ; WX 889 ; N M ; B 19 0 987 662 ; +C 78 ; WX 722 ; N N ; B 12 -14 826 662 ; +C 79 ; WX 722 ; N O ; B 85 -14 753 676 ; +C 80 ; WX 556 ; N P ; B 11 0 630 662 ; +C 81 ; WX 722 ; N Q ; B 85 -177 753 676 ; +C 82 ; WX 667 ; N R ; B 12 0 657 662 ; +C 83 ; WX 556 ; N S ; B 70 -14 566 676 ; +C 84 ; WX 611 ; N T ; B 105 0 705 662 ; +C 85 ; WX 722 ; N U ; B 129 -14 822 662 ; +C 86 ; WX 722 ; N V ; B 133 -14 818 662 ; +C 87 ; WX 944 ; N W ; B 122 -14 1053 662 ; +C 88 ; WX 722 ; N X ; B 12 0 815 662 ; +C 89 ; WX 722 ; N Y ; B 135 0 820 662 ; +C 90 ; WX 611 ; N Z ; B 7 0 696 662 ; +C 91 ; WX 333 ; N bracketleft ; B 61 -156 416 662 ; +C 92 ; WX 278 ; N backslash ; B 37 0 361 682 ; +C 93 ; WX 333 ; N bracketright ; B 6 -156 362 662 ; +C 94 ; WX 469 ; N asciicircum ; B 58 256 501 662 ; +C 95 ; WX 500 ; N underscore ; B -23 -133 485 -84 ; +C 96 ; WX 333 ; N quoteleft ; B 183 432 329 676 ; +C 97 ; WX 444 ; N a ; B 52 -10 454 458 ; +C 98 ; WX 500 ; N b ; B 85 -10 521 682 ; +C 99 ; WX 444 ; N c ; B 58 -10 462 458 ; +C 100 ; WX 500 ; N d ; B 59 -13 544 682 ; +C 101 ; WX 444 ; N e ; B 55 -10 453 458 ; +C 102 ; WX 333 ; N f ; B 20 0 493 682 ; L i fi ; L l fl ; +C 103 ; WX 500 ; N g ; B 6 -217 545 458 ; +C 104 ; WX 500 ; N h ; B 9 0 492 682 ; +C 105 ; WX 278 ; N i ; B 22 0 296 682 ; +C 106 ; WX 278 ; N j ; B -83 -217 324 682 ; +C 107 ; WX 500 ; N k ; B 1 0 554 682 ; +C 108 ; WX 278 ; N l ; B 20 0 302 682 ; +C 109 ; WX 778 ; N m ; B 13 0 767 458 ; +C 110 ; WX 500 ; N n ; B 9 0 492 458 ; +C 111 ; WX 500 ; N o ; B 65 -10 516 458 ; +C 112 ; WX 500 ; N p ; B -36 -217 518 458 ; +C 113 ; WX 500 ; N q ; B 56 -217 504 459 ; +C 114 ; WX 333 ; N r ; B 4 0 407 458 ; +C 115 ; WX 389 ; N s ; B 51 -10 394 458 ; +C 116 ; WX 278 ; N t ; B 85 -10 334 580 ; +C 117 ; WX 500 ; N u ; B 86 -10 496 448 ; +C 118 ; WX 500 ; N v ; B 87 -10 547 448 ; +C 119 ; WX 722 ; N w ; B 98 -10 773 448 ; +C 120 ; WX 500 ; N x ; B 17 0 513 448 ; +C 121 ; WX 500 ; N y ; B 2 -217 555 448 ; +C 122 ; WX 444 ; N z ; B 25 0 484 448 ; +C 123 ; WX 480 ; N braceleft ; B 155 -165 461 682 ; +C 124 ; WX 200 ; N bar ; B 68 0 252 682 ; +C 125 ; WX 480 ; N braceright ; B 110 -165 415 682 ; +C 126 ; WX 541 ; N asciitilde ; B 56 176 576 347 ; +C 161 ; WX 333 ; N exclamdown ; B 85 -217 296 458 ; +C 162 ; WX 500 ; N cent ; B 87 -138 505 579 ; +C 163 ; WX 500 ; N sterling ; B 19 -14 553 676 ; +C 164 ; WX 167 ; N fraction ; B -172 -14 465 676 ; +C 165 ; WX 500 ; N yen ; B 59 0 619 662 ; +C 166 ; WX 500 ; N florin ; B -16 -185 599 676 ; +C 167 ; WX 500 ; N section ; B 94 -148 480 676 ; +C 168 ; WX 500 ; N currency ; B 24 99 599 600 ; +C 169 ; WX 180 ; N quotesingle ; B 158 445 248 685 ; +C 170 ; WX 444 ; N quotedblleft ; B 119 432 498 676 ; +C 171 ; WX 500 ; N guillemotleft ; B 72 35 522 423 ; +C 172 ; WX 333 ; N guilsinglleft ; B 85 35 344 423 ; +C 173 ; WX 333 ; N guilsinglright ; B 70 35 328 422 ; +C 174 ; WX 556 ; N fi ; B 33 0 552 678 ; +C 175 ; WX 556 ; N fl ; B 29 0 578 682 ; +C 177 ; WX 500 ; N endash ; B 29 201 551 250 ; +C 178 ; WX 500 ; N dagger ; B 132 -149 520 676 ; +C 179 ; WX 500 ; N daggerdbl ; B 67 -153 519 676 ; +C 180 ; WX 250 ; N periodcentered ; B 113 204 230 319 ; +C 182 ; WX 453 ; N paragraph ; B 76 -207 490 662 ; +C 183 ; WX 350 ; N bullet ; B 101 175 355 425 ; +C 184 ; WX 333 ; N quotesinglbase ; B 98 -143 244 101 ; +C 185 ; WX 444 ; N quotedblbase ; B 40 -143 419 101 ; +C 186 ; WX 444 ; N quotedblright ; B 142 432 521 676 ; +C 187 ; WX 500 ; N guillemotright ; B 59 34 508 421 ; +C 188 ; WX 1000 ; N ellipsis ; B 117 -14 900 101 ; +C 189 ; WX 1000 ; N perthousand ; B 77 -14 1069 676 ; +C 191 ; WX 444 ; N questiondown ; B 35 -217 383 458 ; +C 193 ; WX 333 ; N grave ; B 129 507 332 678 ; +C 194 ; WX 333 ; N acute ; B 182 507 431 678 ; +C 195 ; WX 333 ; N circumflex ; B 100 507 412 674 ; +C 196 ; WX 333 ; N tilde ; B 95 532 444 638 ; +C 197 ; WX 333 ; N macron ; B 107 547 429 601 ; +C 198 ; WX 333 ; N breve ; B 139 507 425 664 ; +C 199 ; WX 333 ; N dotaccent ; B 216 523 318 623 ; +C 200 ; WX 333 ; N dieresis ; B 118 523 418 623 ; +C 202 ; WX 333 ; N ring ; B 168 483 370 682 ; +C 203 ; WX 333 ; N cedilla ; B 18 -215 240 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 101 528 491 700 ; +C 206 ; WX 333 ; N ogonek ; B 51 -155 227 -10 ; +C 207 ; WX 333 ; N caron ; B 130 507 442 674 ; +C 208 ; WX 1000 ; N emdash ; B 28 201 1051 250 ; +C 225 ; WX 889 ; N AE ; B 5 0 941 662 ; +C 227 ; WX 276 ; N ordfeminine ; B 69 307 356 676 ; +C 232 ; WX 611 ; N Lslash ; B 12 0 629 662 ; +C 233 ; WX 722 ; N Oslash ; B 42 -80 787 734 ; +C 234 ; WX 889 ; N OE ; B 71 -7 946 669 ; +C 235 ; WX 310 ; N ordmasculine ; B 79 307 399 676 ; +C 241 ; WX 667 ; N ae ; B 54 -10 668 458 ; +C 245 ; WX 278 ; N dotlessi ; B 22 0 264 458 ; +C 248 ; WX 278 ; N lslash ; B 20 0 346 682 ; +C 249 ; WX 500 ; N oslash ; B 33 -108 532 549 ; +C 250 ; WX 722 ; N oe ; B 64 -10 728 458 ; +C 251 ; WX 500 ; N germandbls ; B 12 -10 518 682 ; +C -1 ; WX 611 ; N Eacute ; B 12 0 660 892 ; +C -1 ; WX 444 ; N ecircumflex ; B 55 -10 468 674 ; +C -1 ; WX 722 ; N Aacute ; B 15 0 709 892 ; +C -1 ; WX 722 ; N Acircumflex ; B 15 0 709 888 ; +C -1 ; WX 722 ; N Odieresis ; B 85 -14 753 837 ; +C -1 ; WX 564 ; N logicalnot ; B 87 120 603 390 ; +C -1 ; WX 444 ; N atilde ; B 52 -10 500 638 ; +C -1 ; WX 611 ; N Zcaron ; B 7 0 696 888 ; +C -1 ; WX 722 ; N Adieresis ; B 15 0 709 837 ; +C -1 ; WX 333 ; N Icircumflex ; B 18 0 450 888 ; +C -1 ; WX 333 ; N Igrave ; B 18 0 433 892 ; +C -1 ; WX 500 ; N uacute ; B 86 -10 515 678 ; +C -1 ; WX 444 ; N edieresis ; B 55 -10 474 623 ; +C -1 ; WX 500 ; N ucircumflex ; B 86 -10 496 674 ; +C -1 ; WX 500 ; N ydieresis ; B 2 -217 555 623 ; +C -1 ; WX 500 ; N otilde ; B 65 -10 528 638 ; +C -1 ; WX 444 ; N zcaron ; B 25 0 498 674 ; +C -1 ; WX 444 ; N ccedilla ; B 58 -215 462 458 ; +C -1 ; WX 444 ; N adieresis ; B 52 -10 474 623 ; +C -1 ; WX 722 ; N Oacute ; B 85 -14 753 892 ; +C -1 ; WX 722 ; N Otilde ; B 85 -14 753 852 ; +C -1 ; WX 444 ; N egrave ; B 55 -10 453 678 ; +C -1 ; WX 278 ; N iacute ; B 22 0 405 678 ; +C -1 ; WX 722 ; N Ntilde ; B 12 -14 826 852 ; +C -1 ; WX 564 ; N minus ; B 70 229 586 293 ; +C -1 ; WX 722 ; N Ograve ; B 85 -14 753 892 ; +C -1 ; WX 500 ; N ograve ; B 65 -10 516 678 ; +C -1 ; WX 500 ; N ntilde ; B 9 0 528 638 ; +C -1 ; WX 444 ; N aring ; B 52 -10 454 682 ; +C -1 ; WX 444 ; N acircumflex ; B 52 -10 468 674 ; +C -1 ; WX 278 ; N idieresis ; B 22 0 391 623 ; +C -1 ; WX 760 ; N registered ; B 96 -14 782 676 ; +C -1 ; WX 722 ; N Agrave ; B 15 0 709 892 ; +C -1 ; WX 722 ; N Udieresis ; B 129 -14 822 837 ; +C -1 ; WX 444 ; N aacute ; B 52 -10 487 678 ; +C -1 ; WX 611 ; N Egrave ; B 12 0 660 892 ; +C -1 ; WX 611 ; N Edieresis ; B 12 0 660 837 ; +C -1 ; WX 722 ; N Ocircumflex ; B 85 -14 753 888 ; +C -1 ; WX 500 ; N ocircumflex ; B 65 -10 516 674 ; +C -1 ; WX 980 ; N trademark ; B 134 258 1062 662 ; +C -1 ; WX 333 ; N Iacute ; B 18 0 469 892 ; +C -1 ; WX 333 ; N Idieresis ; B 18 0 455 837 ; +C -1 ; WX 722 ; N Atilde ; B 15 0 709 852 ; +C -1 ; WX 760 ; N copyright ; B 95 -14 781 676 ; +C -1 ; WX 667 ; N Ccedilla ; B 84 -215 735 676 ; +C -1 ; WX 444 ; N agrave ; B 52 -10 454 678 ; +C -1 ; WX 722 ; N Ucircumflex ; B 129 -14 822 888 ; +C -1 ; WX 722 ; N Aring ; B 15 0 709 896 ; +C -1 ; WX 278 ; N icircumflex ; B 22 0 386 674 ; +C -1 ; WX 722 ; N Ugrave ; B 129 -14 822 892 ; +C -1 ; WX 556 ; N Scaron ; B 70 -14 592 888 ; +C -1 ; WX 389 ; N scaron ; B 51 -10 470 674 ; +C -1 ; WX 500 ; N udieresis ; B 86 -10 502 623 ; +C -1 ; WX 722 ; N Ydieresis ; B 135 0 820 837 ; +C -1 ; WX 500 ; N odieresis ; B 65 -10 516 623 ; +C -1 ; WX 500 ; N ugrave ; B 86 -10 496 678 ; +C -1 ; WX 444 ; N eacute ; B 55 -10 487 678 ; +C -1 ; WX 500 ; N oacute ; B 65 -10 516 678 ; +C -1 ; WX 278 ; N igrave ; B 22 0 306 678 ; +C -1 ; WX 722 ; N Uacute ; B 129 -14 822 892 ; +C -1 ; WX 611 ; N Ecircumflex ; B 12 0 660 888 ; +EndCharMetrics +StartKernData +StartKernPairs 113 + +KPX A y -92 +KPX A w -92 +KPX A v -74 +KPX A space -55 +KPX A quoteright -111 +KPX A Y -92 +KPX A W -80 +KPX A V -129 +KPX A T -111 + +KPX F period -80 +KPX F comma -80 +KPX F A -74 + +KPX L y -55 +KPX L space -37 +KPX L quoteright -92 +KPX L Y -100 +KPX L W -74 +KPX L V -92 +KPX L T -92 + +KPX P space -37 +KPX P period -111 +KPX P comma -111 +KPX P A -92 + +KPX R y -40 +KPX R Y -55 +KPX R W -55 +KPX R V -80 +KPX R T -60 + +KPX T y -70 +KPX T w -70 +KPX T u -35 +KPX T space -18 +KPX T semicolon -55 +KPX T s -70 +KPX T r -35 +KPX T period -74 +KPX T o -70 +KPX T i -35 +KPX T hyphen -92 +KPX T e -70 +KPX T comma -74 +KPX T colon -50 +KPX T c -70 +KPX T a -70 +KPX T O -18 +KPX T A -80 + +KPX V y -111 +KPX V u -60 +KPX V space -18 +KPX V semicolon -74 +KPX V r -60 +KPX V period -129 +KPX V o -129 +KPX V i -60 +KPX V hyphen -92 +KPX V e -111 +KPX V comma -129 +KPX V colon -74 +KPX V a -111 +KPX V A -129 + +KPX W y -60 +KPX W u -40 +KPX W space -18 +KPX W semicolon -37 +KPX W r -40 +KPX W period -92 +KPX W o -80 +KPX W i -40 +KPX W hyphen -55 +KPX W e -80 +KPX W comma -92 +KPX W colon -37 +KPX W a -80 +KPX W A -111 + +KPX Y v -100 +KPX Y u -111 +KPX Y space -37 +KPX Y semicolon -92 +KPX Y q -111 +KPX Y period -129 +KPX Y p -92 +KPX Y o -100 +KPX Y i -55 +KPX Y hyphen -111 +KPX Y e -100 +KPX Y comma -129 +KPX Y colon -92 +KPX Y a -100 +KPX Y A -111 + +KPX f quoteright 55 +KPX f f -18 + +KPX one one -37 + +KPX quoteleft quoteleft -74 + +KPX quoteright t -18 +KPX quoteright space -74 +KPX quoteright s -55 +KPX quoteright quoteright -74 + +KPX r quoteright 37 +KPX r period -55 +KPX r hyphen -20 +KPX r g -18 +KPX r comma -40 + +KPX space Y -37 +KPX space W -18 +KPX space V -18 +KPX space T -18 +KPX space A -55 + +KPX v period -65 +KPX v comma -65 + +KPX w period -65 +KPX w comma -65 + +KPX y period -65 +KPX y comma -65 +EndKernPairs +EndKernData +EndFontMetrics + diff --git a/dviware/dvitops/timessl.ps b/dviware/dvitops/timessl.ps new file mode 100644 index 0000000000..894601ddc5 --- /dev/null +++ b/dviware/dvitops/timessl.ps @@ -0,0 +1,33 @@ +%! +% $Header: /usr/jjc/dvitops/RCS/timessl.ps,v 1.1 89/02/01 09:25:41 jjc Rel $ +% implements Times-Slanted.ps + +/slantmatrix matrix def + +% oldfontname newfontname angle MakeSlantedFont + +/MakeSlantedFont { + slantmatrix exch dup sin exch cos div 2 exch put + exch + findfont dup maxlength dict begin + dup { + exch dup dup /FID ne exch /UniqueID ne and { + exch def + } { + pop pop + } ifelse + } forall + dup + /FontBBox + exch /FontBBox get aload pop + slantmatrix transform 4 2 roll slantmatrix transform 4 2 roll + 4 array astore + def + /FontMatrix exch /FontMatrix get slantmatrix matrix concatmatrix def + dup /FontName exch def + currentdict end + definefont pop +} bind def + + +/Times-Roman /Times-Slanted 9 MakeSlantedFont diff --git a/dviware/dvitops/tpic.c b/dviware/dvitops/tpic.c new file mode 100644 index 0000000000..1700354b96 --- /dev/null +++ b/dviware/dvitops/tpic.c @@ -0,0 +1,549 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/tpic.c,v 1.4 90/08/14 13:03:50 jjc Rel $"; + +#include "dvitops.h" + +#ifdef TPIC_SUPPORT + +/* Dotted lines look a bit anaemic; so we add this many milli-inches to + the pen size of a dotted line. */ + +#define DOTTED_LINE_WIDTH_ADDITION 3 + +/* flags in tpic_object is or'ed from these */ + +#define ARC 1 +#define SPLINE 2 +#define SHADED 4 +#define INVISIBLE 8 +#define DOTTED 16 +#define DASHED 32 + +struct point { + integer x; + integer y; +}; + +struct tpic_object { + struct tpic_object *next; + integer h, v; + int region; + unsigned flags; + integer pen_size; + float shade; + union { + struct { + float dash_width; + int npoints; + struct point point_vector[2]; /* may be bigger than this */ + } p; + struct { + integer cx; + integer cy; + integer rx; + integer ry; + float s; + float e; + } a; + } u; +}; + +#ifdef PROTO +static void draw_path(FILE *psfp, double sc, integer h, integer v, + struct point *pv, int np, int closed); +static void draw_spline(FILE *psfp, double sc, integer h, integer v, + struct point *pv, int np); +static void draw_ellipse(FILE *psfp, double sc, integer h, integer v, + integer cx, integer cy, integer rx, integer ry); +static void draw_arc(FILE *psfp, double sc, integer h, integer v, + integer cx, integer cy, integer r, double s, double e); +#else +static void draw_path(); +static void draw_spline(); +static void draw_ellipse(); +static void draw_arc(); +#endif + +struct tpic_object *tpic_object_list = NULL; + +#define TPIC_CODE(c1, c2) (((unsigned char)(c1) << 8) + (unsigned char)(c2)) + +/* return 1 if it was a tpic_special, 0 otherwise */ + +int tpic_special(pass, arg, x, y) +int pass; +char *arg; +integer x, y; +{ + static integer current_pen_size = 8; + static unsigned tpic_flags = 0; + static float shade = 0.0; + static int npoints = 0; + static int maxpoints = 0; + static struct point *point_vector = 0; + double dash_width; + int complete = 0; + while (*arg == ' ') + arg++; + if (arg[0] == '\0' || arg[1] == '\0' + || (arg[2] != ' ' && arg[2] != '\0')) + return 0; + if (pass != PASS2) { + switch (TPIC_CODE(arg[0], arg[1])) { + case TPIC_CODE('p', 'n'): + case TPIC_CODE('p', 'a'): + case TPIC_CODE('s', 'p'): + case TPIC_CODE('d', 'a'): + case TPIC_CODE('d', 't'): + case TPIC_CODE('i', 'p'): + case TPIC_CODE('f', 'p'): + case TPIC_CODE('i', 'a'): + case TPIC_CODE('a', 'r'): + case TPIC_CODE('s', 'h'): + case TPIC_CODE('w', 'h'): + case TPIC_CODE('b', 'k'): + return 1; + default: + /* it's not a tpic special */ + return 0; + } + } + switch (TPIC_CODE(arg[0], arg[1])) { + case TPIC_CODE('p', 'n'): + { + long n; + if (sscanf(arg + 2, "%ld", &n) != 1) { + message(ERROR, "bad argument to pn special"); + return 1; + } + current_pen_size = n; + break; + } + case TPIC_CODE('p', 'a'): + { + long x, y; + if (sscanf(arg + 2, "%ld %ld", &x, &y) != 2) { + message(ERROR, "bad arguments to pa special"); + return 1; + } + if (npoints >= maxpoints) { + if (maxpoints == 0) { + point_vector = (struct point *) + malloc((maxpoints = 5)*sizeof(struct point)); + if (point_vector == NULL) + out_of_memory(); + } + else { + point_vector = (struct point *) + realloc((char *)point_vector, + sizeof(struct point)*(maxpoints *= 2)); + if (point_vector == NULL) + out_of_memory(); + } + } + point_vector[npoints].x = x; + point_vector[npoints].y = y; + npoints++; + break; + } + case TPIC_CODE('s', 'p'): + { + float f; + if (sscanf(arg + 2, "%f", &f) == 1 && f != 0.0) { + if (f > 0.0) { + tpic_flags |= DASHED; + dash_width = f; + } + else { + tpic_flags |= DOTTED; + dash_width = -f; + } + } + tpic_flags |= SPLINE; + goto path; + } + case TPIC_CODE('d', 'a'): + { + float f; + if (sscanf(arg + 2, "%f", &f) != 1) { + message(ERROR, "bad argument to da special"); + return 1; + } + tpic_flags |= DASHED; + dash_width = f; + goto path; + } + case TPIC_CODE('d', 't'): + { + float f; + if (sscanf(arg + 2, "%f", &f) != 1) { + message(ERROR, "bad argument to dt special"); + return 1; + } + tpic_flags |= DOTTED; + dash_width = f; + goto path; + } + case TPIC_CODE('i', 'p'): + tpic_flags |= INVISIBLE; + /* fall through */ + case TPIC_CODE('f', 'p'): + path: + { + struct tpic_object *p; + size_t sz = sizeof(struct tpic_object); + if (npoints > 2) + sz += sizeof(struct point)*(npoints - 2); + p = (struct tpic_object *)malloc(sz); + if (p == NULL) + out_of_memory(); + p->flags = tpic_flags; + if (tpic_flags & (DOTTED|DASHED)) + p->u.p.dash_width = dash_width; + tpic_flags = 0; + memcpy((char *)p->u.p.point_vector, (char *)point_vector, + npoints*sizeof(struct point)); + p->u.p.npoints = npoints; + npoints = 0; + p->next = tpic_object_list; + tpic_object_list = p; + complete = 1; + break; + } + case TPIC_CODE('i', 'a'): + tpic_flags |= INVISIBLE; + /* fall through */ + case TPIC_CODE('a', 'r'): + { + struct tpic_object *p; + long x, y; + long rx, ry; + float s, e; + if (sscanf(arg + 2, "%ld %ld %ld %ld %f %f", + &x, &y, &rx, &ry, &s, &e) != 6) { + if (arg[0] == 'i') + message(ERROR, "bad argument to ia special"); + else + message(ERROR, "bad argument to ar special"); + return 1; + } + p = (struct tpic_object *)malloc(sizeof(struct tpic_object)); + if (p == NULL) + out_of_memory(); + p->flags = ARC|tpic_flags; + tpic_flags = 0; + p->u.a.cx = x; + p->u.a.cy = y; + p->u.a.rx = rx; + p->u.a.ry = ry; + p->u.a.s = s; + p->u.a.e = e; + p->next = tpic_object_list; + tpic_object_list = p; + complete = 1; + break; + } + case TPIC_CODE('s', 'h'): + { + float f; + if (sscanf(arg + 2, "%f", &f) != 1) + f = 0.5; + tpic_flags |= SHADED; + shade = f; + break; + } + case TPIC_CODE('w', 'h'): + tpic_flags |= SHADED; + shade = 0.0; + break; + case TPIC_CODE('b', 'k'): + tpic_flags |= SHADED; + shade = 1.0; + break; + default: + /* it's not a tpic special */ + return 0; + } + if (complete) { + /* we just completed an object, so fill in some details */ + tpic_object_list->h = x; + tpic_object_list->v = y; + tpic_object_list->region = current_region; + tpic_object_list->pen_size = current_pen_size; + if (tpic_object_list->flags & DOTTED) + tpic_object_list->pen_size += DOTTED_LINE_WIDTH_ADDITION; + if (tpic_object_list->flags & SHADED) + tpic_object_list->shade = shade; + } + return 1; +} + +#define round(d) ((long)((d) + 0.5)) + + +void p_tpic_list(psfp, page) +FILE *psfp; +struct page_info *page; +{ + int r = NO_REGION; + integer ox = 0, oy = 0; + integer ps = -1; + double sc = (254.0*page->den)/page->num; + struct tpic_object *p = tpic_object_list; + if (p == NULL) + return; + /* reverse tpic_object_list */ + tpic_object_list = NULL; + while (p != NULL) { + struct tpic_object *tem = p; + p = p->next; + tem->next = tpic_object_list; + tpic_object_list = tem; + } + fputs("BO TP\n", psfp); + while (tpic_object_list != NULL) { + p = tpic_object_list; + if (p->region != r) { + if (r != NO_REGION) + fputs("GR\n", psfp); + if (p->region != NO_REGION) { + fputs("GS\n", psfp); + do_transform(p->region, &ox, &oy, psfp); + } + else + ox = oy = 0; + r = p->region; + } + p->h -= ox; + p->v -= oy; + if (p->pen_size != ps) { + ps = p->pen_size; + put_dim(round(ps*sc), psfp); + fputs(" LW\n", psfp); + } + if (p->flags & ARC) { + integer cx, cy, rx, ry; + double s, e; + cx = p->u.a.cx; + cy = p->u.a.cy; + rx = p->u.a.rx; + ry = p->u.a.ry; + s = p->u.a.s; + e = p->u.a.e; + if (e - s >= M_PI*2.0) { + if (p->flags & SHADED) { + if (p->shade != 1.0) + fprintf(psfp, "%g SG\n", 1 - p->shade); + draw_ellipse(psfp, sc, p->h, p->v, cx, cy, rx, ry); + fputs("FI\n", psfp); + if (p->shade != 1.0) + fputs("0 SG\n", psfp); + } + if (!(p->flags & INVISIBLE)) { + draw_ellipse(psfp, sc, p->h, p->v, cx, cy, rx, ry); + fputs("ST\n", psfp); + } + } + else { + if (rx != ry) + message(WARNING, "open arc with rx != ry"); + draw_arc(psfp, sc, p->h, p->v, cx, cy, rx, s, e); + fputs("ST\n", psfp); + } + } + else { + int np = p->u.p.npoints; + struct point *pv = p->u.p.point_vector; + double dw = p->u.p.dash_width*1000.0; + if (p->flags & SPLINE) { + if (p->flags & DASHED) { + put_dim(round(sc*dw), psfp); + putc(' ', psfp); + put_dim(round(sc*dw), psfp); + fputs(" DH\n", psfp); + } + else if (p->flags & DOTTED) { + fputs("0 ", psfp); + put_dim(round(sc*dw), psfp); + fputs(" DH\n", psfp); + } + draw_spline(psfp, sc, p->h, p->v, pv, np); + fputs("ST\n", psfp); + if (p->flags & (DOTTED|DASHED)) + fputs("SO\n", psfp); + } + else { + int closed = (np >= 2 + && pv[0].x == pv[np - 1].x + && pv[0].y == pv[np - 1].y); + if (p->flags & SHADED) { + if (p->shade != 1.0) + fprintf(psfp, "%g SG\n", 1 - p->shade); + draw_path(psfp, sc, p->h, p->v, pv, np - (closed != 0), 1); + fputs("FI\n", psfp); + if (p->shade != 1.0) + fputs("0 SG\n", psfp); + } + if (!(p->flags & INVISIBLE)) { + if (p->flags & DOTTED) { + int i; + for (i = 0; i < np - 1; i++) { + double x = pv[i+1].x - pv[i].x; + double y = pv[i+1].y - pv[i].y; + double dist = sqrt(x*x + y*y); + double adw; + if (dist <= dw) + adw = dist; + else + adw = dist/round(dist/dw); + fputs("0 ", psfp); + put_dim(round(sc*adw), psfp); + fputs(" DH\n", psfp); + draw_path(psfp, sc, p->h, p->v, pv + i, 2, 0); + fputs("ST\n", psfp); + } + fputs("SO\n", psfp); + } + else if (p->flags & DASHED) { + int i; + for (i = 0; i < np - 1; i++) { + double x = pv[i+1].x - pv[i].x; + double y = pv[i+1].y - pv[i].y; + double dist = sqrt(x*x + y*y); + double adw, gw; + if (dist <= dw*2.0) { + adw = dist; + gw = 0.0; + } + else { + int ndashes = (int)(ceil((dist - dw)/(dw*2.0))); + gw = (dist - dw)/ndashes - dw; + adw = dw; + } + put_dim(round(sc*adw), psfp); + putc(' ', psfp); + put_dim(round(sc*gw), psfp); + fputs(" DH\n", psfp); + draw_path(psfp, sc, p->h, p->v, pv + i, 2, 0); + fputs("ST\n", psfp); + } + fputs("SO\n", psfp); + } + else { + draw_path(psfp, sc, p->h, p->v, pv, + np - (closed != 0), closed); + fputs("ST\n", psfp); + } + } + } + } + tpic_object_list = tpic_object_list->next; + free((char *)p); + } + if (r != NO_REGION) + fputs("GR\n", psfp); + fputs("EO\n", psfp); +} + +static void draw_path(psfp, sc, ox, oy, pv, np, closed) +FILE *psfp; +double sc; +integer ox, oy; +struct point *pv; +int np; +int closed; +{ + int i; + put_dim(ox + round(pv[0].x*sc), psfp); + putc(' ', psfp); + put_dim(oy + round(pv[0].y*sc), psfp); + fputs(" MT\n", psfp); + for (i = 1; i < np; i++) { + put_dim(ox + round(pv[i].x*sc), psfp); + putc(' ', psfp); + put_dim(oy + round(pv[i].y*sc), psfp); + fputs(" LT\n", psfp); + } + if (closed) + fputs("CP\n", psfp); +} + +static void draw_spline(psfp, sc, ox, oy, pv, np) +FILE *psfp; +double sc; +integer ox, oy; +struct point *pv; +int np; +{ + int i; + put_dim(ox + round(pv[0].x*sc), psfp); + putc(' ', psfp); + put_dim(oy + round(pv[0].y*sc), psfp); + fputs(" MT\n", psfp); + put_dim(ox + round((pv[0].x+pv[1].x)*sc/2.0), psfp); + putc(' ', psfp); + put_dim(oy + round((pv[0].y+pv[1].y)*sc/2.0), psfp); + fputs(" LT\n", psfp); + for (i = 1; i < np - 1; i++) { + put_dim(ox + round((pv[i-1].x + 5*pv[i].x)*sc/6.0), psfp); + putc(' ', psfp); + put_dim(oy + round((pv[i-1].y + 5*pv[i].y)*sc/6.0), psfp); + putc(' ', psfp); + put_dim(ox + round((5*pv[i].x + pv[i+1].x)*sc/6.0), psfp); + putc(' ', psfp); + put_dim(oy + round((5*pv[i].y + pv[i+1].y)*sc/6.0), psfp); + putc(' ', psfp); + put_dim(ox + round((pv[i].x+pv[i+1].x)*sc/2.0), psfp); + putc(' ', psfp); + put_dim(oy + round((pv[i].y+pv[i+1].y)*sc/2.0), psfp); + fputs(" CT\n", psfp); + } + put_dim(ox + round(pv[np - 1].x*sc), psfp); + putc(' ', psfp); + put_dim(oy + round(pv[np - 1].y*sc), psfp); + fputs(" LT\n", psfp); +} + +static void draw_ellipse(psfp, sc, ox, oy, cx, cy, rx, ry) +FILE *psfp; +double sc; +integer ox, oy; +integer cx, cy, rx, ry; +{ + put_dim(round(rx*sc), psfp); + putc(' ', psfp); + put_dim(round(ry*sc), psfp); + putc(' ', psfp); + put_dim(ox + round(sc*cx), psfp); + putc(' ', psfp); + put_dim(oy + round(sc*cy), psfp); + fputs(" EL\n", psfp); +} + +static void draw_arc(psfp, sc, ox, oy, cx, cy, r, s, e) +FILE *psfp; +double sc; +integer ox, oy; +integer cx, cy, r; +double s, e; +{ + put_dim(ox + round(sc*cx), psfp); + putc(' ', psfp); + put_dim(oy + round(sc*cy), psfp); + putc(' ', psfp); + put_dim(round(sc*r), psfp); + fprintf(psfp, " %g %g AR\n", s*180.0/M_PI, e*180.0/M_PI); +} + +#endif + +/* +Local Variables: +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +tab-width: 4 +End: +*/ + diff --git a/dviware/dvitops/unix.h b/dviware/dvitops/unix.h new file mode 100644 index 0000000000..8e3f514053 --- /dev/null +++ b/dviware/dvitops/unix.h @@ -0,0 +1,43 @@ +/* $Header: /usr/jjc/dvitops/RCS/unix.h,v 1.2 90/08/17 15:52:56 jjc Exp $ */ +/* UNIX support */ + +#define PAPER "a4" +#define TPIC_SUPPORT + +#define TEXFONTS ".:/usr/local/tex/fonts" +#define TEXINPUTS ".:/usr/local/tex/inputs" +#define TEXPK "%f.%dpk:/usr/local/tex/pk/%f.%dpk" +#define TEXMAGS 214,240,257,270,300,329,360,432,518,622,746,896,1075,1290 +#define PSFONTS ".:/usr/local/psfonts" +#define HAVE_REDIRECTION +#define HAVE_SETVBUF +#define DPI 300 +#define FILENAME_MAX 1024 +#define AREA_LIST_SEP ':' +#define AREA_SEP '/' +#define FILENAME_HAS_AREA(f) (*(f) == '/') +#define MAXFONTS 256 +#define HAVE_ISATTY +#define HAVE_MEMORY_H + +#ifdef __STDC__ + +#define PROTO +#define HAVE_SETVBUF +#define STDARG +#include <limits.h> + +#else + +#define const +#define UCHAR_MAX 255 +#define USHRT_MAX 0xffff +#define SHRT_MAX 32767 +#define UINT_MAX 0xffff +#define INT_MAX 32767 +#define LONG_MAX 2147483647L + +#endif /* __STDC__ */ + +typedef unsigned size_t; +typedef long time_t; diff --git a/dviware/dvitops/util.c b/dviware/dvitops/util.c new file mode 100644 index 0000000000..0e09dee553 --- /dev/null +++ b/dviware/dvitops/util.c @@ -0,0 +1,412 @@ +static char rcsid[] = "$Header: /usr/jjc/dvitops/RCS/util.c,v 1.7 90/10/16 07:56:29 jjc Exp $"; + +#include "util.h" + +enum message_type history = INFORMATION; + +#ifdef STDARG +void message(enum message_type type, char *format,...) +#else +void message(va_alist) +va_dcl +#endif +{ + int c, n; + char *s; +#ifndef STDARG + enum message_type type; + char *format; +#endif + va_list ap; +#ifdef STDARG + va_start(ap, format); +#else + va_start(ap); + type = va_arg(ap, enum message_type); + format = va_arg(ap, char *); +#endif + if (program_name != NULL) { + fputs(program_name, stderr); + fputs(": ", stderr); + } + switch (type) { + case FATAL_ERROR: + fputs("fatal error: ", stderr); + break; + case ERROR: + fputs("error: ", stderr); + break; + case WARNING: + fputs("warning: ", stderr); + break; + } + while ((c = *format++) != '\0') + if (c == '%') { + c = *format++; + switch(c) { + case '%': + putc('%', stderr); + break; + case 'd': + n = va_arg(ap, int); + fprintf(stderr, "%d", n); + break; + case 's': + s = va_arg(ap, char *); + fputs(s, stderr); + break; + default: + fprintf(stderr, "...whoops! error while handling error\n"); + exit(FATAL_ERROR); + } + } + else + putc(c, stderr); + fputc('\n', stderr); + va_end(ap); + if (type == FATAL_ERROR) + exit(FATAL_ERROR); + if ((int)type > (int)history) + history = type; +} + +static int safecat(s1, s2, n) +char *s1, *s2; +int n; +{ + if (strlen(s1) + strlen(s2) + 1 > n) + return FALSE; + strcat(s1, s2); + return TRUE; +} + +/* does s1 end with s2 ? */ +static int strends(s1, s2) +char *s1, *s2; +{ + int n2 = strlen(s2); + int n1 = strlen(s1); + if (n1 < n2) + return FALSE; +#ifdef CASE_INSENSITIVE_FILENAMES + return stricmp(s1 + n1 - n2, s2) == 0; +#else + return strcmp(s1 + n1 - n2, s2) == 0; +#endif +} + +/* if ext is not NULL and filename does not end with ext, + ext will be appended to filename */ + +FILE *xfopen(filename, is_binary, al, ext) +char *filename, *al, *ext; +int is_binary; +{ + char path[FILENAME_MAX+1]; + static char list_sep[2] = {AREA_LIST_SEP, '\0'}; +#ifdef AREA_SEP + static char sep[2] = {AREA_SEP , '\0'}; +#endif /* AREA_SEP */ + char *area; + char area_list[FILENAME_MAX*4]; + if (al == NULL || FILENAME_HAS_AREA(filename)) { + if (ext != NULL && !strends(filename, ext)) { + path[0] = '\0'; + safecat(path, filename, sizeof(path)); + safecat(path, ext, sizeof(path)); + if (is_binary) + return FOPEN_RB(path); + else + return fopen(path, "r"); + } + else { + if (is_binary) + return FOPEN_RB(filename); + else + return fopen(filename, "r"); + } + } + if (strlen(al)+1 > sizeof(area_list)) + message(FATAL_ERROR, "directory list too long: %s", al); + strcpy(area_list, al); + for (area = strtok(area_list, list_sep); + area != NULL; + area = strtok(NULL, list_sep)) { +#ifdef AREA_SEP + char *p; +#endif /* AREA_SEP */ + FILE *fp; + path[0] = '\0'; +#ifndef POSTFIX_AREA + if (!safecat(path, area, sizeof(path))) + continue; +#ifdef AREA_SEP + p = path + strlen(path); + if (p > path && p[-1] != AREA_SEP +#ifdef AREA_SEP2 + && p[-1] != AREA_SEP2 +#endif /* AREA_SEP2 */ + ) { + if (!safecat(path, sep, sizeof(path))) + continue; + } +#endif /* AREA_SEP */ +#endif /* not POSTFIX_AREA */ + if (!safecat(path, filename, sizeof(path))) + continue; + if (ext != NULL && !strends(filename, ext)) + safecat(path, ext, sizeof(path)); +#ifdef POSTFIX_AREA +#ifdef AREA_SEP + if (area[0] != AREA_SEP +#ifdef AREA_SEP2 + && area[0] != AREA_SEP2 +#endif /* AREA_SEP2 */ + ) { + if (!safecat(path, sep, sizeof(path))) + continue; + } +#endif /* AREA_SEP */ + if (!safecat(path, area, sizeof(path))) + continue; +#endif /* POSTFIX_AREA */ + if (is_binary) { + if ((fp = FOPEN_RB(path)) != NULL) + return fp; + } + else { + if ((fp = fopen(path, "r")) != NULL) + return fp; + } + } + return NULL; +} + +#ifdef CASE_INSENSITIVE_FILENAMES + +int stricmp(s1, s2) +char *s1, *s2; +{ + for (;;) { + char c1 = *s1, c2 = *s2; + if (c1 == '\0') { + if (c2 == '\0') + return 0; + else + return -1; + } + else if (c2 == '\0') + return 1; + if (isascii(c1) && isupper(c1)) + c1 = tolower(c1); + if (isascii(c2) && isupper(c2)) + c2 = tolower(c2); + if (c1 != c2) + return c1 - c2; + s1++; + s2++; + } +} + +#endif /* CASE_INSENSITIVE_FILENAMES */ + +#ifdef NEED_MEM_FUNCTIONS + +int memcmp(s1, s2, n) +char *s1, *s2; +int n; +{ + for (; --n >= 0; s1++, s2++) + if (*s1 != *s2) + return *s1 - *s2; + return 0; +} + +char *memcpy(s1, s2, n) +char *s1, *s2; +int n; +{ + char *p = s1; + while (--n >= 0) + *p++ = *s2++; + return s1; +} + +char *memset(s, c, n) +char *s; +int c, n; +{ + char *p = s; + while (--n >= 0) + *p++ = c; + return s; +} + +#endif /* NEED_MEM_FUNCTIONS */ + +#ifdef NEED_QSORT + +/* This is a heap sort. */ + +void qsort(v, n, width, compar) +char *v; +int n, width; +int (*compar)(); +{ + char *ip; + char *buf; + char *last = v + (n - 1)*width; + if ((buf = malloc(width)) == 0) + out_of_memory(); + for (ip = v + (n/2)*width; ip >= v; ip -= width) { + char *jp = ip; + memcpy(buf, ip, width); + for (;;) { + char *cp = jp + (jp - v) + width; + if (cp < last) { + char *ocp = cp + width; + if ((*compar)(ocp, cp) > 0) + cp = ocp; + } + else if (cp != last) + break; + if ((*compar)(buf, cp) >= 0) + break; + memcpy(jp, cp, width); + jp = cp; + } + memcpy(jp, buf, width); + } + ip = last; + while (ip > v) { + char *jp = v; + int j; + memcpy(buf, ip, width); + memcpy(ip, v, width); + ip -= width; + for (;;) { + char *cp = jp + (jp - v) + width; + if (cp < ip) { + char *ocp = cp + width; + if ((*compar)(ocp, cp) > 0) + cp = ocp; + } + else if (cp != ip) + break; + memcpy(jp, cp, width); + jp = cp; + } + j = (jp - v)/width; + while (j != 0) { + char *kp; + j = (j - 1)/2; + kp = v + j*width; + if ((*compar)(kp, buf) >= 0) + break; + memcpy(jp, kp, width); + jp = kp; + } + memcpy(jp, buf, width); + } + free(buf); +} + +#endif /* NEED_QSORT */ + +#ifdef NEED_STRTOK + +char *strtok(s1, s2) +char *s1, *s2; +{ + static char *next; + register char *s = s1 != NULL ? s1 : next; + char *start; + for (;;) { + register char *p; + register char c = *s; + if (c == '\0') { + next = s; + return NULL; + } + for (p = s2; *p != '\0' && *p != c; p++) + ; + if (*p == '\0') + break; + s++; + } + start = s; + for (;;) { + register char *p; + register char c = *++s; + if (c == '\0') { + next = s; + return start; + } + for (p = s2; *p != '\0'; p++) + if (*p == c) { + *s = '\0'; + next = s + 1; + return start; + } + } +} + +#endif /* NEED_STRTOK */ + +#ifdef PRIMOS_GETENV + +/* Prime C doesn't provide a getenv function, but there are 'global +variables' that are like enviroment variables. The routine gvget will +retrieve the value of one of these, so we can write a getenv using it. +*/ + + +char *getenv(name) +char *name; +{ + char temp[32]; + extern char *strncat(), *gvget(); + + strcpy(temp,"."); + return(gvget(strncat(temp,name,32))); +} + +#endif /* PRIMOS_GETENV */ + +#ifdef EBCDIC +static int cnva[]={ + 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, + 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, +240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, +124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, +215,216,217,226,227,228,229,230,231,232,233,173,224,189,113,109, +121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, +151,152,153,162,163,164,165,166,167,168,169,192, 79,208, 95, 7, + 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, + 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,225, + 65, 66, 74,114, 69, 70, 71, 72, 73, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 98, 99,100,101,102,103,104,105,112, 67, 68,115,116,117, +118,119,120,128,138,139,140,141,142,143,144,154,155,156,157,158, +159,160,170,171,172,161,174,175,176,177,178,179,180,181,182,183, +184,185,186,187,188,106,190,191,202,203,204,205,206,207,218,219, +220,221,222,223,234,235,236,237,238,239,250,251,252,253,254,255 + }; + +char atoe(char c) /* convert the c from ascii to ebcdic */ +{ + return(cnva[c]); +} +#endif /* EBCDIC */ + +/* +Local Variables: +c-indent-level: 4 +c-continued-statement-offset: 4 +c-brace-offset: -4 +c-argdecl-indent: 0 +c-label-offset: -4 +tab-width: 4 +End: +*/ + diff --git a/dviware/dvitops/util.h b/dviware/dvitops/util.h new file mode 100644 index 0000000000..e63b605a53 --- /dev/null +++ b/dviware/dvitops/util.h @@ -0,0 +1,163 @@ +/* $Header: /usr/jjc/dvitops/RCS/util.h,v 1.7 90/10/16 07:53:45 jjc Exp $ */ + +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <errno.h> +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif /* HAVE_MEMORY_H */ + +#include "config.h" + +#ifndef DPI +#define DPI 300 +#endif + +#ifdef EBCDIC +#define XCHAR atoe +#endif + +#ifdef XCHAR +#define STRXCHAR(s) { char *p_; \ +for (p_ = s; *p_ != '\0'; p_++) *p_ = XCHAR(*p_); } +#else +#define STRXCHAR(s) /* as nothing */ +#endif + +#ifndef XCHAR +#define XCHAR(c) (c) +#endif + +#ifndef FOPEN_RB +#define FOPEN_RB(file) (fopen((file), "r")) +#endif + +#ifndef NORMAL_EXIT_CODE +#define NORMAL_EXIT_CODE 0 +#endif + +#ifndef WARNING_EXIT_CODE +#define WARNING_EXIT_CODE 1 +#endif + +#ifndef ERROR_EXIT_CODE +#define ERROR_EXIT_CODE 2 +#endif + +#ifndef FATAL_ERROR_EXIT_CODE +#define FATAL_ERROR_EXIT_CODE 3 +#endif + +#ifdef BROKEN_PROTO +#ifndef PROTO +#define PROTO +#endif +#define PROMOTED_UNSIGNED_CHAR unsigned char +#else +#define PROMOTED_UNSIGNED_CHAR int +#endif + +#ifdef STDARG +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_END +#define SEEK_END 2 +#endif +#ifdef PROTO +int abs(int); +char *getenv(char *); +int atoi(const char *); +long atol(const char *); +char *calloc(size_t, size_t); +void exit(int); +void free(char *); +char *getenv(char *); +char *malloc(size_t); +void qsort(char *, int, int, int (*)()); +char *realloc(char *, size_t); +double atof(const char *); +int getopt(int argc, char **argv, char *opts); +FILE *xfopen(char *filename, int is_binary, char *area_list, +char *extension); +#ifdef NEED_MEM_FUNCTIONS +int memcmp(char *, char *, int); +char *memcpy(char *, char *, int); +char *memset(char *, int, int); +#endif /* NEED_MEM_FUNCTIONS */ +time_t time(time_t *); +#ifdef NEED_STRTOK +char *strtok(char *, char *); +#endif +#ifdef CASE_INSENSITIVE_FILENAMES +int stricmp(char *, char *); +#endif +#else +int abs(); +char *getenv(); +double atof(); +int atoi(); +long atol(); +char *calloc(); +void exit(); +void free(); +char *getenv(); +char *malloc(); +void qsort(); +char *realloc(); +double atof(); +long atol(); +int getopt(); +FILE *xfopen(); +#ifdef NEED_MEM_FUNCTIONS +int memcmp(); +char *memcpy(); +char *memset(); +#endif /* NEED_MEM_FUNCTIONS */ +void qsort(); +time_t time(); +#ifdef NEED_STRTOK +char *strtok(); +#endif +#ifdef CASE_INSENSITIVE_FILENAMES +int stricmp(); +#endif +#endif + +extern int opterr; +extern int optind; +extern int optopt; +extern char *optarg; + +#define TRUE 1 +#define FALSE 0 + +#ifdef __FILE__ +#define cant_happen() message(FATAL_ERROR, "internal error: %s, line %d",\ +__FILE__, __LINE__) +#else +#define cant_happen() message(FATAL_ERROR, "internal error") +#endif + +#define out_of_memory() message(FATAL_ERROR, "out of memory") + +enum message_type {INFORMATION = 0, WARNING = 1, ERROR = 2, FATAL_ERROR = 3 }; + +extern enum message_type history; +extern char *program_name; + +#ifdef STDARG +void message(enum message_type, char *,...); +#else +void message(); +#endif diff --git a/dviware/dvitops/vms.h b/dviware/dvitops/vms.h new file mode 100644 index 0000000000..235c1ee52c --- /dev/null +++ b/dviware/dvitops/vms.h @@ -0,0 +1,47 @@ +/* $Header: /usr/jjc/dvitops/RCS/vms.h,v 1.1 90/08/14 12:57:32 jjc Rel $ */ +/* Support for VMS. */ + +#define PAPER "a4" + +/* These definitions are certainly not right */ +#define TEXFONTS "[];SOME$DISK:[TEX.FONTS];TEX_FONTS" +#define TEXINPUTS "[];SOME$DISK:[TEX.INPUTS];TEX_INPUTS" +#define TEXPK "[]%f.%dPK;SOME$DISK:[TEX.PK]%f.%dPK;TEX_PK:%f.%dPK" +#define TEXMAGS 214,240,257,270,300,329,360,432,518,622,746,896,1075,1290 +#define PSFONTS "[];SOME$DISK:[TEX.PSFONTS]" +/*#define HAVE_REDIRECTION */ +/*#define HAVE_SETVBUF */ +#define DPI 300 +#define FILENAME_MAX 1024 +#define AREA_LIST_SEP ';' +#define AREA_SEP ':' +#define AREA_SEP2 ']' +#define FILENAME_HAS_AREA(f) (strchr(f, ':') != NULL && strchr(f, ']') != NULL) +#define MAXFONTS 256 +#define HAVE_ISATTY + +#define FOPEN_RB(file) (fopen((file), "r", "ctx=stm")) + +#ifdef __STDC__ + +#define PROTO +/* #define BROKEN_PROTO */ +#define HAVE_SETVBUF +#define STDARG +#include <limits.h> +#include <stddef.h> + +#else + +#define const +#define UCHAR_MAX 255 +#define USHRT_MAX 0xffff +#define SHRT_MAX 32767 +#define UINT_MAX 0xffff +#define INT_MAX 32767 +#define LONG_MAX 2147483647L +typedef int size_t; + +#endif /* __STDC__ */ + +typedef long time_t; |