--- ray/src/px/psign.c 1992/09/08 10:35:08 2.12 +++ ray/src/px/psign.c 2003/06/05 19:29:34 2.19 @@ -1,9 +1,6 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: psign.c,v 2.19 2003/06/05 19:29:34 schorsch Exp $"; #endif - /* * psign.c - produce picture from text. * @@ -11,18 +8,14 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include "standard.h" - #include "color.h" - #include "font.h" -#include "paths.h" - -#ifndef SSS -#define SSS 3 /* super-sample size */ +#ifndef SSS +#define SSS 3 /* super-sample size */ #endif -#define MAXLINE 512 /* longest allowable line */ +#define MAXLINE 512 /* longest allowable line */ char *fontfile = "helvet.fnt"; /* our font file */ @@ -32,24 +25,22 @@ COLOR fgcolor = BLKCOLOR; /* foreground color */ int direct = 'r'; /* direction (right, up, left, down) */ int cheight = 32*SSS; /* character height */ -double aspect = 1.67; /* height/width character aspect */ -double spacing = 0.0; /* character spacing */ +double aspect = 1.67; /* height/width character aspect */ +double spacing = 0.0; /* character spacing */ int cwidth; /* computed character width */ unsigned char *ourbitmap; /* our output bitmap */ int xsiz, ysiz; /* bitmap dimensions */ int xdim; /* size of horizontal scan (bytes) */ -#define bitop(x,y,op) (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7))) -#define tstbit(x,y) bitop(x,y,&) -#define setbit(x,y) bitop(x,y,|=) -#define clrbit(x,y) bitop(x,y,&=~) -#define tglbit(x,y) bitop(x,y,^=) +#define bitop(x,y,op) (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7))) +#define tstbit(x,y) bitop(x,y,&) +#define setbit(x,y) bitop(x,y,|=) +#define clrbit(x,y) bitop(x,y,&=~) +#define tglbit(x,y) bitop(x,y,^=) FONT *ourfont; /* our font */ -char *libpath; /* library search path */ - typedef struct line { char *s; /* line w/o LF */ short *sp; /* character spacing */ @@ -66,7 +57,7 @@ int argc; char *argv[]; { int an; - + SET_FILE_BINARY(stdout); for (an = 1; an < argc && argv[an][0] == '-'; an++) switch (argv[an][1]) { case 'c': /* color */ @@ -124,8 +115,6 @@ unkopt: exit(1); } /* load font file */ - if ((libpath = getenv(ULIBVAR)) == NULL) - libpath = DEFPATH; ourfont = getfont(fontfile); /* get text */ if (an == argc) @@ -138,6 +127,7 @@ unkopt: /* convert text to bitmap */ maptext(); /* print header */ + newheader("RADIANCE", stdout); printargs(argc, argv, stdout); fputformat(COLRFMT, stdout); putchar('\n'); @@ -150,7 +140,7 @@ unkopt: makemap() /* create the bit map */ { - double pictaspect; + double pictaspect; if (direct == 'r' || direct == 'l') { if (xsiz <= 0) { @@ -166,14 +156,14 @@ makemap() /* create the bit map */ else xsiz = ysiz/pictaspect + 0.5; cheight = ysiz/nlines; - cwidth = cheight/aspect + 0.5; + cwidth = cheight/aspect; } else { if (ysiz <= 0) ysiz = cheight*nlines; pictaspect = (double)ysiz/xsiz; aspect = pictaspect*maxwidth/(256*nlines); cheight = ysiz/nlines; - cwidth = cheight/aspect + 0.5; + cwidth = cheight/aspect; } } else { /* reverse orientation */ if (ysiz <= 0) { @@ -189,14 +179,14 @@ makemap() /* create the bit map */ else xsiz = ysiz/pictaspect + 0.5; cheight = xsiz/nlines; - cwidth = cheight/aspect + 0.5; + cwidth = cheight/aspect; } else { if (xsiz <= 0) xsiz = cheight*nlines; pictaspect = (double)ysiz/xsiz; aspect = maxwidth/(256*nlines*pictaspect); cheight = xsiz/nlines; - cwidth = cheight/aspect + 0.5; + cwidth = cheight/aspect; } } if (xsiz % SSS) @@ -214,7 +204,6 @@ makemap() /* create the bit map */ gettext(fp) /* get text from a file */ FILE *fp; { - char *fgets(); char buf[MAXLINE]; register LINE *curl; int len; @@ -227,7 +216,7 @@ FILE *fp; if (curl == NULL) goto memerr; len = strlen(buf); - curl->s = malloc(len); + curl->s = (char *)malloc(len); curl->sp = (short *)malloc(sizeof(short)*len--); if (curl->s == NULL | curl->sp == NULL) goto memerr; @@ -237,10 +226,10 @@ FILE *fp; curl->s[len] = '\0'; if (spacing < -1./256.) len = squeeztext(curl->sp, curl->s, ourfont, - (int)(spacing*-256.0)); + (int)(spacing*-256.)); else if (spacing > 1./256.) len = proptext(curl->sp, curl->s, ourfont, - (int)(spacing*256.0), 3); + (int)(spacing*256.), 3); else len = uniftext(curl->sp, curl->s, ourfont); if (len > maxwidth) @@ -264,7 +253,7 @@ char *av[]; ourtext = (LINE *)malloc(sizeof(LINE)); if (ourtext == NULL) goto memerr; - ourtext->s = malloc(MAXLINE); + ourtext->s = (char *)malloc(MAXLINE); if (ourtext->s == NULL) goto memerr; for (cp = ourtext->s; ac-- > 0; av++) { @@ -278,12 +267,12 @@ char *av[]; ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1)); if (ourtext->sp == NULL) goto memerr; - if (spacing < 0.0) + if (spacing < -1./256.) maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont, - (int)(spacing*-256.0)); - else if (spacing > 0.0) + (int)(spacing*-256.)); + else if (spacing > 1./256.) maxwidth = proptext(ourtext->sp, ourtext->s, ourfont, - (int)(spacing*256.0), 3); + (int)(spacing*256.), 3); else maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont); nlines = 1; @@ -401,7 +390,7 @@ FILE *fp; { COLR pixval[SSS*SSS+1]; /* possible pixel values */ COLOR ctmp0, ctmp1; - double d; + double d; COLR *scanout; int x, y; register int i, j; @@ -442,5 +431,5 @@ FILE *fp; exit(1); } } - free((char *)scanout); + free((void *)scanout); }