xref: /titanic_54/usr/src/cmd/eqn/diacrit.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
3*7c478bd9Sstevel@tonic-gate 
4*7c478bd9Sstevel@tonic-gate 
5*7c478bd9Sstevel@tonic-gate /*
6*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
7*7c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
8*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
9*7c478bd9Sstevel@tonic-gate  */
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate /*
12*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13*7c478bd9Sstevel@tonic-gate  * All Rights Reserved.
14*7c478bd9Sstevel@tonic-gate  */
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate # include "e.h"
19*7c478bd9Sstevel@tonic-gate # include "e.def"
20*7c478bd9Sstevel@tonic-gate 
21*7c478bd9Sstevel@tonic-gate diacrit(p1, type) int p1, type; {
22*7c478bd9Sstevel@tonic-gate 	int c, t;
23*7c478bd9Sstevel@tonic-gate #ifndef NEQN
24*7c478bd9Sstevel@tonic-gate 	int effps;
25*7c478bd9Sstevel@tonic-gate #endif NEQN
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate 	c = oalloc();
28*7c478bd9Sstevel@tonic-gate 	t = oalloc();
29*7c478bd9Sstevel@tonic-gate #ifdef NEQN
30*7c478bd9Sstevel@tonic-gate 	nrwid(p1, ps, p1);
31*7c478bd9Sstevel@tonic-gate 	printf(".nr 10 %du\n", max(eht[p1]-ebase[p1]-VERT(2),0));
32*7c478bd9Sstevel@tonic-gate #else NEQN
33*7c478bd9Sstevel@tonic-gate 	effps = EFFPS(ps);
34*7c478bd9Sstevel@tonic-gate 	nrwid(p1, effps, p1);
35*7c478bd9Sstevel@tonic-gate 	printf(".nr 10 %du\n", VERT(max(eht[p1]-ebase[p1]-EM(1,ps),0)));	/* vertical shift if high */
36*7c478bd9Sstevel@tonic-gate 	printf(".if \\n(ct>1 .nr 10 \\n(10+\\s%d.25m\\s0\n", effps);
37*7c478bd9Sstevel@tonic-gate 	printf(".nr %d \\s%d.1m\\s0\n", t, effps);	/* horiz shift if high */
38*7c478bd9Sstevel@tonic-gate 	printf(".if \\n(ct>1 .nr %d \\s%d.15m\\s0\n", t, effps);
39*7c478bd9Sstevel@tonic-gate #endif NEQN
40*7c478bd9Sstevel@tonic-gate 	switch(type) {
41*7c478bd9Sstevel@tonic-gate 		case VEC:	/* vec */
42*7c478bd9Sstevel@tonic-gate #ifndef NEQN
43*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\v'-.4m'\\s%d\\(->\\s0\\v'.4m'\n",
44*7c478bd9Sstevel@tonic-gate 			    c, max(effps-3, 6));
45*7c478bd9Sstevel@tonic-gate 			break;
46*7c478bd9Sstevel@tonic-gate #endif NEQN
47*7c478bd9Sstevel@tonic-gate 		case DYAD:	/* dyad */
48*7c478bd9Sstevel@tonic-gate #ifdef NEQN
49*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'_\\v'12p'\n", c);
50*7c478bd9Sstevel@tonic-gate #else NEQN
51*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\v'-.4m'\\s%d\\z\\(<-\\(->\\s0\\v'.4m'\n",
52*7c478bd9Sstevel@tonic-gate 			    c, max(effps-3, 6));
53*7c478bd9Sstevel@tonic-gate #endif NEQN
54*7c478bd9Sstevel@tonic-gate 			break;
55*7c478bd9Sstevel@tonic-gate 		case HAT:
56*7c478bd9Sstevel@tonic-gate 			printf(".ds %d ^\n", c);
57*7c478bd9Sstevel@tonic-gate 			break;
58*7c478bd9Sstevel@tonic-gate 		case TILDE:
59*7c478bd9Sstevel@tonic-gate 			printf(".ds %d ~\n", c);
60*7c478bd9Sstevel@tonic-gate 			break;
61*7c478bd9Sstevel@tonic-gate 		case DOT:
62*7c478bd9Sstevel@tonic-gate #ifndef NEQN
63*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\s%d\\v'-.67m'.\\v'.67m'\\s0\n", c, effps);
64*7c478bd9Sstevel@tonic-gate #else NEQN
65*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'.\\v'12p'\n", c);
66*7c478bd9Sstevel@tonic-gate #endif NEQN
67*7c478bd9Sstevel@tonic-gate 			break;
68*7c478bd9Sstevel@tonic-gate 		case DOTDOT:
69*7c478bd9Sstevel@tonic-gate #ifndef NEQN
70*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\s%d\\v'-.67m'..\\v'.67m\\s0'\n", c, effps);
71*7c478bd9Sstevel@tonic-gate #else NEQN
72*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'..\\v'12p'\n", c);
73*7c478bd9Sstevel@tonic-gate #endif NEQN
74*7c478bd9Sstevel@tonic-gate 			break;
75*7c478bd9Sstevel@tonic-gate 		case BAR:
76*7c478bd9Sstevel@tonic-gate #ifndef NEQN
77*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\s%d\\v'.28m'\\h'.05m'\\l'\\n(%du-.1m\\(rn'\\h'.05m'\\v'-.28m'\\s0\n",
78*7c478bd9Sstevel@tonic-gate 				c, effps, p1);
79*7c478bd9Sstevel@tonic-gate #else NEQN
80*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'\\l'\\n(%du'\\v'12p'\n",
81*7c478bd9Sstevel@tonic-gate 				c, p1);
82*7c478bd9Sstevel@tonic-gate #endif NEQN
83*7c478bd9Sstevel@tonic-gate 			break;
84*7c478bd9Sstevel@tonic-gate 		case UNDER:
85*7c478bd9Sstevel@tonic-gate #ifndef NEQN
86*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\l'\\n(%du\\(ul'\n", c, p1);
87*7c478bd9Sstevel@tonic-gate 			printf(".nr %d 0\n", t);
88*7c478bd9Sstevel@tonic-gate 			printf(".nr 10 0-%d\n", ebase[p1]);
89*7c478bd9Sstevel@tonic-gate #else NEQN
90*7c478bd9Sstevel@tonic-gate 			printf(".ds %d \\l'\\n(%du'\n", c, p1);
91*7c478bd9Sstevel@tonic-gate #endif NEQN
92*7c478bd9Sstevel@tonic-gate 			break;
93*7c478bd9Sstevel@tonic-gate 		}
94*7c478bd9Sstevel@tonic-gate 	nrwid(c, ps, c);
95*7c478bd9Sstevel@tonic-gate #ifndef NEQN
96*7c478bd9Sstevel@tonic-gate 	if (lfont[p1] != ITAL)
97*7c478bd9Sstevel@tonic-gate 		printf(".nr %d 0\n", t);
98*7c478bd9Sstevel@tonic-gate 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d",
99*7c478bd9Sstevel@tonic-gate 		p1, p1, c, t, c);
100*7c478bd9Sstevel@tonic-gate 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t);
101*7c478bd9Sstevel@tonic-gate 	/* BUG - should go to right end of widest */
102*7c478bd9Sstevel@tonic-gate #else NEQN
103*7c478bd9Sstevel@tonic-gate 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u'\\v'0-\\n(10u'\\*(%d",
104*7c478bd9Sstevel@tonic-gate 		p1, p1, c, c);
105*7c478bd9Sstevel@tonic-gate 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u'\n", c, p1);
106*7c478bd9Sstevel@tonic-gate #endif NEQN
107*7c478bd9Sstevel@tonic-gate #ifndef NEQN
108*7c478bd9Sstevel@tonic-gate 	if (type != UNDER)
109*7c478bd9Sstevel@tonic-gate 		eht[p1] += VERT(EM(0.15, ps));	/* 0.15m */
110*7c478bd9Sstevel@tonic-gate 	if(dbg)printf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%d,b=%d\n",
111*7c478bd9Sstevel@tonic-gate 		type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]);
112*7c478bd9Sstevel@tonic-gate #else NEQN
113*7c478bd9Sstevel@tonic-gate 	if (type != UNDER)
114*7c478bd9Sstevel@tonic-gate 		eht[p1] += VERT(1);
115*7c478bd9Sstevel@tonic-gate 	if (dbg) printf(".\tdiacrit: %c over S%d, h=%d, b=%d\n", type, p1, eht[p1], ebase[p1]);
116*7c478bd9Sstevel@tonic-gate #endif NEQN
117*7c478bd9Sstevel@tonic-gate 	ofree(c); ofree(t);
118*7c478bd9Sstevel@tonic-gate }
119