| 295 |
|
|
| 296 |
|
|
| 297 |
|
inglyph(x, y, gl) /* (x,y) within font glyph gl? */ |
| 298 |
< |
double x, y; |
| 298 |
> |
double x, y; /* real coordinates in range [0,256) */ |
| 299 |
|
register GLYPH *gl; |
| 300 |
|
{ |
| 301 |
|
int n, ncross; |
| 302 |
< |
int xtc, ytc; |
| 302 |
> |
int xlb, ylb; |
| 303 |
> |
int tv; |
| 304 |
|
register GORD *p0, *p1; |
| 305 |
|
|
| 306 |
|
if (gl == NULL) |
| 307 |
|
return(0); |
| 308 |
< |
xtc = x + 0.5; /* compute test coordinates */ |
| 309 |
< |
ytc = y + 0.5; |
| 310 |
< |
if (gl->left > xtc || gl->right < xtc || |
| 311 |
< |
gl->bottom > ytc || gl->top < ytc) |
| 312 |
< |
return(0); /* outside extent */ |
| 308 |
> |
xlb = x; |
| 309 |
> |
ylb = y; |
| 310 |
> |
if (gl->left > xlb || gl->right <= xlb || /* check extent */ |
| 311 |
> |
gl->bottom > ylb || gl->top <= ylb) |
| 312 |
> |
return(0); |
| 313 |
> |
xlb = xlb<<1 | 1; /* add 1/2 to test points... */ |
| 314 |
> |
ylb = ylb<<1 | 1; /* ...so no equal comparisons */ |
| 315 |
|
n = gl->nverts; /* get # of vertices */ |
| 316 |
|
p0 = gvlist(gl) + 2*(n-1); /* connect last to first */ |
| 317 |
|
p1 = gvlist(gl); |
| 318 |
|
ncross = 0; |
| 319 |
|
/* positive x axis cross test */ |
| 320 |
|
while (n--) { |
| 321 |
< |
if ((p0[1] > ytc) ^ (p1[1] > ytc)) |
| 322 |
< |
if (p0[0] > xtc && p1[0] > xtc) |
| 321 |
> |
if ((p0[1]<<1 > ylb) ^ (p1[1]<<1 > ylb)) { |
| 322 |
> |
tv = p0[0]<<1 > xlb | (p1[0]<<1 > xlb) << 1; |
| 323 |
> |
if (tv == 03) |
| 324 |
|
ncross++; |
| 325 |
< |
else if (p0[0] > xtc || p1[0] > xtc) |
| 325 |
> |
else if (tv) |
| 326 |
|
ncross += (p1[1] > p0[1]) ^ |
| 327 |
|
((p0[1]-y)*(p1[0]-x) > |
| 328 |
|
(p0[0]-x)*(p1[1]-y)); |
| 329 |
+ |
} |
| 330 |
|
p0 = p1; |
| 331 |
|
p1 += 2; |
| 332 |
|
} |