home *** CD-ROM | disk | FTP | other *** search
- /* $RCSfile: paren.c,v $ $Revision: 2.0 $ */
-
- #include <stdio.h>
- #include "gdefs.h"
- #include "externals.h"
- #include "protos.h"
-
- extern FILE *ifile,*ofile;
-
- static char *type_faces[] = {
- "LinePrinter",
- "Pica",
- "Elite",
- "Courier",
- "Helv",
- "Tms Rmn",
- "Gothic",
- "Script",
- "Prestige Elite",
- "Caslon",
- "Orator",
- "Presentations",
- "???",
- "???",
- "???",
- "???",
- "???",
- "Optima",
- "ITC Garamond",
- "Cooper Black",
- "Coronet Bold",
- "Broadway",
- "Bauer Bodoni Black Condensed",
- "Century Schoolbook",
- "University Roman",
- };
-
- static char *spacings[] = {
- "Fixed",
- "Proportional",
- };
-
- static char *quality[] = {
- "Draft",
- "Draft",
- "Letter",
- };
-
- static char *placement[] = {
- "Begin subscripts",
- "Resume normal printing",
- "Begin superscripts",
- };
-
- static char *styles[] = {
- "Upright",
- "Italics",
- };
-
- #define MAX_SET_AT 3
- static char *symbol_set_at[MAX_SET_AT + 1] = {
- "printer default",
- "primary default",
- "current primary",
- "default",
- };
-
- #define MAX_SET_A 0
- static char *symbol_set_a[MAX_SET_A + 1] = {
- "Math Symbols",
- };
-
- #define MAX_SET_B 0
- static char *symbol_set_b[MAX_SET_B + 1] = {
- "Line Draw",
- };
-
- #define MAX_SET_D 1
- static char *symbol_set_d[MAX_SET_D + 1] = {
- "ISO 60: Norwegian 1",
- "ISO 61: Norwegian 2",
- };
-
- #define MAX_SET_E 1
- static char *symbol_set_e[MAX_SET_E + 1] = {
- "Roman Extension",
- "ISO 4: United Kingdom",
- };
-
- #define MAX_SET_F 1
- static char *symbol_set_f[MAX_SET_F + 1] = {
- "ISO 25: French",
- "ISO 69: French",
- };
-
- #define MAX_SET_G 1
- static char *symbol_set_g[MAX_SET_G + 1] = {
- "HP German",
- "ISO 21: German",
- };
-
- #define MAX_SET_I 0
- static char *symbol_set_i[MAX_SET_I + 1] = {
- "ISO 15: Italian",
- };
-
- #define MAX_SET_K 8
- static char *symbol_set_k[MAX_SET_K + 1] = {
- "ISO 14: JIS ASCII",
- "",
- "ISO 57: Chinese",
- "",
- "",
- "",
- "",
- "",
- "Kana-8",
- };
-
- #define MAX_SET_L 0
- static char *symbol_set_l[MAX_SET_L + 1] = {
- "Line Draw",
- };
-
-
- #define MAX_SET_M 8
- static char *symbol_set_m[MAX_SET_M + 1] = {
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "Math8",
- };
-
- #define MAX_SET_N 0
- static char *symbol_set_n[MAX_SET_N + 1] = {
- "ECMA-94: Latin 1",
- };
-
- #define MAX_SET_Q 2
- static char *symbol_set_q[MAX_SET_Q + 1] = {
- "Math8a",
- "Math8b",
- "PI Fonta",
- };
-
- #define MAX_SET_S 6
- static char *symbol_set_s[MAX_SET_S + 1] = {
- "ISO 11: Swedish",
- "HP Spanish",
- "ISO 17: Spanish",
- "ISO 10: Swedish",
- "ISO 16: Portuguese",
- "ISO 84: Portuguese",
- "ISO 85: Spanish",
- };
-
- #define MAX_SET_U 15
- static char *symbol_set_u[MAX_SET_U + 1] = {
- "ISO 6: ASCII",
- "Legal",
- "ISO 2: IRV",
- "",
- "",
- "",
- "",
- "",
- "HP Roman8",
- "ANSI-8",
- "PC-8",
- "PC-8 (Danish/Norwegian)",
- "PC 850",
- "",
- "",
- "PI Font",
- };
-
- void decode_paren(void) /* <Esc>( or <Esc>) */
- {
- int start_pos;
- int stop_pos;
- int i;
- int max;
- int done;
- int starting_val;
- char c1,c2,c3;
- char *font;
- char **pp_char;
-
- c1 = esc_string[1];
- c2 = esc_string[2];
- c3 = esc_string[3];
- font = primary;
- if (c1 == ')') {
- font = secondary;
- }
- if ((c2 >= '0') && (c2 <= '9')) {
- /* The font selection sequences seem to vary from the standard
- pcl practice of following the escape with 2 characters then
- a number.
- All the pcl font selection examples do not try to combine
- any of this group of escape sequences. Good software should
- try to avoid the confusion of combining these sequences
- as well.
- */
-
- starting_val = c2 - '0';
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,starting_val);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- if (c3 == '@') {
- if ((num >= 0) && (num <= MAX_SET_AT)) {
- fprintf(ofile,"Designate %s font set as %s\n",
- symbol_set_at[num],font);
- if (num == 3) {
- indent(4);
- fprintf(ofile,
- "Set all font characteristics (except orientation) to\n");
- indent(4);
- fprintf(ofile,
- "those of the default %s font.\n", font);
- }
- }
- else {
- fprintf(ofile,"Designate %s font ???\n", font);
- }
- }
- else if ((c3 == 'x') || (c3 == 'X')) {
- fprintf(ofile,"select %s font with ID # = %d\n", font,num);
- }
- else {
- pp_char = NULL;
- max = -1;
- switch (c3) {
- case 'a':
- case 'A':
- max = MAX_SET_A;
- pp_char = symbol_set_a;
- break;
- case 'b':
- case 'B':
- max = MAX_SET_B;
- pp_char = symbol_set_b;
- break;
- case 'd':
- case 'D':
- max = MAX_SET_D;
- pp_char = symbol_set_d;
- break;
- case 'e':
- case 'E':
- max = MAX_SET_E;
- pp_char = symbol_set_e;
- break;
- case 'f':
- case 'F':
- max = MAX_SET_F;
- pp_char = symbol_set_f;
- break;
- case 'g':
- case 'G':
- max = MAX_SET_G;
- pp_char = symbol_set_g;
- break;
- case 'i':
- case 'I':
- max = MAX_SET_I;
- pp_char = symbol_set_i;
- break;
- case 'k':
- case 'K':
- max = MAX_SET_K;
- pp_char = symbol_set_k;
- break;
- case 'l':
- case 'L':
- max = MAX_SET_L;
- pp_char = symbol_set_l;
- break;
- case 'm':
- case 'M':
- max = MAX_SET_M;
- pp_char = symbol_set_m;
- break;
- case 'n':
- case 'N':
- max = MAX_SET_N;
- pp_char = symbol_set_n;
- break;
- case 'q':
- case 'Q':
- max = MAX_SET_Q;
- pp_char = symbol_set_q;
- break;
- case 's':
- case 'S':
- max = MAX_SET_S;
- pp_char = symbol_set_s;
- break;
- case 'u':
- case 'U':
- max = MAX_SET_U;
- pp_char = symbol_set_u;
- break;
- default:
- break;
- }
- if (pp_char != NULL) {
- fprintf(ofile,"%s font set = ",font);
- if ((num >= 0) && (num <= max)) {
- if (**(pp_char + num) != 0) {
- fprintf(ofile,"%s\n",*(pp_char + num));
- }
- else {
- fprintf(ofile,questions);
- }
- }
- else {
- fprintf(ofile,questions);
- }
- }
- else {
- fprintf(ofile,"%s",bad_esc);
- }
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 's') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'b':
- case 'B':
- fprintf(ofile,"%s font weight = ", font);
- if ((num < -7) || (num > 7)) {
- fprintf(ofile,out_of_range,num);
- }
- else if (num < 0) {
- fprintf(ofile,"Light (%d)\n", num);
- }
- else if (num > 0) {
- fprintf(ofile,"Bold (%d)\n", num);
- }
- else {
- fprintf(ofile,"Medium (%d)\n", num);
- }
- break;
- case 'h':
- case 'H':
- if (is_float) {
- fprintf(ofile,
- "%s font characters per inch = %d.%s\n",
- font, num, fraction);
- }
- else {
- fprintf(ofile,"%s font characters per inch = %d\n",
- font, num);
- }
- break;
- case 'p':
- case 'P': /* Fixed or proportional */
- fprintf(ofile,"%s font spacing = ",font);
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",spacings[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'q':
- case 'Q': /* Letter or draft quality */
- if (c1 == '(') {
- fprintf(ofile,"Print quality = ");
- if ((num >= 0) && (num <= 2)) {
- fprintf(ofile,"%s\n",quality[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- }
- else {
- fprintf(ofile,"%s",bad_esc);
- }
- break;
- case 's':
- case 'S':
- fprintf(ofile,"%s font style = ",font);
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",styles[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 't':
- case 'T':
- fprintf(ofile,"%s font typeface = ",font);
- if ((num >= 0) && (num <= 24)) {
- fprintf(ofile,"%s\n",type_faces[num]);
- }
- else if (num == 85) {
- fprintf(ofile,"%s\n","Univers Condensed");
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'u':
- case 'U':
- fprintf(ofile,"%s text placement = ",font);
- if ((num >= -1) && (num <= 1)) {
- fprintf(ofile,"%s\n",placement[num+1]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'v':
- case 'V':
- fprintf(ofile,"%s font point size = ",font);
- if (is_float) {
- fprintf(ofile, "%d.%s\n", num, fraction);
- }
- else {
- fprintf(ofile, "%d\n", num);
- }
- break;
- case 'W': /* Can't have 'w' */
- if (c1 == '(') {
- fprintf(ofile,
- "Font Descriptor (font header) in next %d characters\n",
- num);
- }
- else {
- fprintf(ofile,
- "Download character data in next %d characters\n",
- num);
- }
- for (i=0; i<num; i++) {
- c1 = getc(ifile);
- }
- done = TRUE;
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else {
- fprintf(ofile,"%s",bad_esc);
- }
- }
-