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