home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / psroff / part05 / dt.c next >
Encoding:
C/C++ Source or Header  |  1989-10-17  |  16.0 KB  |  531 lines

  1. /*    Copyright 1985, 1986, 1987, 1988 Chris Lewis
  2.         All Rights Reserved
  3.  
  4.     Permission to copy and further distribute is freely given provided 
  5.     this copyright notice remains intact and that this software is not 
  6.     sold for profit.
  7.  
  8.     Project:    Generic Troff drivers
  9.     Module:        dt.c
  10.     Author:     Chris Lewis
  11.     Specs:        Ditroff driver
  12.  */
  13.  
  14. #include "defs.h"
  15.  
  16. #ifdef    DT
  17. #include "dt.h"
  18.  
  19. int currentPage = 0;
  20.  
  21. #ifndef    SVR3
  22. #ifndef    lint
  23. static char SCCSid[] = "@(#)dt.c: 1.5 Copyright 89/07/04 16:59:46 Chris Lewis";
  24. #endif
  25. #else
  26. #ident  "@(#)dt.c: 1.5 Copyright 89/07/04 16:59:46 Chris Lewis" /*(SVR3)*/
  27. #endif
  28.  
  29. #define    MAXFONT    50
  30.  
  31. #define    USED    01
  32.  
  33. struct dtFts {
  34.     char *troffName;
  35.     char *ascName;
  36.     int     flags;
  37. } dtFts[MAXFONT+1];
  38.  
  39. struct dtFts *t2dtf[8];
  40.  
  41. struct troff2befont dtStdFont[108] = {
  42.  
  43. /*          +-------------------------------- Troff character number
  44.         |
  45.             |    +--------------------------- U: standard fonts
  46.             |    |                            S: symbol font
  47.             |    |                            D: draw macro
  48.             |    |                            n: new font
  49.             |    |
  50.             |    |  +------------------------ X-shift (scaled by point)
  51.             |    |  |                         Note: positive is right.
  52.             |    |  |
  53.             |    |  |  +--------------------- Y-shift (scaled by point)
  54.             |    |  |  |                      Note: positive is up.
  55.             |    |  |  |
  56.             |    |  |  |  +------------------ Point scale factor
  57.             |    |  |  |  |
  58.             |    |  |  |  |   +-------------- Sequence
  59.             |    |  |  |  |   |
  60.             |    |  |  |  |   |               Printable sequence title
  61.             |    |  |  |  |   |                 |
  62.             |    |  |  |  |   |                 |
  63.             v    v  v  v  v   v                 v                    */
  64.     /*  1*/    {U, 0, 0, 1, "h",        "h"},
  65.     /*  2*/    {U, 0, 0, 1, "t",        "t"},
  66.     /*  3*/    {U, 0, 0, 1, "n",        "n"},
  67.     /*  4*/    {U, 0, 0, 1, "m",        "m"},
  68.     /*  5*/    {U, 0, 0, 1, "l",        "l"},
  69.     /*  6*/    {U, 0, 0, 1, "i",        "i"},
  70.     /*  7*/    {U, 0, 0, 1, "z",        "z"},
  71.     /*  8*/    {U, 0, 0, 1, "s",        "s"},
  72.     /*  9*/    {U, 0, 0, 1, "d",        "d"},
  73.     /* 10*/    {U, 0, 0, 1, "b",        "b"},
  74.     /* 11*/    {U, 0, 0, 1, "x",        "x"},
  75.     /* 12*/    {U, 0, 0, 1, "f",        "f"},
  76.     /* 13*/    {U, 0, 0, 1, "j",        "j"},
  77.     /* 14*/    {U, 0, 0, 1, "u",        "u"},
  78.     /* 15*/    {U, 0, 0, 1, "k",        "k"},
  79.     /* 16*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  80.     /* 17*/    {U, 0, 0, 1, "p",        "p"},
  81.     /* 18*/    {U, 0, 0, 1, "em",        "3/4 em"},
  82.     /* 19*/    {U, 0, 0, 1, ";",        ";"},
  83.     /* 20*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  84.     /* 21*/    {U, 0, 0, 1, "a",        "a"},
  85.     /* 22*/    {U, 0, 0, 1, "ru",        "horizontal rule"},
  86.     /* 23*/    {U, 0, 0, 1, "c",        "c"},
  87.     /* 24*/    {U, 0, 0, 1, "`",        "` open"},
  88.     /* 25*/    {U, 0, 0, 1, "e",        "e"},
  89.     /* 26*/    {U, 0, 0, 1, "'",        "' close"},
  90.     /* 27*/    {U, 0, 0, 1, "o",        "o"},
  91.     /* 28*/    {U, 0, 0, 1, "14",        "1/4"},
  92.     /* 29*/    {U, 0, 0, 1, "r",        "r"},
  93.     /* 30*/    {U, 0, 0, 1, "12",        "1/2"},
  94.     /* 31*/    {U, 0, 0, 1, "v",        "v"},
  95.     /* 32*/    {U, 0, 0, 1, "hy",        "- hyphen"},
  96.     /* 33*/    {U, 0, 0, 1, "w",        "w"},
  97.     /* 34*/    {U, 0, 0, 1, "q",        "q"},
  98.     /* 35*/    {U, 0, 0, 1, "/",        "/"},
  99.     /* 36*/    {U, 0, 0, 1, ".",        "."},
  100.     /* 37*/    {U, 0, 0, 1, "g",        "g"},
  101.     /* 38*/    {U, 0, 0, 1, "34",        "3/4"},
  102.     /* 39*/    {U, 0, 0, 1, ",",        ","},
  103.     /* 40*/    {U, 0, 0, 1, "&",        "&"},
  104.     /* 41*/    {U, 0, 0, 1, "y",        "y"},
  105.     /* 42*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  106.     /* 43*/    {U, 0, 0, 1, "%",        "%"},
  107.     /* 44*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  108.     /* 45*/    {U, 0, 0, 1, "Q",        "Q"},
  109.     /* 46*/    {U, 0, 0, 1, "T",        "T"},
  110.     /* 47*/    {U, 0, 0, 1, "O",        "O"},
  111.     /* 48*/    {U, 0, 0, 1, "H",        "H"},
  112.     /* 49*/    {U, 0, 0, 1, "N",        "N"},
  113.     /* 50*/    {U, 0, 0, 1, "M",        "M"},
  114.     /* 51*/    {U, 0, 0, 1, "L",        "L"},
  115.     /* 52*/    {U, 0, 0, 1, "R",        "R"},
  116.     /* 53*/    {U, 0, 0, 1, "G",        "G"},
  117.     /* 54*/    {U, 0, 0, 1, "I",        "I"},
  118.     /* 55*/    {U, 0, 0, 1, "P",        "P"},
  119.     /* 56*/    {U, 0, 0, 1, "C",        "C"},
  120.     /* 57*/    {U, 0, 0, 1, "V",        "V"},
  121.     /* 58*/    {U, 0, 0, 1, "E",        "E"},
  122.     /* 59*/    {U, 0, 0, 1, "Z",        "Z"},
  123.     /* 60*/    {U, 0, 0, 1, "D",        "D"},
  124.     /* 61*/    {U, 0, 0, 1, "B",        "B"},
  125.     /* 62*/    {U, 0, 0, 1, "S",        "S"},
  126.     /* 63*/    {U, 0, 0, 1, "Y",        "Y"},
  127.     /*from here on are actually code 1-45, upper half of font */
  128.     /* 64*/    {U, 0, 0, 1, "F",        "F"},
  129.     /* 65*/    {U, 0, 0, 1, "X",        "X"},
  130.     /* 66*/    {U, 0, 0, 1, "A",        "A"},
  131.     /* 67*/    {U, 0, 0, 1, "W",        "W"},
  132.     /* 68*/    {U, 0, 0, 1, "J",        "J"},
  133.     /* 69*/    {U, 0, 0, 1, "U",        "U"},
  134.     /* 70*/    {U, 0, 0, 1, "K",        "K"},
  135.     /* 71*/    {U, 0, 0, 1, "0",        "0"},
  136.     /* 72*/    {U, 0, 0, 1, "1",        "1"},
  137.     /* 73*/    {U, 0, 0, 1, "2",        "2"},
  138.     /* 74*/    {U, 0, 0, 1, "3",        "3"},
  139.     /* 75*/    {U, 0, 0, 1, "4",        "4"},
  140.     /* 76*/    {U, 0, 0, 1, "5",        "5"},
  141.     /* 77*/    {U, 0, 0, 1, "6",        "6"},
  142.     /* 78*/    {U, 0, 0, 1, "7",        "7"},
  143.     /* 79*/    {U, 0, 0, 1, "8",        "8"},
  144.     /* 80*/    {U, 0, 0, 1, "9",        "9"},
  145.     /* 81*/    {U, 0, 0, 1, "*",        "*"},
  146.     /* 82*/    {U, 0, 0, 1, "-",        "minus"},
  147.     /* 83*/    {U, 0, 0, 1, "fi",        "fi"},
  148.     /* 84*/    {U, 0, 0, 1, "fl",        "fl"},
  149.     /* 85*/    {U, 0, 0, 1, "ff",        "ff"},
  150.     /* 86*/    {U, 0, 0, 1, "ct",        "cent sign"},
  151.     /* 87*/    {U, 0, 0, 1, "Fl",        "ffl"},
  152.     /* 88*/    {U, 0, 0, 1, "Fi",        "ffi"},
  153.     /* 89*/    {U, 0, 0, 1, "(",        "("},
  154.     /* 90*/    {U, 0, 0, 1, ")",        ")"},
  155.     /* 91*/    {U, 0, 0, 1, "[",        "["},
  156.     /* 92*/    {U, 0, 0, 1, "]",        "]"},
  157.     /* 93*/    {U, 0, 0, 1, "de",        "degree"},
  158.     /* 94*/    {U, 0, 0, 1, "dg",        "dagger"},
  159.     /* 95*/    {U, 0, 0, 1, "=",        "="},
  160.     /* 96*/    {U, 0, 0, 1, "rg",        "registered"},
  161.     /* 97*/    {U, 0, 0, 1, ":",        ":"},
  162.     /* 98*/    {U, 0, 0, 1, "+",        "+"},
  163.     /* 99*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  164.     /*100*/    {U, 0, 0, 1, "!",        "!"},
  165.     /*101*/    {U, 0, 0, 1, "bu",        "bullet"},
  166.     /*102*/    {U, 0, 0, 1, "?",        "?"},
  167.     /*103*/    {U, 0, 0, 1, "fm",        "foot mark (minute)"},
  168.     /*104*/    {U, 0, 0, 1, "|",        "|"},
  169.     /*105*/    {U, 0, 0, 1, NOCODE,        "unassigned"},
  170.     /*106*/    {U, 0, 0, 1, "co",        "copyright"},
  171.     /*107*/    {U, 0, 0, 1, "sq",        "square"},
  172.     /*108*/    {U, 0, 0, 1, "$",        "$"}
  173. };
  174.  
  175. struct troff2befont dtSymFont[] = {
  176. /*          +-------------------------------- Troff character number
  177.         |
  178.             |    +--------------------------- U: standard fonts
  179.             |    |                            S: symbol font
  180.             |    |                            D: draw macro
  181.             |    |
  182.             |    |  +------------------------ X-shift (scaled by point)
  183.             |    |  |                         Note: positive is right.
  184.             |    |  |
  185.             |    |  |  +--------------------- Y-shift (scaled by point)
  186.             |    |  |  |                      Note: positive is up.
  187.             |    |  |  |
  188.             |    |  |  |  +------------------ Point scale factor
  189.             |    |  |  |  |
  190.             |    |  |  |  |   +-------------- Sequence
  191.             |    |  |  |  |   |
  192.             |    |  |  |  |   |               Printable sequence title
  193.             |    |  |  |  |   |                 |
  194.             |    |  |  |  |   |                 |
  195.             v    v  v  v  v   v                 v                    */
  196.     /*  1*/    {S, 0, 0, 1, "*q",        "psi"},
  197.     /*  2*/    {S, 0, 0, 1, "*h",        "theta"},
  198.     /*  3*/    {S, 0, 0, 1, "*n",        "nu"},
  199.     /*  4*/    {S, 0, 0, 1, "*m",        "mu"},
  200.     /*  5*/    {S, 0, 0, 1, "*l",        "lambda"},
  201.     /*  6*/    {S, 0, 0, 1, "*i",        "iota"},
  202.     /*  7*/    {S, 0, 0, 1, "*z",        "zeta"},
  203.     /*  8*/    {S, 0, 0, 1, "*s",        "sigma"},
  204.     /*  9*/    {S, 0, 0, 1, "*d",        "delta"},
  205.     /* 10*/    {S, 0, 0, 1, "*b",        "beta"},
  206.     /* 11*/    {S, 0, 0, 1, "*c",        "xi"},
  207.     /* 12*/    {S, 0, 0, 1, "*y",        "eta"},
  208.     /* 13*/    {S, 0, 0, 1, "*f",        "phi"},
  209.     /* 14*/    {S, 0, 0, 1, "*u",        "upsilon"},
  210.     /* 15*/    {S, 0, 0, 1, "*k",        "kappa"},
  211.     /* 16*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  212.     /* 17*/    {S, 0, 0, 1, "*p",        "pi"},
  213.     /* 18*/    {S, 0, 0, 1, "@",        "@"},
  214.     /* 19*/    {S, 0, 0, 1, "da",        "down arrow"},
  215.     /* 20*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  216.     /* 21*/    {S, 0, 0, 1, "*a",        "alpha"},
  217.     /* 22*/    {S, 0, 0, 1, "or",        "or (was star)"},
  218.     /* 23*/    {S, 0, 0, 1, "*x",        "chi"},
  219.     /* 24*/    {U, 0, 0, 1, "\"",        "double quote"},
  220.     /* 25*/    {S, 0, 0, 1, "*e",        "epsilon"},
  221.     /* 26*/    {S, 0, 0, 1, "eq",        "equation equal"},
  222.     /* 27*/    {S, 0, 0, 1, "*o",        "omicron"},
  223.     /* 28*/    {S, 0, 0, 1, "<-",        "left arrow"},
  224.     /* 29*/    {S, 0, 0, 1, "*r",        "rho"},
  225.     /* 30*/    {S, 0, 0, 1, "ua",        "up arrow"},
  226.     /* 31*/    {S, 0, 0, 1, "*t",        "tau"},
  227.     /* 32*/    {S, 0, 0, 1, "ul",        "underline"},
  228.     /* 33*/    {U, 0, 0, 1, "\\",        "back slash"},
  229.     /* 34*/    {S, 0, 0, 1, "*Q",        "Psi"},
  230.     /* 35*/    {S, 0, 0, 1, "?",        "bell system sign"},
  231.     /* 36*/    {S, 0, 0, 1, "if",        "infinity"},
  232.     /* 37*/    {S, 0, 0, 1, "*g",        "gamma"},
  233.     /* 38*/    {S, 0, 0, 1, "ip",        "improper superset"},
  234.     /* 39*/    {S, 0, 0, 1, "pt",        "proportional to"},
  235.     /* 40*/    {S, 0, 0, 1, "rh",        "right hand"},
  236.     /* 41*/    {S, 0, 0, 1, "*w",        "omega"},
  237.     /* 42*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  238.     /* 43*/    {S, 0, 0, 1, "gr",        "gradient"},
  239.     /* 44*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  240.     /* 45*/    {S, 0, 0, 1, "*F",        "Phi"},
  241.     /* 46*/    {S, 0, 0, 1, "*H",        "Theta"},
  242.     /* 47*/    {S, 0, 0, 1, "*W",        "Omega"},
  243.     /* 48*/    {S, 0, 0, 1, "cu",        "union"},
  244.     /* 49*/    {S, 0, 0, 1, "rn",        "root en"},
  245.     /* 50*/    {S, 0, 0, 1, "ts",        "terminal sigma (was root em)"},
  246.     /* 51*/    {S, 0, 0, 1, "*L",        "Lambda"},
  247.     /* 52*/    {S, 0, 0, 1, "mi",        "equation minus"},
  248.     /* 53*/    {S, 0, 0, 1, "*G",        "Gamma"},
  249.     /* 54*/    {S, 0, 0, 1, "is",        "integral sign"},
  250.     /* 55*/    {S, 0, 0, 1, "*P",        "Pi"},
  251.     /* 56*/    {S, 0, 0, 1, "sb",        "subset of"},
  252.     /* 57*/    {S, 0, 0, 1, "sp",        "superset of"},
  253.     /* 58*/    {S, 0, 0, 1, "ap",        "approximates"},
  254.     /* 59*/    {S, 0, 0, 1, "pd",        "partial derivative"},
  255.     /* 60*/    {S, 0, 0, 1, "*D",        "Delta"},
  256.     /* 61*/    {S, 0, 0, 1, "sr",        "square root"},
  257.     /* 62*/    {S, 0, 0, 1, "*S",        "Sigma"},
  258.     /* 63*/    {S, 0, 0, 1, "~=",        "approx ="},
  259.     /* 64*/    {S, 0, 0, 1, ">",        ">"},
  260.     /* 65*/    {S, 0, 0, 1, "*C",        "Xi"},
  261.     /* 66*/    {S, 0, 0, 1, "<",        "<"},
  262.     /* 67*/    {S, 0, 0, 1, "/",        "slash"},
  263.     /* 68*/    {S, 0, 0, 1, "ca",        "intersect"},
  264.     /* 69*/    {S, 0, 0, 1, "*U",        "Upsilon"},
  265.     /* 70*/    {S, 0, 0, 1, "no",        "logical not"},
  266.     /* 71*/    {S, 0, 0, 1, "rc",        "right ceiling"},
  267.     /* 72*/    {S, 0, 0, 1, "lt",        "left top brace"},
  268.     /* 73*/    {S, 0, 0, 1, "bv",        "bold vertical"},
  269.     /* 74*/    {S, 0, 0, 1, "lk",        "left ctr brace"},
  270.     /* 75*/    {S, 0, 0, 1, "lb",        "left bot brace"},
  271.     /* 76*/    {S, 0, 0, 1, "rt",        "right top brace"},
  272.     /* 77*/    {S, 0, 0, 1, "rk",        "right ctr brace"},
  273.     /* 78*/    {S, 0, 0, 1, "rb",        "right bot brace"},
  274.     /* 79*/    {S, 0, 0, 1, "rf",        "right floor"},
  275.     /* 80*/    {S, 0, 0, 1, "lf",        "left floor"},
  276.     /* 81*/    {S, 0, 0, 1, "lc",        "left ceiling"},
  277.     /* 82*/    {S, 0, 0, 1, "mu",        "multiply"},
  278.     /* 83*/    {S, 0, 0, 1, "di",        "divide"},
  279.     /* 84*/    {S, 0, 0, 1, "+-",        "plus-minus"},
  280.     /* 85*/    {S, 0, 0, 1, "<=",        "<="},
  281.     /* 86*/    {S, 0, 0, 1, ">=",        ">="},
  282.     /* 87*/    {S, 0, 0, 1, "==",        "identically equal"},
  283.     /* 88*/    {S, 0, 0, 1, "!=",        "not equal"},
  284.     /* 89*/    {S, 0, 0, 1, "{",        "{"},
  285.     /* 90*/    {S, 0, 0, 1, "}",        "}"},
  286.     /* 91*/    {U, 0, 0, 1, "aa",        "acute accent"},
  287.     /* 92*/    {U, 0, 0, 1, "ga",        "grave accent"},
  288.     /* 93*/    {S, 0, 0, 1, "^",        "^"},
  289.     /* 94*/    {S, 0, 0, 1, "#",        "#"},
  290.     /* 95*/    {S, 0, 0, 1, "lh",        "left hand"},
  291.     /* 96*/    {S, 0, 0, 1, "mo",        "member of"},
  292.     /* 97*/    {U, 0, 0, 1, "~",        "~"},
  293.     /* 98*/    {S, 0, 0, 1, "es",        "empty set"},
  294.     /* 99*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  295.     /*100*/    {U, 0, 0, 1, "dd",        "dbl dagger"},
  296.     /*101*/    {S, 0, 0, 1, "br",        "box rule (was parallel sign)"},
  297.     /*102*/    {S, 0, 0, 1, "**",        "math * "},
  298.     /*103*/    {S, 0, 0, 1, "ib",        "improper subset"},
  299.     /*104*/    {S, 0, 0, 1, "ci",        "circle"},
  300.     /*105*/    {S, 0, 0, 1, NOCODE,        "unassigned"},
  301.     /*106*/    {S, 0, 0, 1, "pl",        "equation plus"},
  302.     /*107*/    {S, 0, 0, 1, "->",        "right arrow"},
  303.     /*108*/    {U, 0, 0, 1, "sc",        "section"}
  304. };
  305.  
  306. dtPage() {
  307.     pagePending = 1;
  308. }
  309.  
  310. static
  311. doPageStart(e) {
  312.     currentPage++;
  313.     pagePending = 0;
  314.     printf("p%d\n", currentPage);
  315. }
  316.  
  317. static int lastFont = (-1), lastPoints = (-1);
  318.  
  319. dtSetFont(font, points)
  320. int font, points; {
  321.     if (lastPoints != points || font != lastFont) {
  322.     if (!(dtFts[font].flags)&USED)
  323.         printf("x font %d %s\n", font+1, dtFts[font].troffName);
  324.     dtFts[font].flags |= USED;
  325.     printf("f%d\n", font+1);
  326.     printf("s%d\n", points);
  327.     lastPoints = points;
  328.     lastFont = font;
  329.     }
  330. }
  331.  
  332. dtChar(x, y, font, points, troffChar) 
  333. int x, y, font, points, troffChar; {
  334.     static double lasty = (-1);
  335.     register double nx = TROFF2DTX(x), ny = TROFF2DTY(y);
  336.     register struct troff2befont *rp;
  337.     register char *sequence = "a";
  338.     if (pagePending) {
  339.         lasty = lastFont = lastPoints = (-1);
  340.         doPageStart();
  341.     }
  342.  
  343.     DEBUGPRINTF("x,y=%d,%d; font=%d, points=%d, tc=%d\n",
  344.         x, y, font, points, troffChar);
  345.  
  346.     if (font == 3) {
  347.         rp = &be->besymfont[troffChar];
  348.     } else {
  349.         rp = &be->bestdfont[troffChar];
  350.     }
  351.  
  352.     switch(rp->t2b_font) {
  353.         /* Only fonts with "U" are subject to font translation */
  354.         case U: 
  355.         if (font == 3)
  356.             font = 0;    /* Special chars are Courier */
  357.         else {
  358.             DEBUGPRINTF("dtSetChar %d->%s (%s)\n", font, 
  359.             t2dtf[font]->troffName,
  360.             t2dtf[font]->ascName);
  361.             font = t2dtf[font] - dtFts;
  362.         }
  363.         break;
  364.         case S: 
  365.         font = 3;
  366.         break;
  367.         case D:
  368.         break;
  369.         default:
  370.         /* Typically used when the main fonts don't have the
  371.            character desired.  Eg: right-hand is in the
  372.            ZapfDingbats font */
  373.         font = rp->t2b_font;
  374.         break;
  375.     }
  376.  
  377.     sequence = rp->t2b_charseq;
  378.  
  379.     if (!sequence) {
  380.         fprintf(stderr, "No coding for %d\n", troffChar);
  381.         return;
  382.     }
  383.  
  384.     /*    We're committed now */
  385.  
  386.     points *= rp->t2b_scale;
  387.     nx += points * rp->t2b_xc;
  388.     ny += points * rp->t2b_yc;
  389.     dtSetFont(font, points);
  390. #ifdef    NOTYET
  391.     if (rp->t2b_font == D)
  392.         printf("H%d\nV%d\nc%s\n", (int) nx, (int) ny, sequence);
  393.     else {
  394. #endif
  395.         printf("H%d\n", (int) nx);
  396.         if (lasty != ny) {
  397.         printf("V%d\n", (int) ny);
  398.         lasty = ny;
  399.         }
  400.         if (sequence[1])
  401.         printf("C%s\n", sequence);
  402.         else
  403.         printf("c%s\n", sequence);
  404. #ifdef    NOTYET
  405.     }
  406. #endif
  407. }
  408.  
  409. dtProlog() {
  410.     extern char *getlogin(), *ctime();
  411.     extern char *strchr();
  412.     extern char nodename[];
  413.     extern char *device;
  414.     char buf2[512];
  415.     char buffer[512];
  416.     FILE *library;
  417.     int c;
  418.     long curtime;
  419.  
  420.     currentPage = 0;
  421.     pagePending = 1;
  422.  
  423.     for (c = 0; c < 8; c++)
  424.     t2dtf[c] = &dtFts[c];
  425.  
  426.     sprintf(buf2, "%s.%s", DTFONTS, be->bename);
  427.  
  428.     if ((library = fopen(buf2, "r")) == NULL) {
  429.     sprintf(buffer, "%s/%s", LIBDIR, buf2);
  430.     if ((library = fopen(buffer, "r")) == NULL) {
  431.         fprintf(stderr, "Cannot open PostScript font definitions %s\n",
  432.         buffer);
  433.         exit(1);
  434.     }
  435.     }
  436.  
  437.     loadfontdefs(library);
  438.     fclose(library);
  439.  
  440.     time(&curtime);
  441.     strcpy(buffer, ctime(&curtime));
  442.     *strchr(buffer, '\n') = '\0';
  443.  
  444.     getnodename();
  445.  
  446.     printf("#Title: (stdin)\n");
  447.     printf("#Creator: %s %s %s\n", getlogin(), progname, T2VERSION);
  448.     printf("#CreationDate: %s\n", buffer);
  449.     printf("#For: %s\n", getlogin());
  450.     printf("#Pages: (atend)\n");
  451.     printf("#DocumentFonts: (atend)\n");
  452.     printf("#EndComments\n");
  453.     printf("x T %s\n", device);
  454.     printf("x res %d %d %d\n", DTRESOLUTION, 1, 1);
  455.     printf("x init\n");
  456.  
  457. }
  458.  
  459. dtEpilog() {
  460.     printf("x trailer\n");
  461.     printf("x stop\n");
  462. }
  463.  
  464. dtFontSel(from, to)
  465. char from, *to; {
  466. #ifdef    DEBUG
  467.     register int i;
  468.     register struct dtFts *p;
  469. #endif
  470.     DEBUGPRINTF("dtFontSel: %c -> %s\n", from, to);
  471.     if (from < '1' || from > '8') {
  472.     fprintf(stderr, "Bad arguments to dtFontSel: %c %s\n", from, to);
  473.     return;
  474.     }
  475.  
  476.     for (p = dtFts; p->troffName; p++)
  477.     if (strcmp(p->troffName, to) == 0) {
  478.         t2dtf[from - '1'] = p;
  479.         break;
  480.     }
  481.     if (!p->troffName) {
  482.     fprintf(stderr, "Could not translate font %c (%s)\n", from, to);
  483.     }
  484. #ifdef    DEBUG
  485.     for (i = 0; i < 8; i++)
  486.     DEBUGPRINTF("Font %d->%s\n", i+1, t2dtf[i]->ascName);
  487. #endif
  488. }
  489.  
  490. /*struct troff2befont *
  491. dtGetFontTables(which)
  492. int which; {
  493.     return(which? symbolFont: standardFont);
  494. }*/
  495.  
  496. static
  497. loadfontdefs(f)
  498. FILE *f; {
  499.     struct dtFts *p = dtFts;
  500.     extern char *malloc();
  501.     int flags;
  502.     char rbuf[512], nbuf[512], dtbuf[512];
  503.     while(fgets(rbuf, sizeof(rbuf), f)) {
  504.     if (rbuf[0] == '#')
  505.         continue;
  506.     switch(sscanf(rbuf, "%s%s", nbuf, dtbuf)) {
  507.         default:
  508.         break;
  509.         case 2:
  510.         if (nbuf[0] == '#')
  511.             break;
  512.         if (p - dtFts >= MAXFONT) {
  513.             fprintf(stderr, "Too many font definitions in %s\n",
  514.             be->bename);
  515.             exit(1);
  516.         }
  517.         p->troffName = malloc(strlen(nbuf) + 1);
  518.         strcpy(p->troffName, nbuf);
  519.         p->ascName = malloc(strlen(dtbuf) + 1);
  520.         strcpy(p->ascName, dtbuf);
  521.         p->flags = 0;
  522.         p++;
  523.     }
  524.     }
  525. #ifdef    DEBUG
  526.     for (p = dtFts; p->troffName; p++)
  527.     DEBUGPRINTF("%s -> %s\n", p->troffName, p->ascName);
  528. #endif
  529. }
  530. #endif /* DT */
  531.