home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / misc / pcl2english.lzh / PAREN.C < prev    next >
C/C++ Source or Header  |  1990-10-16  |  9KB  |  475 lines

  1. /* $RCSfile: paren.c,v $  $Revision: 2.0 $ */
  2.  
  3. #include <stdio.h>
  4. #include "gdefs.h"
  5. #include "externals.h"
  6. #include "protos.h"
  7.  
  8. extern FILE *ifile,*ofile;
  9.  
  10. static char *type_faces[] = {
  11.     "LinePrinter",
  12.     "Pica",
  13.     "Elite",
  14.     "Courier",
  15.     "Helv",
  16.     "Tms Rmn",
  17.     "Gothic",
  18.     "Script",
  19.     "Prestige Elite",
  20.     "Caslon",
  21.     "Orator",
  22.     "Presentations",
  23.     "???",
  24.     "???",
  25.     "???",
  26.     "???",
  27.     "???",
  28.     "Optima",
  29.     "ITC Garamond",
  30.     "Cooper Black",
  31.     "Coronet Bold",
  32.     "Broadway",
  33.     "Bauer Bodoni Black Condensed",
  34.     "Century Schoolbook",
  35.     "University Roman",
  36. };
  37.  
  38. static char *spacings[] = {
  39.     "Fixed",
  40.     "Proportional",
  41. };
  42.  
  43. static char *quality[] = {
  44.     "Draft",
  45.     "Draft",
  46.     "Letter",
  47. };
  48.  
  49. static char *placement[] = {
  50.     "Begin subscripts",
  51.     "Resume normal printing",
  52.     "Begin superscripts",
  53. };
  54.  
  55. static char *styles[] = {
  56.     "Upright",
  57.     "Italics",
  58. };
  59.  
  60. #define MAX_SET_AT    3
  61. static char *symbol_set_at[MAX_SET_AT + 1] = {
  62.     "printer default",
  63.     "primary default",
  64.     "current primary",
  65.     "default",
  66. };
  67.  
  68. #define MAX_SET_A    0
  69. static char *symbol_set_a[MAX_SET_A + 1] = {
  70.     "Math Symbols",
  71. };
  72.  
  73. #define MAX_SET_B    0
  74. static char *symbol_set_b[MAX_SET_B + 1] = {
  75.     "Line Draw",
  76. };
  77.  
  78. #define MAX_SET_D    1
  79. static char *symbol_set_d[MAX_SET_D + 1] = {
  80.     "ISO 60: Norwegian 1",
  81.     "ISO 61: Norwegian 2",
  82. };
  83.  
  84. #define MAX_SET_E    1
  85. static char *symbol_set_e[MAX_SET_E + 1] = {
  86.     "Roman Extension",
  87.     "ISO 4: United Kingdom",
  88. };
  89.  
  90. #define MAX_SET_F    1
  91. static char *symbol_set_f[MAX_SET_F + 1] = {
  92.     "ISO 25: French",
  93.     "ISO 69: French",
  94. };
  95.  
  96. #define MAX_SET_G    1
  97. static char *symbol_set_g[MAX_SET_G + 1] = {
  98.     "HP German",
  99.     "ISO 21: German",
  100. };
  101.  
  102. #define MAX_SET_I    0
  103. static char *symbol_set_i[MAX_SET_I + 1] = {
  104.     "ISO 15: Italian",
  105. };
  106.  
  107. #define MAX_SET_K    8
  108. static char *symbol_set_k[MAX_SET_K + 1] = {
  109.     "ISO 14: JIS ASCII",
  110.     "",
  111.     "ISO 57: Chinese",
  112.     "",
  113.     "",
  114.     "",
  115.     "",
  116.     "",
  117.     "Kana-8",
  118. };
  119.  
  120. #define MAX_SET_L    0
  121. static char *symbol_set_l[MAX_SET_L + 1] = {
  122.     "Line Draw",
  123. };
  124.  
  125.  
  126. #define MAX_SET_M    8
  127. static char *symbol_set_m[MAX_SET_M + 1] = {
  128.     "",
  129.     "",
  130.     "",
  131.     "",
  132.     "",
  133.     "",
  134.     "",
  135.     "",
  136.     "Math8",
  137. };
  138.  
  139. #define MAX_SET_N    0
  140. static char *symbol_set_n[MAX_SET_N + 1] = {
  141.     "ECMA-94: Latin 1",
  142. };
  143.  
  144. #define MAX_SET_Q    2
  145. static char *symbol_set_q[MAX_SET_Q + 1] = {
  146.     "Math8a",
  147.     "Math8b",
  148.     "PI Fonta",
  149. };
  150.  
  151. #define MAX_SET_S    6
  152. static char *symbol_set_s[MAX_SET_S + 1] = {
  153.     "ISO 11: Swedish",
  154.     "HP Spanish",
  155.     "ISO 17: Spanish",
  156.     "ISO 10: Swedish",
  157.     "ISO 16: Portuguese",
  158.     "ISO 84: Portuguese",
  159.     "ISO 85: Spanish",
  160. };
  161.  
  162. #define MAX_SET_U    15
  163. static char *symbol_set_u[MAX_SET_U + 1] = {
  164.     "ISO 6: ASCII",
  165.     "Legal",
  166.     "ISO 2: IRV",
  167.     "",
  168.     "",
  169.     "",
  170.     "",
  171.     "",
  172.     "HP Roman8",
  173.     "ANSI-8",
  174.     "PC-8",
  175.     "PC-8 (Danish/Norwegian)",
  176.     "PC 850",
  177.     "",
  178.     "",
  179.     "PI Font",
  180. };
  181.  
  182. void decode_paren(void)    /* <Esc>(  or  <Esc>) */
  183. {
  184.     int         start_pos;
  185.     int         stop_pos;
  186.     int         i;
  187.     int         max;
  188.     int         done;
  189.     int         starting_val;
  190.     char     c1,c2,c3;
  191.     char    *font;
  192.     char    **pp_char;
  193.  
  194.     c1 = esc_string[1];
  195.     c2 = esc_string[2];
  196.     c3 = esc_string[3];
  197.     font = primary;
  198.     if (c1 == ')') {
  199.         font = secondary;
  200.     }
  201.     if ((c2 >= '0') && (c2 <= '9')) {
  202.         /* The font selection sequences seem to vary from the standard
  203.            pcl practice of following the escape with 2 characters then
  204.            a number.  
  205.            All the pcl font selection examples do not try to combine
  206.            any of this group of escape sequences.  Good software should
  207.            try to avoid the confusion of combining these sequences
  208.            as well.
  209.            */
  210.  
  211.         starting_val = c2 - '0';
  212.         start_pos = stop_pos = 3;
  213.         done = FALSE;
  214.         while (done == FALSE) {
  215.             get_num(&stop_pos,starting_val);
  216.             c3 = esc_string[stop_pos];
  217.             print_sub_string(2, start_pos, stop_pos);
  218.             if (c3 == '@') {
  219.                 if ((num >= 0) && (num <= MAX_SET_AT)) {
  220.                     fprintf(ofile,"Designate %s font set as %s\n", 
  221.                         symbol_set_at[num],font);
  222.                     if (num == 3) {
  223.                         indent(4);
  224.                         fprintf(ofile,
  225.                             "Set all font characteristics (except orientation) to\n");
  226.                         indent(4);
  227.                         fprintf(ofile,
  228.                             "those of the default %s font.\n", font);
  229.                     }
  230.                 }
  231.                 else {
  232.                     fprintf(ofile,"Designate %s font ???\n",  font);
  233.                 }
  234.             }
  235.             else if ((c3 == 'x') || (c3 == 'X')) {
  236.                 fprintf(ofile,"select %s font with ID # = %d\n", font,num);
  237.             }
  238.             else {
  239.                 pp_char = NULL;
  240.                 max = -1;
  241.                 switch (c3) {
  242.                     case 'a':
  243.                     case 'A':
  244.                         max = MAX_SET_A;
  245.                         pp_char = symbol_set_a;
  246.                         break;
  247.                     case 'b':
  248.                     case 'B':
  249.                         max = MAX_SET_B;
  250.                         pp_char = symbol_set_b;
  251.                         break;
  252.                     case 'd':
  253.                     case 'D':
  254.                         max = MAX_SET_D;
  255.                         pp_char = symbol_set_d;
  256.                         break;
  257.                     case 'e':
  258.                     case 'E':
  259.                         max = MAX_SET_E;
  260.                         pp_char = symbol_set_e;
  261.                         break;
  262.                     case 'f':
  263.                     case 'F':
  264.                         max = MAX_SET_F;
  265.                         pp_char = symbol_set_f;
  266.                         break;
  267.                     case 'g':
  268.                     case 'G':
  269.                         max = MAX_SET_G;
  270.                         pp_char = symbol_set_g;
  271.                         break;
  272.                     case 'i':
  273.                     case 'I':
  274.                         max = MAX_SET_I;
  275.                         pp_char = symbol_set_i;
  276.                         break;
  277.                     case 'k':
  278.                     case 'K':
  279.                         max = MAX_SET_K;
  280.                         pp_char = symbol_set_k;
  281.                         break;
  282.                     case 'l':
  283.                     case 'L':
  284.                         max = MAX_SET_L;
  285.                         pp_char = symbol_set_l;
  286.                         break;
  287.                     case 'm':
  288.                     case 'M':
  289.                         max = MAX_SET_M;
  290.                         pp_char = symbol_set_m;
  291.                         break;
  292.                     case 'n':
  293.                     case 'N':
  294.                         max = MAX_SET_N;
  295.                         pp_char = symbol_set_n;
  296.                         break;
  297.                     case 'q':
  298.                     case 'Q':
  299.                         max = MAX_SET_Q;
  300.                         pp_char = symbol_set_q;
  301.                         break;
  302.                     case 's':
  303.                     case 'S':
  304.                         max = MAX_SET_S;
  305.                         pp_char = symbol_set_s;
  306.                         break;
  307.                     case 'u':
  308.                     case 'U':
  309.                         max = MAX_SET_U;
  310.                         pp_char = symbol_set_u;
  311.                         break;
  312.                     default:
  313.                         break;
  314.                 }
  315.                 if (pp_char != NULL) {
  316.                     fprintf(ofile,"%s font set = ",font);
  317.                     if ((num >= 0) && (num <= max)) {
  318.                         if (**(pp_char + num) != 0) {
  319.                             fprintf(ofile,"%s\n",*(pp_char + num));
  320.                         }
  321.                         else {
  322.                             fprintf(ofile,questions);
  323.                         }
  324.                     }
  325.                     else {
  326.                         fprintf(ofile,questions);
  327.                     }
  328.                 }
  329.                 else {
  330.                     fprintf(ofile,"%s",bad_esc);
  331.                 }
  332.             }
  333.             stop_pos++;
  334.             start_pos = stop_pos;
  335.             if (esc_string[start_pos] == 0) {
  336.                 done = TRUE;
  337.             }
  338.         }
  339.     }
  340.     else if (c2 == 's') {
  341.         start_pos = stop_pos = 3;
  342.         done = FALSE;
  343.         while (done == FALSE) {
  344.             get_num(&stop_pos,0);
  345.             c3 = esc_string[stop_pos];
  346.             print_sub_string(2, start_pos, stop_pos);
  347.             switch (c3) {
  348.                 case 'b':
  349.                 case 'B':
  350.                     fprintf(ofile,"%s font weight = ", font);
  351.                     if ((num < -7) || (num > 7)) {
  352.                         fprintf(ofile,out_of_range,num);
  353.                     }
  354.                     else if (num < 0) {
  355.                         fprintf(ofile,"Light (%d)\n", num);
  356.                     }
  357.                     else if (num > 0) {
  358.                         fprintf(ofile,"Bold (%d)\n", num);
  359.                     }
  360.                     else {
  361.                         fprintf(ofile,"Medium (%d)\n", num);
  362.                     }
  363.                     break;
  364.                 case 'h':
  365.                 case 'H':
  366.                     if (is_float) {
  367.                         fprintf(ofile,
  368.                             "%s font characters per inch = %d.%s\n",
  369.                             font, num, fraction);
  370.                     }
  371.                     else {
  372.                         fprintf(ofile,"%s font characters per inch = %d\n",
  373.                             font, num);
  374.                     }
  375.                     break;
  376.                 case 'p':
  377.                 case 'P':    /* Fixed or proportional */
  378.                     fprintf(ofile,"%s font spacing = ",font);
  379.                     if ((num >= 0) && (num <= 1)) {
  380.                         fprintf(ofile,"%s\n",spacings[num]);
  381.                     }
  382.                     else {
  383.                         fprintf(ofile,questions);
  384.                     }
  385.                     break;
  386.                 case 'q':
  387.                 case 'Q':    /* Letter or draft quality */
  388.                     if (c1 == '(') {
  389.                         fprintf(ofile,"Print quality = ");
  390.                         if ((num >= 0) && (num <= 2)) {
  391.                             fprintf(ofile,"%s\n",quality[num]);
  392.                         }
  393.                         else {
  394.                             fprintf(ofile,questions);
  395.                         }
  396.                     }
  397.                     else {
  398.                         fprintf(ofile,"%s",bad_esc);
  399.                     }
  400.                     break;
  401.                 case 's':
  402.                 case 'S':
  403.                     fprintf(ofile,"%s font style = ",font);
  404.                     if ((num >= 0) && (num <= 1)) {
  405.                         fprintf(ofile,"%s\n",styles[num]);
  406.                     }
  407.                     else {
  408.                         fprintf(ofile,questions);
  409.                     }
  410.                     break;
  411.                 case 't':
  412.                 case 'T':
  413.                     fprintf(ofile,"%s font typeface = ",font);
  414.                     if ((num >= 0) && (num <= 24)) {
  415.                         fprintf(ofile,"%s\n",type_faces[num]);
  416.                     }
  417.                     else if (num == 85) {
  418.                         fprintf(ofile,"%s\n","Univers Condensed");
  419.                     }
  420.                     else {
  421.                         fprintf(ofile,questions);
  422.                     }
  423.                     break;
  424.                 case 'u':
  425.                 case 'U':
  426.                     fprintf(ofile,"%s text placement = ",font);
  427.                     if ((num >= -1) && (num <= 1)) {
  428.                         fprintf(ofile,"%s\n",placement[num+1]);
  429.                     }
  430.                     else {
  431.                         fprintf(ofile,questions);
  432.                     }
  433.                     break;
  434.                 case 'v':
  435.                 case 'V':
  436.                     fprintf(ofile,"%s font point size = ",font);
  437.                     if (is_float) {
  438.                         fprintf(ofile, "%d.%s\n", num, fraction);
  439.                     }
  440.                     else {
  441.                         fprintf(ofile, "%d\n", num);
  442.                     }
  443.                     break;
  444.                 case 'W':    /* Can't have 'w' */
  445.                     if (c1 == '(') {
  446.                         fprintf(ofile,
  447.                             "Font Descriptor (font header) in next %d characters\n",
  448.                             num);
  449.                     }
  450.                     else {
  451.                         fprintf(ofile,
  452.                             "Download character data in next %d characters\n",
  453.                             num);
  454.                     }
  455.                     for (i=0; i<num; i++) {
  456.                         c1 = getc(ifile);
  457.                     }
  458.                     done = TRUE;
  459.                     break;
  460.                 default:
  461.                     fprintf(ofile,"%s",bad_esc);
  462.                     break;
  463.             }
  464.             stop_pos++;
  465.             start_pos = stop_pos;
  466.             if (esc_string[start_pos] == 0) {
  467.                 done = TRUE;
  468.             }
  469.         }
  470.     }
  471.     else {
  472.         fprintf(ofile,"%s",bad_esc);
  473.     }
  474. }
  475.