1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
142 |
|
if ((tl=(TLINE *)malloc(sizeof(TLINE)+siz)) == NULL || |
143 |
|
(tl->spc=(short *)malloc(siz*sizeof(short))) == NULL) |
144 |
|
error(SYSTEM, "out of memory in tlalloc"); |
145 |
– |
tl->spc = NULL; |
145 |
|
tl->next = NULL; |
146 |
|
strcpy(TLSTR(tl), s); |
147 |
|
return(tl); |
154 |
|
{ |
155 |
|
#define R (tm->oargs.farg+3) |
156 |
|
#define D (tm->oargs.farg+6) |
157 |
< |
extern char *strcpy(), *fgets(); |
157 |
> |
extern char *strcpy(); |
158 |
|
FVECT DxR; |
159 |
|
double d; |
160 |
|
FILE *fp; |
170 |
|
if (tm->oargs.nsargs - tndx(tm) < 1 || tm->oargs.nfargs < sndx(tm)) |
171 |
|
objerror(tm, USER, "bad # arguments"); |
172 |
|
if ((t = (TEXT *)malloc(sizeof(TEXT))) == NULL) |
173 |
< |
goto memerr; |
173 |
> |
error(SYSTEM, "out of memory in gettext"); |
174 |
|
/* compute vectors */ |
175 |
|
fcross(DxR, D, R); |
176 |
|
fcross(t->right, DxR, D); |
220 |
|
i = sndx(tm); |
221 |
|
d = i < tm->oargs.nfargs ? tm->oargs.farg[i] : 0.0; |
222 |
|
i = d * 256.0; |
223 |
+ |
t->tl.width = 0; |
224 |
|
for (tlp = t->tl.next; tlp != NULL; tlp = tlp->next) { |
225 |
– |
if ((tlp->spc = (short *)malloc( |
226 |
– |
(strlen(TLSTR(tlp))+1)*sizeof(short))) == NULL) |
227 |
– |
goto memerr; |
225 |
|
if (i < 0) |
226 |
|
tlp->width = squeeztext(tlp->spc, TLSTR(tlp), t->f, -i); |
227 |
|
else if (i > 0) |
228 |
|
tlp->width = proptext(tlp->spc, TLSTR(tlp), t->f, i, 3); |
229 |
|
else |
230 |
|
tlp->width = uniftext(tlp->spc, TLSTR(tlp), t->f); |
231 |
+ |
if (tlp->width > t->tl.width) |
232 |
+ |
t->tl.width = tlp->width; |
233 |
|
} |
234 |
|
/* we're done */ |
235 |
|
tm->os = (char *)t; |
236 |
|
return(t); |
238 |
– |
memerr: |
239 |
– |
error(SYSTEM, "out of memory in gettext"); |
237 |
|
#undef R |
238 |
|
#undef D |
239 |
|
} |
248 |
|
tp = (TEXT *)m->os; |
249 |
|
if (tp == NULL) |
250 |
|
return; |
251 |
< |
for (tlp = tp->tl.next; tlp != NULL; tlp = tlp->next) { |
251 |
> |
while ((tlp = tp->tl.next) != NULL) { |
252 |
> |
tp->tl.next = tlp->next; |
253 |
|
free((char *)tlp->spc); |
254 |
|
free((char *)tlp); |
255 |
|
} |
272 |
|
v[0] = p[0] - m->oargs.farg[0]; |
273 |
|
v[1] = p[1] - m->oargs.farg[1]; |
274 |
|
v[2] = p[2] - m->oargs.farg[2]; |
275 |
< |
h = x = DOT(v, tp->right)*256.; |
275 |
> |
x = DOT(v, tp->right); |
276 |
> |
i = sndx(m); |
277 |
> |
if (i < m->oargs.nfargs) |
278 |
> |
x *= tp->f->mwidth + 256.*fabs(m->oargs.farg[i]); |
279 |
> |
else |
280 |
> |
x *= 256.; |
281 |
> |
h = x; |
282 |
|
i = y = DOT(v, tp->down); |
283 |
|
if (x < 0.0 || y < 0.0) |
284 |
|
return(0); |
299 |
|
|
300 |
|
|
301 |
|
inglyph(x, y, gl) /* (x,y) within font glyph gl? */ |
302 |
< |
double x, y; |
302 |
> |
double x, y; /* real coordinates in range [0,256) */ |
303 |
|
register GLYPH *gl; |
304 |
|
{ |
305 |
|
int n, ncross; |
306 |
< |
int xtc, ytc; |
306 |
> |
int xlb, ylb; |
307 |
> |
int tv; |
308 |
|
register GORD *p0, *p1; |
309 |
|
|
310 |
|
if (gl == NULL) |
311 |
|
return(0); |
312 |
< |
xtc = x + 0.5; /* compute test coordinates */ |
313 |
< |
ytc = y + 0.5; |
314 |
< |
if (gl->left > xtc || gl->right < xtc || |
315 |
< |
gl->bottom > ytc || gl->top < ytc) |
316 |
< |
return(0); /* outside extent */ |
312 |
> |
xlb = x; |
313 |
> |
ylb = y; |
314 |
> |
if (gl->left > xlb || gl->right <= xlb || /* check extent */ |
315 |
> |
gl->bottom > ylb || gl->top <= ylb) |
316 |
> |
return(0); |
317 |
> |
xlb = xlb<<1 | 1; /* add 1/2 to test points... */ |
318 |
> |
ylb = ylb<<1 | 1; /* ...so no equal comparisons */ |
319 |
|
n = gl->nverts; /* get # of vertices */ |
320 |
|
p0 = gvlist(gl) + 2*(n-1); /* connect last to first */ |
321 |
|
p1 = gvlist(gl); |
322 |
|
ncross = 0; |
323 |
|
/* positive x axis cross test */ |
324 |
|
while (n--) { |
325 |
< |
if ((p0[1] > ytc) ^ (p1[1] > ytc)) |
326 |
< |
if (p0[0] > xtc && p1[0] > xtc) |
325 |
> |
if ((p0[1]<<1 > ylb) ^ (p1[1]<<1 > ylb)) { |
326 |
> |
tv = p0[0]<<1 > xlb | (p1[0]<<1 > xlb) << 1; |
327 |
> |
if (tv == 03) |
328 |
|
ncross++; |
329 |
< |
else if (p0[0] > xtc || p1[0] > xtc) |
329 |
> |
else if (tv) |
330 |
|
ncross += (p1[1] > p0[1]) ^ |
331 |
|
((p0[1]-y)*(p1[0]-x) > |
332 |
|
(p0[0]-x)*(p1[1]-y)); |
333 |
+ |
} |
334 |
|
p0 = p1; |
335 |
|
p1 += 2; |
336 |
|
} |