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