16 |
|
|
17 |
|
#include "font.h" |
18 |
|
|
19 |
< |
#ifndef SSS |
20 |
< |
#define SSS 3 /* super-sample size */ |
21 |
< |
#endif |
19 |
> |
#include "paths.h" |
20 |
|
|
21 |
< |
#define MAXLINE 512 /* longest allowable line */ |
22 |
< |
|
25 |
< |
#ifndef DEFPATH |
26 |
< |
#define DEFPATH ":/usr/local/lib/ray" |
21 |
> |
#ifndef SSS |
22 |
> |
#define SSS 3 /* super-sample size */ |
23 |
|
#endif |
28 |
– |
#ifndef ULIBVAR |
29 |
– |
#define ULIBVAR "RAYPATH" |
30 |
– |
#endif |
24 |
|
|
25 |
+ |
#define MAXLINE 512 /* longest allowable line */ |
26 |
+ |
|
27 |
|
char *fontfile = "helvet.fnt"; /* our font file */ |
28 |
|
|
29 |
|
COLOR bgcolor = WHTCOLOR; /* background color */ |
32 |
|
int direct = 'r'; /* direction (right, up, left, down) */ |
33 |
|
|
34 |
|
int cheight = 32*SSS; /* character height */ |
35 |
< |
double aspect = 1.67; /* height/width character aspect */ |
36 |
< |
double spacing = 0.0; /* character spacing */ |
35 |
> |
double aspect = 1.67; /* height/width character aspect */ |
36 |
> |
double spacing = 0.0; /* character spacing */ |
37 |
|
int cwidth; /* computed character width */ |
38 |
|
|
39 |
|
unsigned char *ourbitmap; /* our output bitmap */ |
40 |
|
int xsiz, ysiz; /* bitmap dimensions */ |
41 |
|
int xdim; /* size of horizontal scan (bytes) */ |
42 |
|
|
43 |
< |
#define bitop(x,y,op) (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7))) |
44 |
< |
#define tstbit(x,y) bitop(x,y,&) |
45 |
< |
#define setbit(x,y) bitop(x,y,|=) |
46 |
< |
#define clrbit(x,y) bitop(x,y,&=~) |
47 |
< |
#define tglbit(x,y) bitop(x,y,^=) |
43 |
> |
#define bitop(x,y,op) (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7))) |
44 |
> |
#define tstbit(x,y) bitop(x,y,&) |
45 |
> |
#define setbit(x,y) bitop(x,y,|=) |
46 |
> |
#define clrbit(x,y) bitop(x,y,&=~) |
47 |
> |
#define tglbit(x,y) bitop(x,y,^=) |
48 |
|
|
49 |
|
FONT *ourfont; /* our font */ |
50 |
|
|
60 |
|
int nlines, maxline; /* text dimensions */ |
61 |
|
int maxwidth; /* maximum line width (dvi) */ |
62 |
|
|
68 |
– |
extern char *getenv(); |
63 |
|
|
70 |
– |
|
64 |
|
main(argc, argv) |
65 |
|
int argc; |
66 |
|
char *argv[]; |
67 |
|
{ |
68 |
|
int an; |
69 |
< |
|
69 |
> |
#ifdef MSDOS |
70 |
> |
setmode(fileno(stdout), O_BINARY); |
71 |
> |
#endif |
72 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
73 |
|
switch (argv[an][1]) { |
74 |
|
case 'c': /* color */ |
152 |
|
|
153 |
|
makemap() /* create the bit map */ |
154 |
|
{ |
155 |
< |
double pictaspect; |
155 |
> |
double pictaspect; |
156 |
|
|
157 |
|
if (direct == 'r' || direct == 'l') { |
158 |
|
if (xsiz <= 0) { |
168 |
|
else |
169 |
|
xsiz = ysiz/pictaspect + 0.5; |
170 |
|
cheight = ysiz/nlines; |
171 |
< |
cwidth = cheight/aspect + 0.5; |
171 |
> |
cwidth = cheight/aspect; |
172 |
|
} else { |
173 |
|
if (ysiz <= 0) |
174 |
|
ysiz = cheight*nlines; |
175 |
|
pictaspect = (double)ysiz/xsiz; |
176 |
|
aspect = pictaspect*maxwidth/(256*nlines); |
177 |
|
cheight = ysiz/nlines; |
178 |
< |
cwidth = cheight/aspect + 0.5; |
178 |
> |
cwidth = cheight/aspect; |
179 |
|
} |
180 |
|
} else { /* reverse orientation */ |
181 |
|
if (ysiz <= 0) { |
191 |
|
else |
192 |
|
xsiz = ysiz/pictaspect + 0.5; |
193 |
|
cheight = xsiz/nlines; |
194 |
< |
cwidth = cheight/aspect + 0.5; |
194 |
> |
cwidth = cheight/aspect; |
195 |
|
} else { |
196 |
|
if (xsiz <= 0) |
197 |
|
xsiz = cheight*nlines; |
198 |
|
pictaspect = (double)ysiz/xsiz; |
199 |
|
aspect = maxwidth/(256*nlines*pictaspect); |
200 |
|
cheight = xsiz/nlines; |
201 |
< |
cwidth = cheight/aspect + 0.5; |
201 |
> |
cwidth = cheight/aspect; |
202 |
|
} |
203 |
|
} |
204 |
|
if (xsiz % SSS) |
216 |
|
gettext(fp) /* get text from a file */ |
217 |
|
FILE *fp; |
218 |
|
{ |
224 |
– |
char *fgets(); |
219 |
|
char buf[MAXLINE]; |
220 |
|
register LINE *curl; |
221 |
|
int len; |
238 |
|
curl->s[len] = '\0'; |
239 |
|
if (spacing < -1./256.) |
240 |
|
len = squeeztext(curl->sp, curl->s, ourfont, |
241 |
< |
(int)(spacing*-256.0)); |
241 |
> |
(int)(spacing*-256.)); |
242 |
|
else if (spacing > 1./256.) |
243 |
|
len = proptext(curl->sp, curl->s, ourfont, |
244 |
< |
(int)(spacing*256.0), 3); |
244 |
> |
(int)(spacing*256.), 3); |
245 |
|
else |
246 |
|
len = uniftext(curl->sp, curl->s, ourfont); |
247 |
|
if (len > maxwidth) |
279 |
|
ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1)); |
280 |
|
if (ourtext->sp == NULL) |
281 |
|
goto memerr; |
282 |
< |
if (spacing < 0.0) |
282 |
> |
if (spacing < -1./256.) |
283 |
|
maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont, |
284 |
< |
(int)(spacing*-256.0)); |
285 |
< |
else if (spacing > 0.0) |
284 |
> |
(int)(spacing*-256.)); |
285 |
> |
else if (spacing > 1./256.) |
286 |
|
maxwidth = proptext(ourtext->sp, ourtext->s, ourfont, |
287 |
< |
(int)(spacing*256.0), 3); |
287 |
> |
(int)(spacing*256.), 3); |
288 |
|
else |
289 |
|
maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont); |
290 |
|
nlines = 1; |
402 |
|
{ |
403 |
|
COLR pixval[SSS*SSS+1]; /* possible pixel values */ |
404 |
|
COLOR ctmp0, ctmp1; |
405 |
< |
double d; |
405 |
> |
double d; |
406 |
|
COLR *scanout; |
407 |
|
int x, y; |
408 |
|
register int i, j; |