xref: /illumos-gate/usr/src/cmd/eqn/diacrit.c (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
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 #include "e.def"
17 
18 void
19 diacrit(int p1, int type)
20 {
21 	int c, t;
22 #ifndef NEQN
23 	int effps;
24 #endif	/* NEQN */
25 
26 	c = oalloc();
27 	t = oalloc();
28 #ifdef NEQN
29 	nrwid(p1, ps, p1);
30 	printf(".nr 10 %du\n", max(eht[p1]-ebase[p1]-VERT(2), 0));
31 #else	/* NEQN */
32 	effps = EFFPS(ps);
33 	nrwid(p1, effps, p1);
34 
35 	/* vertical shift if high */
36 	printf(".nr 10 %du\n", VERT(max(eht[p1]-ebase[p1]-EM(1, ps), 0)));
37 
38 	printf(".if \\n(ct>1 .nr 10 \\n(10+\\s%d.25m\\s0\n", effps);
39 
40 	/* horiz shift if high */
41 	printf(".nr %d \\s%d.1m\\s0\n", t, effps);
42 
43 	printf(".if \\n(ct>1 .nr %d \\s%d.15m\\s0\n", t, effps);
44 #endif	/* NEQN */
45 	switch (type) {
46 		case VEC:	/* vec */
47 #ifndef NEQN
48 			printf(".ds %d \\v'-.4m'\\s%d\\(->\\s0\\v'.4m'\n",
49 			    c, max(effps-3, 6));
50 			break;
51 #endif	/* NEQN */
52 		case DYAD:	/* dyad */
53 #ifdef NEQN
54 			printf(".ds %d \\v'-12p'_\\v'12p'\n", c);
55 #else	/* NEQN */
56 			printf(
57 			    ".ds %d \\v'-.4m'\\s%d\\z\\(<-\\(->\\s0\\v'.4m'\n",
58 			    c, max(effps-3, 6));
59 #endif	/* NEQN */
60 			break;
61 		case HAT:
62 			printf(".ds %d ^\n", c);
63 			break;
64 		case TILDE:
65 			printf(".ds %d ~\n", c);
66 			break;
67 		case DOT:
68 #ifndef NEQN
69 			printf(
70 			    ".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 DOTDOT:
76 #ifndef NEQN
77 			printf(
78 			    ".ds %d \\s%d\\v'-.67m'..\\v'.67m\\s0'\n",
79 			    c, effps);
80 #else	/* NEQN */
81 			printf(".ds %d \\v'-12p'..\\v'12p'\n", c);
82 #endif	/* NEQN */
83 			break;
84 		case BAR:
85 #ifndef NEQN
86 			printf(".ds %d \\s%d\\v'.28m'\\h'.05m'\\l'\\n"
87 			    "(%du-.1m\\(rn'\\h'.05m'\\v'-.28m'\\s0\n",
88 			    c, effps, p1);
89 #else	/* NEQN */
90 			printf(".ds %d \\v'-12p'\\l'\\n(%du'\\v'12p'\n",
91 			    c, p1);
92 #endif	/* NEQN */
93 			break;
94 		case UNDER:
95 #ifndef NEQN
96 			printf(".ds %d \\l'\\n(%du\\(ul'\n", c, p1);
97 			printf(".nr %d 0\n", t);
98 			printf(".nr 10 0-%d\n", ebase[p1]);
99 #else	/* NEQN */
100 			printf(".ds %d \\l'\\n(%du'\n", c, p1);
101 #endif	/* NEQN */
102 			break;
103 	}
104 	nrwid(c, ps, c);
105 #ifndef NEQN
106 	if (lfont[p1] != ITAL)
107 		printf(".nr %d 0\n", t);
108 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d",
109 	    p1, p1, c, t, c);
110 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t);
111 	/* BUG - should go to right end of widest */
112 #else	/* NEQN */
113 	printf(".as %d \\h'-\\n(%du-\\n(%du/2u'\\v'0-\\n(10u'\\*(%d",
114 	    p1, p1, c, c);
115 	printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u'\n", c, p1);
116 #endif	/* NEQN */
117 #ifndef NEQN
118 	if (type != UNDER)
119 		eht[p1] += VERT(EM(0.15, ps));	/* 0.15m */
120 	if (dbg)
121 		printf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%d,b=%d\n",
122 		    type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]);
123 #else	/* NEQN */
124 	if (type != UNDER)
125 		eht[p1] += VERT(1);
126 	if (dbg)
127 		printf(".\tdiacrit: %c over S%d, h=%d, b=%d\n",
128 		    type, p1, eht[p1], ebase[p1]);
129 #endif	/* NEQN */
130 	ofree(c); ofree(t);
131 }
132