xref: /onnv-gate/usr/src/cmd/eqn/diacrit.c (revision 364:f36290b8cb0b)
1*364Sceastha /*
2*364Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*364Sceastha  * Use is subject to license terms.
4*364Sceastha  */
5*364Sceastha 
60Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate  */
14*364Sceastha 
15*364Sceastha #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
17*364Sceastha #include "e.h"
18*364Sceastha #include "e.def"
190Sstevel@tonic-gate 
20*364Sceastha void
diacrit(int p1,int type)21*364Sceastha diacrit(int p1, int type)
22*364Sceastha {
230Sstevel@tonic-gate 	int c, t;
240Sstevel@tonic-gate #ifndef NEQN
250Sstevel@tonic-gate 	int effps;
26*364Sceastha #endif	/* NEQN */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate 	c = oalloc();
290Sstevel@tonic-gate 	t = oalloc();
300Sstevel@tonic-gate #ifdef NEQN
310Sstevel@tonic-gate 	nrwid(p1, ps, p1);
32*364Sceastha 	printf(".nr 10 %du\n", max(eht[p1]-ebase[p1]-VERT(2), 0));
33*364Sceastha #else	/* NEQN */
340Sstevel@tonic-gate 	effps = EFFPS(ps);
350Sstevel@tonic-gate 	nrwid(p1, effps, p1);
36*364Sceastha 
37*364Sceastha 	/* vertical shift if high */
38*364Sceastha 	printf(".nr 10 %du\n", VERT(max(eht[p1]-ebase[p1]-EM(1, ps), 0)));
39*364Sceastha 
400Sstevel@tonic-gate 	printf(".if \\n(ct>1 .nr 10 \\n(10+\\s%d.25m\\s0\n", effps);
41*364Sceastha 
42*364Sceastha 	/* horiz shift if high */
43*364Sceastha 	printf(".nr %d \\s%d.1m\\s0\n", t, effps);
44*364Sceastha 
450Sstevel@tonic-gate 	printf(".if \\n(ct>1 .nr %d \\s%d.15m\\s0\n", t, effps);
46*364Sceastha #endif	/* NEQN */
47*364Sceastha 	switch (type) {
480Sstevel@tonic-gate 		case VEC:	/* vec */
490Sstevel@tonic-gate #ifndef NEQN
500Sstevel@tonic-gate 			printf(".ds %d \\v'-.4m'\\s%d\\(->\\s0\\v'.4m'\n",
510Sstevel@tonic-gate 			    c, max(effps-3, 6));
520Sstevel@tonic-gate 			break;
53*364Sceastha #endif	/* NEQN */
540Sstevel@tonic-gate 		case DYAD:	/* dyad */
550Sstevel@tonic-gate #ifdef NEQN
560Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'_\\v'12p'\n", c);
57*364Sceastha #else	/* NEQN */
58*364Sceastha 			printf(
59*364Sceastha 			    ".ds %d \\v'-.4m'\\s%d\\z\\(<-\\(->\\s0\\v'.4m'\n",
600Sstevel@tonic-gate 			    c, max(effps-3, 6));
61*364Sceastha #endif	/* NEQN */
620Sstevel@tonic-gate 			break;
630Sstevel@tonic-gate 		case HAT:
640Sstevel@tonic-gate 			printf(".ds %d ^\n", c);
650Sstevel@tonic-gate 			break;
660Sstevel@tonic-gate 		case TILDE:
670Sstevel@tonic-gate 			printf(".ds %d ~\n", c);
680Sstevel@tonic-gate 			break;
690Sstevel@tonic-gate 		case DOT:
700Sstevel@tonic-gate #ifndef NEQN
71*364Sceastha 			printf(
72*364Sceastha 			    ".ds %d \\s%d\\v'-.67m'.\\v'.67m'\\s0\n", c, effps);
73*364Sceastha #else	/* NEQN */
740Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'.\\v'12p'\n", c);
75*364Sceastha #endif	/* NEQN */
760Sstevel@tonic-gate 			break;
770Sstevel@tonic-gate 		case DOTDOT:
780Sstevel@tonic-gate #ifndef NEQN
79*364Sceastha 			printf(
80*364Sceastha 			    ".ds %d \\s%d\\v'-.67m'..\\v'.67m\\s0'\n",
81*364Sceastha 			    c, effps);
82*364Sceastha #else	/* NEQN */
830Sstevel@tonic-gate 			printf(".ds %d \\v'-12p'..\\v'12p'\n", c);
84*364Sceastha #endif	/* NEQN */
850Sstevel@tonic-gate 			break;
860Sstevel@tonic-gate 		case BAR:
870Sstevel@tonic-gate #ifndef NEQN
88*364Sceastha 			printf(".ds %d \\s%d\\v'.28m'\\h'.05m'\\l'\\n"
89*364Sceastha 			    "(%du-.1m\\(rn'\\h'.05m'\\v'-.28m'\\s0\n",
90*364Sceastha 			    c, effps, p1);
91*364Sceastha #else	/* NEQN */
92*364Sceastha 			printf(".ds %d \\v'-12p'\\l'\\n(%du'\\v'12p'\n",
93*364Sceastha 			    c, p1);
94*364Sceastha #endif	/* NEQN */
950Sstevel@tonic-gate 			break;
960Sstevel@tonic-gate 		case UNDER:
970Sstevel@tonic-gate #ifndef NEQN
980Sstevel@tonic-gate 			printf(".ds %d \\l'\\n(%du\\(ul'\n", c, p1);
990Sstevel@tonic-gate 			printf(".nr %d 0\n", t);
1000Sstevel@tonic-gate 			printf(".nr 10 0-%d\n", ebase[p1]);
101*364Sceastha #else	/* NEQN */
1020Sstevel@tonic-gate 			printf(".ds %d \\l'\\n(%du'\n", c, p1);
103*364Sceastha #endif	/* NEQN */
1040Sstevel@tonic-gate 			break;
105*364Sceastha 	}
1060Sstevel@tonic-gate 	nrwid(c, ps, c);
1070Sstevel@tonic-gate #ifndef NEQN
1080Sstevel@tonic-gate 	if (lfont[p1] != ITAL)
1090Sstevel@tonic-gate 		printf(".nr %d 0\n", t);
110*364Sceastha 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d",
111*364Sceastha 	    p1, p1, c, t, c);
1120Sstevel@tonic-gate 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t);
1130Sstevel@tonic-gate 	/* BUG - should go to right end of widest */
114*364Sceastha #else	/* NEQN */
115*364Sceastha 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u'\\v'0-\\n(10u'\\*(%d",
116*364Sceastha 	    p1, p1, c, c);
1170Sstevel@tonic-gate 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u'\n", c, p1);
118*364Sceastha #endif	/* NEQN */
1190Sstevel@tonic-gate #ifndef NEQN
1200Sstevel@tonic-gate 	if (type != UNDER)
1210Sstevel@tonic-gate 		eht[p1] += VERT(EM(0.15, ps));	/* 0.15m */
122*364Sceastha 	if (dbg)
123*364Sceastha 		printf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%d,b=%d\n",
124*364Sceastha 		    type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]);
125*364Sceastha #else	/* NEQN */
1260Sstevel@tonic-gate 	if (type != UNDER)
1270Sstevel@tonic-gate 		eht[p1] += VERT(1);
128*364Sceastha 	if (dbg)
129*364Sceastha 		printf(".\tdiacrit: %c over S%d, h=%d, b=%d\n",
130*364Sceastha 		    type, p1, eht[p1], ebase[p1]);
131*364Sceastha #endif	/* NEQN */
1320Sstevel@tonic-gate 	ofree(c); ofree(t);
1330Sstevel@tonic-gate }
134