1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)diacrit.c	4.4 (Berkeley) 04/17/91";
10 #endif /* not lint */
11 
12 # include "e.h"
13 # include "e.def"
14 
15 diacrit(p1, type) int p1, type; {
16 	int c, t;
17 #ifndef NEQN
18 	int effps;
19 #endif NEQN
20 
21 	c = oalloc();
22 	t = oalloc();
23 #ifdef NEQN
24 	nrwid(p1, ps, p1);
25 	printf(".nr 10 %du\n", max(eht[p1]-ebase[p1]-VERT(2),0));
26 #else NEQN
27 	effps = EFFPS(ps);
28 	nrwid(p1, effps, p1);
29 	printf(".nr 10 %du\n", VERT(max(eht[p1]-ebase[p1]-6*ps,0)));	/* vertical shift if high */
30 	printf(".if \\n(ct>1 .nr 10 \\n(10+\\s%d.25m\\s0\n", effps);
31 	printf(".nr %d \\s%d.1m\\s0\n", t, effps);	/* horiz shift if high */
32 	printf(".if \\n(ct>1 .nr %d \\s%d.15m\\s0\n", t, effps);
33 #endif NEQN
34 	switch(type) {
35 		case VEC:	/* vec */
36 #ifndef NEQN
37 			printf(".ds %d \\v'-.4m'\\s%d\\(->\\s0\\v'.4m'\n",
38 			    c, max(effps-3, 6));
39 			break;
40 #endif NEQN
41 		case DYAD:	/* dyad */
42 #ifdef NEQN
43 			printf(".ds %d \\v'-1'_\\v'1'\n", c);
44 #else NEQN
45 			printf(".ds %d \\v'-.4m'\\s%d\\z\\(<-\\(->\\s0\\v'.4m'\n",
46 			    c, max(effps-3, 6));
47 #endif NEQN
48 			break;
49 		case HAT:
50 			printf(".ds %d ^\n", c);
51 			break;
52 		case TILDE:
53 			printf(".ds %d ~\n", c);
54 			break;
55 		case DOT:
56 #ifndef NEQN
57 			printf(".ds %d \\s%d\\v'-.67m'.\\v'.67m'\\s0\n", c, effps);
58 #else NEQN
59 			printf(".ds %d \\v'-1'.\\v'1'\n", c);
60 #endif NEQN
61 			break;
62 		case DOTDOT:
63 #ifndef NEQN
64 			printf(".ds %d \\s%d\\v'-.67m'..\\v'.67m\\s0'\n", c, effps);
65 #else NEQN
66 			printf(".ds %d \\v'-1'..\\v'1'\n", c);
67 #endif NEQN
68 			break;
69 		case BAR:
70 #ifndef NEQN
71 			printf(".ds %d \\s%d\\v'.18m'\\h'.05m'\\l'\\n(%du-.1m\\(rn'\\h'.05m'\\v'-.18m'\\s0\n",
72 				c, effps, p1);
73 #else NEQN
74 			printf(".ds %d \\v'-1'\\l'\\n(%du'\\v'1'\n",
75 				c, p1);
76 #endif NEQN
77 			break;
78 		case UNDER:
79 #ifndef NEQN
80 			printf(".ds %d \\l'\\n(%du\\(ul'\n", c, p1);
81 			printf(".nr %d 0\n", t);
82 			printf(".nr 10 0-%d\n", ebase[p1]);
83 #else NEQN
84 			printf(".ds %d \\l'\\n(%du'\n", c, p1);
85 #endif NEQN
86 			break;
87 		}
88 	nrwid(c, ps, c);
89 #ifndef NEQN
90 	if (lfont[p1] != ITAL)
91 		printf(".nr %d 0\n", t);
92 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d",
93 		p1, p1, c, t, c);
94 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t);
95 	/* BUG - should go to right end of widest */
96 #else NEQN
97 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u'\\v'0-\\n(10u'\\*(%d",
98 		p1, p1, c, c);
99 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u'\n", c, p1);
100 #endif NEQN
101 #ifndef NEQN
102 	if (type != UNDER)
103 		eht[p1] += VERT( (6*ps*15) / 100);	/* 0.15m */
104 	if(dbg)printf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%d,b=%d\n",
105 		type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]);
106 #else NEQN
107 	if (type != UNDER)
108 		eht[p1] += VERT(1);
109 	if (dbg) printf(".\tdiacrit: %c over S%d, h=%d, b=%d\n", type, p1, eht[p1], ebase[p1]);
110 #endif NEQN
111 	ofree(c); ofree(t);
112 }
113