xref: /illumos-gate/usr/src/cmd/eqn/font.c (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved. The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #include "e.h"
16 
17 void
18 setfont(char ch1)
19 {
20 	/* use number '1', '2', '3' for roman, italic, bold */
21 	yyval = ft;
22 	if (ch1 == 'r' || ch1 == 'R')
23 		ft = ROM;
24 	else if (ch1 == 'i' || ch1 == 'I')
25 		ft = ITAL;
26 	else if (ch1 == 'b' || ch1 == 'B')
27 		ft = BLD;
28 	else
29 		ft = ch1;
30 	printf(".ft %c\n", ft);
31 #ifndef NEQN
32 	if (dbg) printf(".\tsetfont %c %c\n", ch1, ft);
33 #else	/* NEQN */
34 	if (dbg) printf(".\tsetfont %c\n", ft);
35 #endif	/* NEQN */
36 }
37 
38 void
39 font(int p1, int p2)
40 {
41 		/* old font in p1, new in ft */
42 	yyval = p2;
43 	lfont[yyval] = rfont[yyval] = ft == ITAL ? ITAL : ROM;
44 	if (dbg)
45 		printf(".\tb:fb: S%d <- \\f%c S%d \\f%c b=%d,h=%d,lf=%c,"
46 		    "rf=%c\n", yyval, ft, p2, p1, ebase[yyval], eht[yyval],
47 		    lfont[yyval], rfont[yyval]);
48 	printf(".ds %d \\f%c\\*(%d\\f%c\n", yyval, ft, p2, p1);
49 	ft = p1;
50 	printf(".ft %c\n", ft);
51 }
52 
53 void
54 fatbox(int p)
55 {
56 	yyval = p;
57 	nrwid(p, ps, p);
58 	printf(".ds %d \\*(%d\\h'-\\n(%du+0.05m'\\*(%d\n", p, p, p, p);
59 	if (dbg) printf(".\tfat %d, sh=0.05m\n", p);
60 }
61 
62 void
63 globfont(void)
64 {
65 	char temp[20];
66 
67 	(void) getstr(temp, 20);
68 	yyval = eqnreg = 0;
69 	gfont = temp[0];
70 	switch (gfont) {
71 	case 'r': case 'R':
72 		gfont = '1';
73 		break;
74 	case 'i': case 'I':
75 		gfont = '2';
76 		break;
77 	case 'b': case 'B':
78 		gfont = '3';
79 		break;
80 	}
81 	printf(".ft %c\n", gfont);
82 	ft = gfont;
83 }
84