home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / DCFVBA.ZIP / DCFPAR.C < prev    next >
Text File  |  1990-05-04  |  4KB  |  187 lines

  1. /**
  2. ***  This is a part of the DCFVBA project.   This set of functions handle
  3. ***  The PCL datastreams beginning with:  <Esc>(
  4. **/
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "dcfvba.h"
  10.  
  11. /* -------------------------------------------------------------------------- */
  12.  
  13. void pcl_paren(void)
  14.    {
  15.    char   pcl_command;
  16.  
  17.    double number;  /* holds PCL argument */
  18.    next_char();
  19.    pcl_command = (char)toupper(*current);
  20.    switch(pcl_command)
  21.       {
  22.       case 'S':
  23.          {
  24.          do
  25.             {
  26.             next_char();
  27.             number = get_pcl_arg();
  28.             pcl_paren_S(number);
  29.             }
  30.          while(strchr(PCL_END_SET,*current) == NULL);
  31.          break;
  32.          } /* case 'S' */
  33.       case '1':
  34.       case '2':
  35.       case '3':
  36.       case '4':
  37.       case '5':
  38.       case '6':
  39.       case '7':
  40.       case '8':
  41.       case '9':
  42.          {
  43.          number = get_pcl_arg();
  44.          pcl_paren_number(number);
  45.          break;
  46.          }
  47.       default:
  48.          {
  49.          char error_message[255];
  50.  
  51.          sprintf(error_message,"Unsupported PCL command: <Esc>(%c",*current);
  52.          error(error_message,8);
  53.          } /* default */
  54.       } /* switch */
  55.    } /* pcl_paren */
  56.  
  57. /* -------------------------------------------------------------------------- */
  58.  
  59. void pcl_paren_S(double number)
  60.    {
  61.    char pcl_char;
  62.  
  63.    pcl_char = (char)toupper(*current);
  64.    switch(pcl_char)
  65.       {
  66.       case 'B': /* Bold */
  67.          {
  68.          if (number == 3)  /* Bold on */
  69.             {
  70.             new_line();
  71.             fputs(".bf bold\n",vba_file);
  72.             bold = 1;
  73.             }
  74.          else
  75.          if ((number == 0) ||
  76.              (number == -3))
  77.             {
  78.             if (bold)
  79.                {
  80.                new_line();
  81.                fputs(".pf\n",vba_file);
  82.                strcpy(line,".ct ");
  83.                bold = 0;
  84.                }
  85.             }
  86.          else
  87.             error("Invalid PCL datastream",12);
  88.          break;
  89.          }
  90.       case 'H': /* Set pitch */
  91.          {
  92.          if (number != 10)
  93.             error("Unsupported pitch",0);
  94.          break;
  95.          }
  96.       case 'P': /* Proportional spacing */
  97.          {
  98.          if (number != 0)
  99.             error("Proportional spacing not supported",0);
  100.          break;
  101.          }
  102.       case 'S': /* Italics */
  103.          {
  104.          if (number == 0)
  105.             {
  106.             if (italics)
  107.                {
  108.                new_line();
  109.                fputs(".us off\n",vba_file);
  110.                strcpy(line,".ct ");
  111.                italics = 0;
  112.                }
  113.             break;
  114.             }
  115.          else
  116.          if (number == 1)
  117.             {
  118.             new_line();
  119.             fputs(".us on\n",vba_file);
  120.             italics = 1;
  121.             break;
  122.             }
  123.          else
  124.             error("Invalid PCL data stream",12);
  125.          } /* case 'S' */
  126.       case 'T': /* Select typeface */
  127.          {
  128.          if (number != 3)
  129.             error("Unsupported typeface",0);
  130.          break;
  131.          }
  132.       case 'U': /* Super/sub script */
  133.          {
  134.          if (number != 0)
  135.             (number == 1) ?
  136.                  error("Superscript not supported",0) :
  137.                  error("Subscript not supported",0);
  138.          break;
  139.          }
  140.       case 'V': /* Character height */
  141.          {
  142.          if (number != 12)
  143.             error("Unsupported character height",0);
  144.          break;
  145.          }
  146.       default:
  147.          error("Invalid PCL datastream",12);
  148.       } /* switch */
  149.    }
  150.  
  151. /* -------------------------------------------------------------------------- */
  152.  
  153. void pcl_paren_number(double number)
  154.    {
  155.    char pcl_char;
  156.  
  157.    pcl_char = (char)toupper(*current);
  158.    switch(pcl_char)
  159.       {
  160.       case 'D':
  161.       case 'E':
  162.       case 'F':
  163.       case 'G':
  164.       case 'H':
  165.       case 'I':
  166.       case 'K':
  167.       case 'S':
  168.          {
  169.          error("Unsupported font selection",0);
  170.          break;
  171.          }
  172.       case 'U': /* IBM PC U.S.A */
  173.          {
  174.          if (number != 10)
  175.             error("Unsupported font selection",0);
  176.          break;
  177.          }
  178.       case '@': /* Font default */
  179.          {
  180.          error("Font default PCL command not supported",0);
  181.          break;
  182.          }
  183.       default:
  184.          error("Invalid PCL datastream",12);
  185.       } /* switch */
  186.    }
  187.