2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
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.
15 #pragma ident "%Z%%M% %I% %E% SMI"
21 bshiftb(int p1
, int dir
, int p2
)
23 int shval
, d1
, h1
, b1
, h2
, b2
;
25 int diffps
, effps
, effps2
;
36 effps2
= EFFPS(ps
+deltaps
);
40 if (dir
== SUB
) { /* subscript */
42 /* top 1/2m above bottom of main box */
43 d1
= VERT(EM(0.5, effps2
));
47 shval
= - d1
+ h2
- b2
;
48 if (d1
+b1
> h2
) /* move little sub down */
50 ebase
[yyval
] = b1
+ max(0, h2
-b1
-d1
);
51 eht
[yyval
] = h1
+ max(0, h2
-b1
-d1
);
53 if (rfont
[p1
] == ITAL
&& lfont
[p2
] == ROM
)
55 if (rfont
[p2
] == ITAL
)
58 } else { /* superscript */
60 /* 4/10 up main box */
61 d1
= VERT(EM(0.2, effps
));
67 shval
= -VERT((4 * (h1
-b1
)) / 10) - b2
;
68 if (VERT(4*(h1
-b1
)/10) + h2
< h1
-b1
) /* raise little super */
70 shval
= -VERT(1) - b2
;
71 if (VERT(1) + h2
< h1
-b1
) /* raise little super */
73 shval
= -(h1
-b1
) + h2
-b2
- d1
;
75 eht
[yyval
] = h1
+ max(0, h2
-VERT((6*(h1
-b1
))/10));
76 if (rfont
[p1
] == ITAL
)
78 if (rfont
[p2
] == ITAL
)
81 eht
[yyval
] = h1
+ max(0, h2
- VERT(1));
85 printf(".\tb:b shift b: S%d <- S%d vert %d S%d vert %d; "
86 "b=%d, h=%d\n", yyval
, p1
, shval
, p2
, -shval
,
87 ebase
[yyval
], eht
[yyval
]);
89 printf(".as %d \\v'%du'\\s-%d%s\\*(%d\\s+%d%s\\v'%du'\n",
90 yyval
, shval
, diffps
, sh1
, p2
, diffps
, sh2
, -shval
);
92 if (rfont
[p2
] == ITAL
)
95 rfont
[p1
] = rfont
[p2
];
97 printf(".as %d \\v'%du'\\*(%d\\v'%du'\n",
98 yyval
, shval
, p2
, -shval
);
108 if (dbg
) printf(".\tshift: %d;ps=%d\n", yyval
, ps
);
112 shift2(int p1
, int p2
, int p3
)
114 int effps
, h1
, h2
, h3
, b1
, b2
, b3
, subsh
, d1
, d2
, supsh
, treg
;
121 if (dbg
) printf(".\tshift2 s%d <- %d %d %d\n", yyval
, p1
, p2
, p3
);
122 effps
= EFFPS(ps
+deltaps
);
124 eht
[p3
] = h3
= VERT((eht
[p3
] * effps
) / EFFPS(ps
));
126 effps2
= EFFPS(ps
+deltaps
);
128 h1
= eht
[p1
]; b1
= ebase
[p1
];
129 h2
= eht
[p2
]; b2
= ebase
[p2
];
132 d1
= VERT(EM(0.5, effps2
));
134 h3
= eht
[p3
]; b3
= ebase
[p3
];
138 if (d1
+b1
> h2
) /* move little sub down */
141 supsh
= -VERT((4*(h1
-b1
))/10) - b3
;
142 d2
= VERT(EM(0.2, effps
));
143 if (VERT(4*(h1
-b1
)/10)+h3
< h1
-b1
)
145 supsh
= - VERT(1) - b3
;
147 if (VERT(1)+h3
< h1
-b1
)
149 supsh
= -(h1
-b1
) + (h3
-b3
) - d2
;
151 eht
[yyval
] = h1
+ max(0, h3
-VERT((6*(h1
-b1
))/10)) + max(0, h2
-b1
-d1
);
153 eht
[yyval
] = h1
+ max(0, h3
-VERT(1)) + max(0, h2
-b1
-d1
);
155 ebase
[yyval
] = b1
+max(0, h2
-b1
-d1
);
157 if (rfont
[p1
] == ITAL
&& lfont
[p2
] == ROM
)
158 printf(".ds %d \\|\\*(%d\n", p2
, p2
);
159 if (rfont
[p2
] == ITAL
)
160 printf(".as %d \\|\n", p2
);
162 nrwid(p2
, effps
, p2
);
164 if (rfont
[p1
] == ITAL
&& lfont
[p3
] == ROM
)
165 printf(".ds %d \\|\\|\\*(%d\n", p3
, p3
);
167 printf(".ds %d \\|\\*(%d\n", p3
, p3
);
169 nrwid(p3
, effps
, p3
);
170 printf(".nr %d \\n(%d\n", treg
, p3
);
171 printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2
, treg
, treg
, p2
);
173 printf(".as %d \\v'%du'\\s%d\\*(%d\\h'-\\n(%du'\\v'%du'\\\n",
174 p1
, subsh
, effps
, p2
, p2
, -subsh
+supsh
);
175 printf("\\s%d\\*(%d\\h'-\\n(%du+\\n(%du'\\s%d\\v'%du'\n",
176 effps
, p3
, p3
, treg
, effps2
, -supsh
);
178 printf(".as %d \\v'%du'\\*(%d\\h'-\\n(%du'\\v'%du'\\\n",
179 p1
, subsh
, p2
, p2
, -subsh
+supsh
);
180 printf("\\*(%d\\h'-\\n(%du+\\n(%du'\\v'%du'\n",
181 p3
, p3
, treg
, -supsh
);
185 if (rfont
[p2
] == ITAL
)
186 rfont
[yyval
] = 0; /* lie */
188 ofree(p2
); ofree(p3
); ofree(treg
);