home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8710 / 18 / troff2lj.c < prev   
Encoding:
C/C++ Source or Header  |  1990-07-13  |  14.2 KB  |  637 lines

  1. /*
  2.  *    Filter that translates troff CAT output into commands for
  3.  *    an HP LaserJet II printer with the K font cartridge.
  4.  *    Ideally troff should be used with special width tables,
  5.  *    however, the standard CAT tables produce a readable output.
  6.  *
  7.  *    Note that the K font cartridge only allows point sizes 8 and 10.
  8.  *    A possible fix would be to use the Z font cartridge or to
  9.  *    implement downloadable fonts.
  10.  */
  11. #include <stdio.h>
  12.  
  13. /*#define DEBUG                /* Debug option */
  14. #define COMPRESS            /* Compress text horizontally 5% */
  15. #define BERKELEY_HACK            /* Codes 0116/0117 are not tilt */
  16. #define LINES        (11*432)    /* #CAT-lines on a page */
  17.  
  18. /* Convert CAT units to LaserJet units and set first page offset (CAT units) */
  19.  
  20. #define SCALE_X(n)    ((300*n)/432)
  21. #ifdef COMPRESS
  22. # define SCALE_Y(n)    ((286.36*n)/432+75)    /* 10.5", 0.25" margin */
  23. # define SKIP        348            /* Empirical */
  24. #else
  25. # define SCALE_Y(n)    ((300*n)/432)        /* 11", no margin */
  26. # define SKIP        240            /* Empirical */
  27. #endif
  28.  
  29. /* Some escape codes for LaserJet */
  30.  
  31. #define INIT        "\033E\033&l0O\033(0U\033(s1p10v0s0b5T"
  32. #define EXIT        "\033E\033&k2G"
  33. #define X_POS(x)    "\033*p%dX",x        /* Left to right */
  34. #define XY_POS(x,y)    "\033*p%dx%dY",x,y    /* Top to bottom */
  35. #define FORM_FEED    "\033&l1H"
  36. #define POINT_SIZE(n)    "\033(s%dV",n
  37. #define ITALIC_OFF    "\033(s0S"
  38. #define ITALIC_ON    "\033(s1S"
  39. #define BOLD_OFF    "\033(s0B"
  40. #define BOLD_ON        "\033(s3B"
  41.  
  42. static char *prog_name;
  43.  
  44. /* State of CAT, escape is horizontal motion, lead is vertical motion */
  45.  
  46. static char upper_rail = 0;
  47. static char upper_mag = 0;
  48. static char tilt_up = 0;
  49. static char upper_font = 0;
  50. static char escape_backward = 0;
  51. static char lead_backward = 0;
  52. static char lead_magnification = 0;
  53.  
  54. /* These have corresponding LaserJet variables (below) */
  55.  
  56. static char cat_font = 2;
  57. static char cat_ps = 10;
  58. static int cat_col = 0;
  59. static int cat_row = -SKIP;
  60.  
  61. /* State of LaserJet */
  62.  
  63. static char hp_char_set = 0;        /* Values 0 through 5 are allowed */
  64. static char page_not_blank = 0;        /* Flag */
  65.  
  66. /* These have corresponding CAT variables (above) */
  67.  
  68. static char hp_font = 2;
  69. static char hp_ps = 10;
  70. static int hp_col = -100000;        /* These are in LaserJet units */
  71. static int hp_row = -100000;        /* 300 per inch */
  72.  
  73. static struct char_table {
  74.     char c;                /* LaserJet character */
  75.     char char_set;            /* LaserJet character set */
  76.     char x_shift;            /* Horizontal ajustment */
  77.     char y_shift;            /* Vertical ajustment */
  78. };
  79.  
  80. /*
  81.  *    The next two char_table structures define the mapping of a
  82.  *    CAT character position to the corresponding LaserJet character.
  83.  *    Note the following restrictions in the K font point sizes:
  84.  *
  85.  *    Style                Character Set #
  86.  *            0    1    2    3    4    5
  87.  *    Roman        8,10    8,10    8,10    8,10    10    10
  88.  *    Italic        10    10    *    *    *    *
  89.  *    Bold        10    10    *    *    *    *
  90.  *
  91.  *    The x_shift, y_shift fields are for fine tuning of the final
  92.  *    character position. These will be scaled with the point size
  93.  *    and should be given in units 3000 to the inch for point size 10.
  94.  *    The coordinate directions are:
  95.  *        x_shift: from left to right
  96.  *        y_shift: from top to bottom.
  97.  */
  98.  
  99. static struct char_table standard_table [110] = {
  100.     '\0',    0,    0,    0,    /* null */
  101.     'h',    0,    0,    0,    /* h */
  102.     't',    0,    0,    0,    /* t */
  103.     'n',    0,    0,    0,    /* n */
  104.     'm',    0,    0,    0,    /* m */
  105.     'l',    0,    0,    0,    /* l */
  106.     'i',    0,    0,    0,    /* i */
  107.     'z',    0,    0,    0,    /* z */
  108.     's',    0,    0,    0,    /* s */
  109.     'd',    0,    0,    0,    /* d */
  110.     'b',    0,    0,    0,    /* b */
  111.     'x',    0,    0,    0,    /* x */
  112.     'f',    0,    0,    0,    /* f */
  113.     'j',    0,    0,    0,    /* j */
  114.     'u',    0,    0,    0,    /* u */
  115.     'k',    0,    0,    0,    /* k */
  116.     '\0',    0,    0,    0,    /* null */
  117.     'p',    0,    0,    0,    /* p */
  118.     'v',    1,    0,    0,    /* 3/4 em dash */
  119.     ';',    0,    0,    0,    /* ; */
  120.     '\0',    0,    0,    0,    /* null */
  121.     'a',    0,    0,    0,    /* a */
  122.     '_',    0,    0,    -85,    /* rule */
  123.     'c',    0,    0,    0,    /* c */
  124.     '`',    0,    0,    0,    /* open quote */
  125.     'e',    0,    0,    0,    /* e */
  126.     '\'',    0,    0,    0,    /* close quote */
  127.     'o',    0,    0,    0,    /* o */
  128.     'w',    1,    0,    0,    /* 1/4 */
  129.     'r',    0,    0,    0,    /* r */
  130.     'x',    1,    0,    0,    /* 1/2 */
  131.     'v',    0,    0,    0,    /* v */
  132.     '-',    0,    0,    0,    /* hyphen */
  133.     'w',    0,    0,    0,    /* w */
  134.     'q',    0,    0,    0,    /* q */
  135.     '/',    0,    0,    0,    /* / */
  136.     '.',    0,    0,    0,    /* . */
  137.     'g',    0,    0,    0,    /* g */
  138.     '\0',    0,    0,    0,    /* 3/4 */
  139.     ',',    0,    0,    0,    /* , */
  140.     '&',    0,    0,    0,    /* & */
  141.     'y',    0,    0,    0,    /* y */
  142.     '\0',    0,    0,    0,    /* null */
  143.     '%',    0,    0,    0,    /* % */
  144.     '\0',    0,    0,    0,    /* null */
  145.     'Q',    0,    0,    0,    /* Q */
  146.     'T',    0,    0,    0,    /* T */
  147.     'O',    0,    0,    0,    /* O */
  148.     'H',    0,    0,    0,    /* H */
  149.     'N',    0,    0,    0,    /* N */
  150.     'M',    0,    0,    0,    /* M */
  151.     'L',    0,    0,    0,    /* L */
  152.     'R',    0,    0,    0,    /* R */
  153.     'G',    0,    0,    0,    /* G */
  154.     'I',    0,    0,    0,    /* I */
  155.     'P',    0,    0,    0,    /* P */
  156.     'C',    0,    0,    0,    /* C */
  157.     'V',    0,    0,    0,    /* V */
  158.     'E',    0,    0,    0,    /* E */
  159.     'Z',    0,    0,    0,    /* Z */
  160.     'D',    0,    0,    0,    /* D */
  161.     'B',    0,    0,    0,    /* B */
  162.     'S',    0,    0,    0,    /* S */
  163.     'Y',    0,    0,    0,    /* Y */
  164.     '\0',    0,    0,    0,    /* null */
  165.     'F',    0,    0,    0,    /* F */
  166.     'X',    0,    0,    0,    /* X */
  167.     'A',    0,    0,    0,    /* A */
  168.     'W',    0,    0,    0,    /* W */
  169.     'J',    0,    0,    0,    /* J */
  170.     'U',    0,    0,    0,    /* U */
  171.     'K',    0,    0,    0,    /* K */
  172.     '0',    0,    0,    0,    /* 0 */
  173.     '1',    0,    0,    0,    /* 1 */
  174.     '2',    0,    0,    0,    /* 2 */
  175.     '3',    0,    0,    0,    /* 3 */
  176.     '4',    0,    0,    0,    /* 4 */
  177.     '5',    0,    0,    0,    /* 5 */
  178.     '6',    0,    0,    0,    /* 6 */
  179.     '7',    0,    0,    0,    /* 7 */
  180.     '8',    0,    0,    0,    /* 8 */
  181.     '9',    0,    0,    0,    /* 9 */
  182.     '*',    0,    0,    0,    /* * */
  183.     '-',    0,    0,    0,    /* curent font minus */
  184.     '\0',    0,    0,    0,    /* fi */
  185.     '\0',    0,    0,    0,    /* fl */
  186.     '\0',    0,    0,    0,    /* ff */
  187.     '?',    1,    0,    0,    /* cent sign */
  188.     '\0',    0,    0,    0,    /* ffl */
  189.     '\0',    0,    0,    0,    /* ffi */
  190.     '(',    0,    0,    0,    /* ( */
  191.     ')',    0,    0,    0,    /* ) */
  192.     '[',    0,    0,    0,    /* [ */
  193.     ']',    0,    0,    0,    /* ] */
  194.     '3',    1,    0,    0,    /* degree */
  195.     'N',    3,    0,    0,    /* dagger */
  196.     '=',    0,    0,    0,    /* = */
  197.     ',',    5,    0,    0,    /* registered */
  198.     ':',    0,    0,    0,    /* : */
  199.     '+',    0,    0,    0,    /* + */
  200.     '\0',    0,    0,    0,    /* null */
  201.     '!',    0,    0,    0,    /* ! */
  202.     'K',    3,    0,    0,    /* bullet */
  203.     '?',    0,    0,    0,    /* ? */
  204.     '\'',    2,    0,    0,    /* foot mark */
  205.     '|',    0,    0,    0,    /* | */
  206.     '\0',    0,    0,    0,    /* null */
  207.     '-',    5,    0,    0,    /* copyright */
  208.     'l',    5,    0,    0,    /* square */
  209.     '$',    0,    0,    0    /* $ */
  210. };
  211.  
  212. static struct char_table special_table [110] = {
  213.     '\0',    2,    0,    0,    /* null */
  214.     'w',    2,    0,    0,    /* psi */
  215.     'h',    2,    0,    0,    /* theta */
  216.     'm',    2,    0,    0,    /* nu */
  217.     'l',    2,    0,    0,    /* mu */
  218.     'k',    2,    0,    0,    /* lambda */
  219.     'i',    2,    0,    0,    /* iota */
  220.     'f',    2,    0,    0,    /* zeta */
  221.     'r',    2,    0,    0,    /* sigma */
  222.     'd',    2,    0,    0,    /* delta */
  223.     'b',    2,    0,    0,    /* beta */
  224.     'n',    2,    0,    0,    /* xi */
  225.     'g',    2,    0,    0,    /* eta */
  226.     'u',    2,    0,    0,    /* phi */
  227.     't',    2,    0,    0,    /* upsilon */
  228.     'j',    2,    0,    0,    /* kappa */
  229.     '\0',    2,    0,    0,    /* null */
  230.     'p',    2,    0,    0,    /* pi */
  231.     '@',    0,    0,    0,    /* @ */
  232.     '#',    3,    0,    0,    /* down arrow */
  233.     '\0',    2,    0,    0,    /* null */
  234.     'a',    2,    0,    0,    /* alpha */
  235.     '|',    0,    0,    0,    /* or */
  236.     'v',    2,    0,    0,    /* chi */
  237.     '"',    0,    0,    0,    /* " */
  238.     'e',    2,    0,    0,    /* epsilon */
  239.     '=',    2,    0,    0,    /* math equals */
  240.     'o',    2,    0,    0,    /* omicron */
  241.     '$',    3,    0,    0,    /* left arrow */
  242.     'q',    2,    0,    0,    /* rho */
  243.     '!',    3,    0,    0,    /* up arrow */
  244.     's',    2,    0,    0,    /* tau */
  245.     '_',    0,    0,    0,    /* underrule */
  246.     '\\',    0,    0,    0,    /* \ */
  247.     'W',    2,    0,    0,    /* Psi */
  248.     'H',    5,    0,    0,    /* bell system sign */
  249.     '$',    2,    0,    0,    /* infinity */
  250.     'c',    2,    0,    0,    /* gamma */
  251.     '?',    3,    0,    0,    /* improper superset */
  252.     '&',    2,    0,    0,    /* proportional to */
  253.     '&',    3,    0,    0,    /* right hand */
  254.     'x',    2,    0,    0,    /* omega */
  255.     '\0',    2,    0,    0,    /* null */
  256.     'Y',    2,    0,    0,    /* gradient */
  257.     '\0',    2,    0,    0,    /* null */
  258.     'U',    2,    0,    0,    /* Phi */
  259.     'H',    2,    0,    0,    /* Theta */
  260.     'X',    2,    0,    0,    /* Omega */
  261.     '5',    3,    0,    0,    /* cup (union) */
  262.     '0',    3,    0,    0,    /* root en extender */
  263.     '[',    2,    0,    0,    /* terminal sigma */
  264.     'K',    2,    0,    0,    /* Lambda */
  265.     '-',    2,    0,    0,    /* math minus */
  266.     'C',    2,    0,    0,    /* Gamma */
  267.     'U',    3,    0,    0,    /* integral sign */
  268.     'P',    2,    0,    0,    /* Pi */
  269.     ':',    3,    0,    0,    /* subset of */
  270.     ';',    3,    0,    0,    /* superset of */
  271.     '~',    0,    0,    0,    /* approximates */
  272.     'Z',    2,    0,    0,    /* partial derivative */
  273.     'D',    2,    0,    0,    /* Delta */
  274.     '!',    2,    0,    0,    /* square root */
  275.     'R',    2,    0,    0,    /* Sigma */
  276.     '?',    2,    0,    0,    /* approx = */
  277.     '\0',    2,    0,    0,    /* null */
  278.     '>',    0,    0,    0,    /* > */
  279.     'N',    2,    0,    0,    /* Xi */
  280.     '<',    0,    0,    0,    /* < */
  281.     '/',    0,    0,    0,    /* slash (matching backslash) */
  282.     '6',    3,    0,    0,    /* cap (intersection) */
  283.     'T',    2,    0,    0,    /* Upsilon */
  284.     'H',    3,    0,    0,    /* not */
  285.     'p',    3,    0,    0,    /* right ceiling */
  286.     'b',    3,    0,    0,    /* left top */
  287.     'v',    3,    0,    0,    /* bold vertical (used with floor...) */
  288.     'c',    3,    0,    0,    /* left center of big curly bracket */
  289.     'd',    3,    0,    0,    /* left bottom */
  290.     'r',    3,    0,    0,    /* right top */
  291.     's',    3,    0,    0,    /* right center of big curly bracket */
  292.     't',    3,    0,    0,    /* right bottom */
  293.     'q',    3,    0,    0,    /* right floor */
  294.     'a',    3,    0,    0,    /* left floor */
  295.     '`',    3,    0,    0,    /* left ceiling */
  296.     '*',    2,    0,    0,    /* multiply */
  297.     '%',    2,    0,    0,    /* divide */
  298.     '~',    3,    0,    0,    /* plus-minus */
  299.     '\\',    2,    0,    0,    /* <= */
  300.     '^',    2,    0,    0,    /* >= */
  301.     '}',    2,    0,    0,    /* identically equal */
  302.     ']',    2,    0,    0,    /* not equal */
  303.     '{',    0,    0,    0,    /* { */
  304.     '}',    0,    0,    0,    /* } */
  305.     '(',    1,    0,    0,    /* acute accent */
  306.     ')',    1,    0,    0,    /* grave accent */
  307.     '*',    1,    0,    0,    /* ^ */
  308.     '#',    0,    0,    0,    /* # */
  309.     '(',    3,    0,    0,    /* left hand */
  310.     '7',    3,    0,    0,    /* member of */
  311.     ',',    1,    0,    0,    /* ~ */
  312.     'X',    3,    0,    0,    /* empty set */
  313.     '\0',    2,    0,    0,    /* null */
  314.     'O',    3,    0,    0,    /* double dagger */
  315.     'v',    3,    0,    0,    /* box vertical rule */
  316.     '*',    0,    0,    0,    /* math star */
  317.     '>',    3,    0,    0,    /* improper subset */
  318.     'M',    3,    0,    0,    /* circle */
  319.     '\0',    2,    0,    0,    /* null */
  320.     '+',    2,    0,    0,    /* math plus */
  321.     '"',    3,    0,    0,    /* right arrow */
  322.     '=',    1,    0,    0    /* section */
  323. };
  324.  
  325. main (argc, argv)
  326. int argc;
  327. char **argv;
  328. {
  329.     prog_name = *argv;
  330.  
  331.     printf (INIT);
  332.     read_cat ();
  333.     printf (EXIT);
  334. }
  335.  
  336. /*
  337.  *    Read end interpret CAT codes
  338.  */
  339.  read_cat ()
  340.  {
  341.     register int c;
  342.  
  343.     while ((c = getchar ()) != EOF) {
  344.         if (c & 0200)
  345.             escape ((~c) & 0177);
  346.         else if (c < 0100)
  347.             flash (c);
  348.         else if ((c & 0340) == 0140)
  349.             lead ((~c) & 037);
  350.         else if ((c & 0360) == 0120)
  351.             change_point_size (c & 017);
  352.         else if ((c & 0360) == 0100)
  353.             control (c & 017);
  354.         else
  355.             fprintf (stderr, "%s: Illegal CAT code: 0%o\n", prog_name, c);
  356.     }
  357. }
  358.  
  359. /*
  360.  *    Horizontal motion
  361.  */
  362. escape (c)
  363. int c;
  364. {
  365.     if (escape_backward)
  366.         cat_col -= c;
  367.     else
  368.         cat_col += c;
  369. }
  370.  
  371. /*
  372.  *    Print character
  373.  */
  374. flash (c)
  375. int c;
  376. {
  377.     if (upper_font)
  378.         c += 64;
  379.  
  380. #ifdef DEBUG
  381.     fprintf (stderr, "Flash char %d on font %d, ", c, cat_font);
  382. #endif
  383.  
  384.     if (cat_font <= 7)
  385.         hp_print_char (standard_table [c]);
  386.     else
  387.         hp_print_char (special_table [c]);
  388.     
  389.     page_not_blank = 1;
  390. }
  391.  
  392. /*
  393.  *    Vertical motion
  394.  */
  395. lead (c)
  396. int c;
  397. {
  398.     if (lead_magnification)
  399.         c <<= 6;
  400.     lead_magnification = 0;
  401.  
  402.     c *= 3;
  403.  
  404.     if (lead_backward)
  405.         cat_row -= c;
  406.     else
  407.         cat_row += c;
  408.  
  409.     if (cat_row >= LINES) {
  410.         hp_form_feed ();
  411.         cat_row -= LINES;
  412.     }
  413. }
  414.  
  415. /*
  416.  *    Interpret change-point-size code
  417.  */
  418. change_point_size (c)
  419. int c;
  420. {
  421.     static int c_last = 2;
  422.     static char point_size_table [15] =
  423.         {7, 8, 10, 11, 12, 14, 18, 9, 6, 16, 20, 22, 24, 28, 36};
  424.  
  425.     /* Adjust escape */
  426.  
  427.     if (c_last <= 8 && c > 8)        /* Single to double */
  428.         cat_col -= 55;
  429.     else if (c_last > 8 && c <= 8)        /* Double to single */
  430.         cat_col += 55;
  431.     c_last = c;
  432.     
  433.     /* Interpret new point size */
  434.  
  435.     if (c >= 0 && c <= 016)
  436.         cat_ps = point_size_table [c];
  437.     else
  438.         fprintf (stderr, "%s: Illegal CAT point size: 0%o\n", prog_name, c);
  439.  
  440.     if (hp_ps != cat_ps)
  441.         hp_change_point_size ();
  442.  
  443. #ifdef DEBUG
  444.     fprintf (stderr, "New point_size %d\n", cat_ps);
  445. #endif
  446. }
  447.  
  448. /*
  449.  *    CAT control codes: init and font changes
  450.  */
  451. control (c)
  452. int c;
  453. {
  454.     switch (c) {
  455.     case 0:                /* Initialize */
  456.         upper_rail = 0;
  457.         upper_mag = 0;
  458.         tilt_up = 0;
  459.         upper_font = 0;
  460.         escape_backward = 0;
  461.         lead_backward = 0;
  462.         lead_magnification = 0;
  463.         break;
  464.     case 01:            /* Font change */
  465.         upper_rail = 0;
  466.         break;
  467.     case 02:            /* Font change */
  468.         upper_rail = 1;
  469.         break;
  470.     case 03:            /* Font change */
  471.         upper_mag = 1;
  472.         break;
  473.     case 04:            /* Font change */
  474.         upper_mag = 0;
  475.         break;
  476.     case 05:            /* Change font half */
  477.         upper_font = 0;
  478.         break;
  479.     case 06:            /* Change font half */
  480.         upper_font = 1;
  481.         break;
  482.     case 07:            /* Change horizontal direction */
  483.         escape_backward = 0;
  484.         break;
  485.     case 010:            /* Change horizontal direction */
  486.         escape_backward = 1;
  487.         break;
  488.     case 011:            /* Stop code */
  489.         break;
  490.     case 012:            /* Change vertical direction */
  491.         lead_backward = 0;
  492.         break;
  493.     case 014:            /* Change vertical direction */
  494.         lead_backward = 1;
  495.         break;
  496. #ifdef BERKELEY_HACK
  497.     case 016:            /* Magnify next lead 64 times */
  498.         lead_magnification = 1;
  499.         break;
  500. #else
  501.     case 016:            /* Font change */
  502.         tilt_up = 1;
  503.         break;
  504.     case 017:            /* Font change */
  505.         tilt_up = 0;
  506.         break;
  507. #endif
  508.     default:
  509.         fprintf (stderr, "%s: Illegal CAT control code: 0%o\n", prog_name, c);
  510.         break;
  511.     }
  512.  
  513.     cat_font = 2 - tilt_up + (upper_rail << 1) + (upper_mag << 2);
  514.  
  515.     if (hp_font != cat_font)
  516.         hp_change_font ();
  517.  
  518. #ifdef DEBUG
  519.     fprintf (stderr, "Control code: 0%o\n", c);
  520. #endif
  521. }
  522.  
  523. hp_print_char (c)
  524. struct char_table c;
  525. {
  526.     int x, y;
  527.  
  528.     if (hp_char_set != c.char_set)
  529.         hp_change_char_set (c.char_set);
  530.  
  531.     /* Convert to LaserJet coordinates (50 is for rounding) */
  532.  
  533.     if (c.x_shift < 0)
  534.         x = SCALE_X(cat_col) + (c.x_shift * hp_ps - 50) / 100;
  535.     else
  536.         x = SCALE_X(cat_col) + (c.x_shift * hp_ps + 50) / 100;
  537.     if (c.y_shift < 0)
  538.         y = SCALE_Y(cat_row) + (c.y_shift * hp_ps - 50) / 100;
  539.     else
  540.         y = SCALE_Y(cat_row) + (c.y_shift * hp_ps + 50) / 100;
  541.  
  542.     /* Position LaserJet (cannot trust hp_col -- see below) */
  543.  
  544.     if (hp_row != y)
  545.         printf (XY_POS(x,y));
  546.     else
  547.         printf (X_POS(x));
  548.  
  549.     putchar (c.c);
  550.  
  551.     hp_col = x;            /* Wrong by a character width */
  552.     hp_row = y;
  553.  
  554. #ifdef DEBUG
  555.     fprintf (stderr, "col=%d, row=%d, ", x, y);
  556.     fprintf (stderr, "hp_c = %c(%d), c_set=%d\n", c.c, c.c, c.char_set);
  557. #endif
  558. }
  559.  
  560. hp_change_char_set (char_set)
  561. char char_set;
  562. {
  563.     switch (char_set) {
  564.     case 0:                /* USASCII */
  565.         printf ("\033(0U");
  566.         break;
  567.     case 1:                /* Roman Extension */
  568.         printf ("\033(0E");
  569.         break;
  570.     case 2:                /* Math 8a */
  571.         printf ("\033(0Q");
  572.         break;
  573.     case 3:                /* Math 8b */
  574.         printf ("\033(1Q");
  575.         break;
  576.     case 4:                /* Math 7 */
  577.         printf ("\033(0A");
  578.         break;
  579.     case 5:                /* PiFonta */
  580.         printf ("\033(2Q");
  581.         break;
  582.     default:
  583.         fprintf (stderr, "%s: Illegal HP character set: %d\n", prog_name, char_set);
  584.         break;
  585.     }
  586.     hp_char_set = char_set;
  587. }
  588.  
  589. hp_form_feed ()
  590. {
  591.     if (page_not_blank)
  592.         printf (FORM_FEED);
  593.  
  594.     page_not_blank = 0;
  595. }
  596.  
  597. hp_change_point_size ()
  598. {
  599.  
  600. /*
  601.  *    Note that no checking is done to see if the asked for
  602.  *    point size is available.
  603.  */
  604.  
  605.     printf (POINT_SIZE(cat_ps));
  606.     
  607.     hp_ps = cat_ps;
  608. }
  609.  
  610. hp_change_font ()
  611. {
  612.     switch (cat_font) {
  613.     case 1:                /* Standard */
  614.     case 2:
  615.     case 7:
  616.     case 8:
  617.         printf (BOLD_OFF);
  618.         printf (ITALIC_OFF);
  619.         break;
  620.     case 3:                /* Italic */
  621.     case 4:
  622.         printf (BOLD_OFF);
  623.         printf (ITALIC_ON);
  624.         break;
  625.     case 5:                /* Bold */
  626.     case 6:
  627.         printf (BOLD_ON);
  628.         printf (ITALIC_OFF);
  629.         break;
  630.     default:
  631.         fprintf (stderr, "%s: Illegal HP font: %d\n", prog_name, cat_font);
  632.         break;
  633.     }
  634.     
  635.     hp_font = cat_font;
  636. }
  637.