--- ray/src/px/psign.c 1992/06/16 16:48:39 2.6 +++ ray/src/px/psign.c 1992/07/08 13:58:10 2.11 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -66,7 +66,6 @@ int nlines, maxline; /* text dimensions */ int maxwidth; /* maximum line width (dvi) */ extern char *getenv(); -extern char *malloc(), *calloc(); main(argc, argv) @@ -110,6 +109,12 @@ char *argv[]; goto unkopt; } break; + case 'x': /* x resolution */ + xsiz = atoi(argv[++an])*SSS; + break; + case 'y': + ysiz = atoi(argv[++an])*SSS; + break; case 'h': /* height of characters */ cheight = atoi(argv[++an])*SSS; break; @@ -152,22 +157,64 @@ unkopt: makemap() /* create the bit map */ { - cwidth = cheight/aspect + 0.5; + double pictaspect; + if (direct == 'r' || direct == 'l') { - xsiz = (long)maxwidth*cwidth >> 8; - ysiz = nlines*cheight; + if (xsiz <= 0) { + cwidth = cheight/aspect + 0.5; + xsiz = (long)maxwidth*cwidth >> 8; + ysiz = nlines*cheight; + } else if (aspect > FTINY) { + if (ysiz <= 0) + ysiz = cheight*nlines; + pictaspect = 256*nlines*aspect/maxwidth; + if (pictaspect*xsiz < ysiz) + ysiz = pictaspect*xsiz + 0.5; + else + xsiz = ysiz/pictaspect + 0.5; + cheight = ysiz/nlines; + cwidth = cheight/aspect + 0.5; + } else { + if (ysiz <= 0) + ysiz = cheight*nlines; + pictaspect = (double)ysiz/xsiz; + aspect = pictaspect*maxwidth/(256*nlines); + cheight = ysiz/nlines; + cwidth = cheight/aspect + 0.5; + } } else { /* reverse orientation */ - xsiz = nlines*cheight; - ysiz = (long)maxwidth*cwidth >> 8; + if (ysiz <= 0) { + cwidth = cheight/aspect + 0.5; + xsiz = nlines*cheight; + ysiz = (long)maxwidth*cwidth >> 8; + } else if (aspect > FTINY) { + if (xsiz <= 0) + xsiz = cheight*nlines; + pictaspect = maxwidth/(256*nlines*aspect); + if (pictaspect*xsiz < ysiz) + ysiz = pictaspect*xsiz + 0.5; + else + xsiz = ysiz/pictaspect + 0.5; + cheight = xsiz/nlines; + cwidth = cheight/aspect + 0.5; + } else { + if (xsiz <= 0) + xsiz = cheight*nlines; + pictaspect = (double)ysiz/xsiz; + aspect = maxwidth/(256*nlines*pictaspect); + cheight = xsiz/nlines; + cwidth = cheight/aspect + 0.5; + } } if (xsiz % SSS) xsiz += SSS - xsiz%SSS; if (ysiz % SSS) ysiz += SSS - ysiz%SSS; xdim = (xsiz+7)/8; - ourbitmap = (BYTE *)calloc(ysiz, xdim); + ourbitmap = (BYTE *)bmalloc(ysiz*xdim); if (ourbitmap == NULL) error(SYSTEM, "Out of memory in makemap"); + bzero((char *)ourbitmap, ysiz*xdim); } @@ -195,10 +242,10 @@ FILE *fp; maxline = len; strncpy(curl->s, buf, len); curl->s[len] = '\0'; - if (spacing < 0.0) + if (spacing < -1./256.) len = squeeztext(curl->sp, curl->s, ourfont, (int)(spacing*-256.0)); - else if (spacing > 0.0) + else if (spacing > 1./256.) len = proptext(curl->sp, curl->s, ourfont, (int)(spacing*256.0), 3); else