home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / utils / rtfprsr / trf_nwid.c < prev    next >
C/C++ Source or Header  |  1995-05-18  |  2KB  |  92 lines

  1. /*
  2.     trf-nwid.c - routine to try to figure out the width of an en
  3.     in the current point size.  This is used by the table writing
  4.     code in an attempt to get cells the right width.
  5.  
  6.     If you're trying to figure out widths for another version of
  7.     troff, run nwidth.trf through it and look at the result.
  8. */
  9.  
  10. # include    <stdio.h>
  11. # include    <sys/types.h>
  12. # include    "rtf.h"
  13. # include    "rtf2troff.h"
  14.  
  15. typedef    struct EnVal    EnVal;
  16.  
  17. struct    EnVal
  18. {
  19.     int    size;
  20.     double    width;
  21. };
  22.  
  23. # define    uXroff    300.0    /* xroff dpi */
  24.  
  25. EnVal    enXroff [] =
  26. {
  27.     3,    9./uXroff,    /* xroff uses 4 */
  28.     4,    9./uXroff,
  29.     5,    11./uXroff,
  30.     6,    13./uXroff,
  31.     7,    16./uXroff,
  32.     8,    18./uXroff,
  33.     9,    20./uXroff,
  34.     10,    22./uXroff,
  35.     11,    25./uXroff,
  36.     12,    27./uXroff,
  37.     13,    29./uXroff,
  38.     14,    31./uXroff,
  39.     15,    34./uXroff,
  40.     16,    36./uXroff,
  41.     17,    36./uXroff,    /* xroff uses 16 */
  42.     18,    40./uXroff,
  43.     19,    40./uXroff,    /* xroff uses 18 */
  44.     20,    45./uXroff,
  45.     22,    45./uXroff,    /* xroff uses 20 */
  46.     24,    54./uXroff,
  47.     26,    54./uXroff,    /* xroff uses 24
  48.     28,    63./uXroff,
  49.     30,    67./uXroff,
  50.     32,    67./uXroff,    /* xroff uses 0?!? Use 30 instead */
  51.     34,    67./uXroff,    /* xroff uses 0?!? Use 30 instead */
  52.     36,    81./uXroff,
  53.     38,    81./uXroff,    /* xroff uses 36 */
  54.     40,    81./uXroff,    /* xroff uses 36
  55.     44,    107./uXroff,    /* xroff uses 48 */
  56.     48,    107./uXroff,
  57.     72,    107./uXroff,    /* xroff uses 48 */
  58.     0,    50./uXroff    /* 0 = end of table; 50 = default size */
  59. };
  60.  
  61.  
  62. static double    EVTabLookup ();
  63.  
  64.  
  65. static double EVTabLookup (tab)
  66. EnVal    tab[];
  67. {
  68. int    ps = ics->fontSize;
  69. EnVal    *p;
  70.  
  71.     for (p = tab; p->size != 0; p++)
  72.     {
  73.         if (p->size >= ps)
  74.             return (p->width);
  75.     }
  76.     return (p->width);    /* use last width as default */
  77. }
  78.  
  79.  
  80. double EnWidth ()
  81. {
  82.     /*
  83.         Our tpscript uses 720 as resolution base, and character
  84.         sizes are 5 times the point size.
  85.     */
  86.     if (tvers == PSTROFF)
  87.         return (ics->fontSize * 5. / 720.);
  88.  
  89.     /* default - covers troff and xroff */
  90.     return (EVTabLookup (enXroff));
  91. }
  92.