summaryrefslogtreecommitdiff
path: root/support/RTF-1_06a1/trf-nwid.c
blob: 0f71c1efb2fb294ba1f7e60aa31956628b6303db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
	trf-nwid.c - routine to try to figure out the width of an en
	in the current point size.  This is used by the table writing
	code in an attempt to get cells the right width.

	If you're trying to figure out widths for another version of
	troff, run nwidth.trf through it and look at the result.
*/

# include	<stdio.h>
# include	<sys/types.h>
# include	"rtf.h"
# include	"rtf2troff.h"

typedef	struct EnVal	EnVal;

struct	EnVal
{
	int	size;
	double	width;
};

# define	uXroff	300.0	/* xroff dpi */

EnVal	enXroff [] =
{
	3,	9./uXroff,	/* xroff uses 4 */
	4,	9./uXroff,
	5,	11./uXroff,
	6,	13./uXroff,
	7,	16./uXroff,
	8,	18./uXroff,
	9,	20./uXroff,
	10,	22./uXroff,
	11,	25./uXroff,
	12,	27./uXroff,
	13,	29./uXroff,
	14,	31./uXroff,
	15,	34./uXroff,
	16,	36./uXroff,
	17,	36./uXroff,	/* xroff uses 16 */
	18,	40./uXroff,
	19,	40./uXroff,	/* xroff uses 18 */
	20,	45./uXroff,
	22,	45./uXroff,	/* xroff uses 20 */
	24,	54./uXroff,
	26,	54./uXroff,	/* xroff uses 24
	28,	63./uXroff,
	30,	67./uXroff,
	32,	67./uXroff,	/* xroff uses 0?!? Use 30 instead */
	34,	67./uXroff,	/* xroff uses 0?!? Use 30 instead */
	36,	81./uXroff,
	38,	81./uXroff,	/* xroff uses 36 */
	40,	81./uXroff,	/* xroff uses 36
	44,	107./uXroff,	/* xroff uses 48 */
	48,	107./uXroff,
	72,	107./uXroff,	/* xroff uses 48 */
	0,	50./uXroff	/* 0 = end of table; 50 = default size */
};


static double	EVTabLookup ();


static double EVTabLookup (tab)
EnVal	tab[];
{
int	ps = ics->fontSize;
EnVal	*p;

	for (p = tab; p->size != 0; p++)
	{
		if (p->size >= ps)
			return (p->width);
	}
	return (p->width);	/* use last width as default */
}


double EnWidth ()
{
	/*
		Our tpscript uses 720 as resolution base, and character
		sizes are 5 times the point size.
	*/
	if (tvers == PSTROFF)
		return (ics->fontSize * 5. / 720.);

	/* default - covers troff and xroff */
	return (EVTabLookup (enXroff));
}