ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/psign.c
(Generate patch)

Comparing ray/src/px/psign.c (file contents):
Revision 2.5 by greg, Tue Jun 16 16:27:37 1992 UTC vs.
Revision 2.12 by greg, Tue Sep 8 10:35:08 1992 UTC

# Line 1 | Line 1
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";
# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "font.h"
18  
19 + #include  "paths.h"
20 +
21   #ifndef  SSS
22   #define  SSS                    3       /* super-sample size */
23   #endif
24  
25   #define  MAXLINE                512     /* longest allowable line */
26  
25 #ifndef  DEFPATH
26 #define  DEFPATH                ":/usr/local/lib/ray"
27 #endif
28 #ifndef  ULIBVAR
29 #define  ULIBVAR                "RAYPATH"
30 #endif
31
27   char  *fontfile = "helvet.fnt";         /* our font file */
28  
29   COLOR  bgcolor = WHTCOLOR;              /* background color */
# Line 38 | Line 33 | int  direct = 'r';                     /* direction (right, up, left, do
33  
34   int  cheight = 32*SSS;                  /* character height */
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 */
# Line 64 | Line 60 | LINE  *ourtext;                                /* our text */
60   int  nlines, maxline;                   /* text dimensions */
61   int  maxwidth;                          /* maximum line width (dvi) */
62  
67 extern char  *getenv();
68 extern char  *malloc(), *calloc();
63  
70
64   main(argc, argv)
65   int  argc;
66   char  *argv[];
# Line 109 | Line 102 | char  *argv[];
102                                  goto unkopt;
103                          }
104                          break;
105 +                case 'x':                       /* x resolution */
106 +                        xsiz = atoi(argv[++an])*SSS;
107 +                        break;
108 +                case 'y':
109 +                        ysiz = atoi(argv[++an])*SSS;
110 +                        break;
111                  case 'h':                       /* height of characters */
112                          cheight = atoi(argv[++an])*SSS;
113                          break;
114                  case 'a':                       /* aspect ratio */
115                          aspect = atof(argv[++an]);
116                          break;
117 +                case 's':                       /* spacing */
118 +                        spacing = atof(argv[++an]);
119 +                        break;
120                  default:;
121   unkopt:
122                          fprintf(stderr, "%s: unknown option: %s\n",
# Line 148 | Line 150 | unkopt:
150  
151   makemap()                       /* create the bit map */
152   {
153 <        cwidth = cheight/aspect + 0.5;
153 >        double  pictaspect;
154 >        
155          if (direct == 'r' || direct == 'l') {
156 <                xsiz = (long)maxwidth*cwidth >> 8;
157 <                ysiz = nlines*cheight;
156 >                if (xsiz <= 0) {
157 >                        cwidth = cheight/aspect + 0.5;
158 >                        xsiz = (long)maxwidth*cwidth >> 8;
159 >                        ysiz = nlines*cheight;
160 >                } else if (aspect > FTINY) {
161 >                        if (ysiz <= 0)
162 >                                ysiz = cheight*nlines;
163 >                        pictaspect = 256*nlines*aspect/maxwidth;
164 >                        if (pictaspect*xsiz < ysiz)
165 >                                ysiz = pictaspect*xsiz + 0.5;
166 >                        else
167 >                                xsiz = ysiz/pictaspect + 0.5;
168 >                        cheight = ysiz/nlines;
169 >                        cwidth = cheight/aspect + 0.5;
170 >                } else {
171 >                        if (ysiz <= 0)
172 >                                ysiz = cheight*nlines;
173 >                        pictaspect = (double)ysiz/xsiz;
174 >                        aspect = pictaspect*maxwidth/(256*nlines);
175 >                        cheight = ysiz/nlines;
176 >                        cwidth = cheight/aspect + 0.5;
177 >                }
178          } else {                        /* reverse orientation */
179 <                xsiz = nlines*cheight;
180 <                ysiz = (long)maxwidth*cwidth >> 8;
179 >                if (ysiz <= 0) {
180 >                        cwidth = cheight/aspect + 0.5;
181 >                        xsiz = nlines*cheight;
182 >                        ysiz = (long)maxwidth*cwidth >> 8;
183 >                } else if (aspect > FTINY) {
184 >                        if (xsiz <= 0)
185 >                                xsiz = cheight*nlines;
186 >                        pictaspect = maxwidth/(256*nlines*aspect);
187 >                        if (pictaspect*xsiz < ysiz)
188 >                                ysiz = pictaspect*xsiz + 0.5;
189 >                        else
190 >                                xsiz = ysiz/pictaspect + 0.5;
191 >                        cheight = xsiz/nlines;
192 >                        cwidth = cheight/aspect + 0.5;
193 >                } else {
194 >                        if (xsiz <= 0)
195 >                                xsiz = cheight*nlines;
196 >                        pictaspect = (double)ysiz/xsiz;
197 >                        aspect = maxwidth/(256*nlines*pictaspect);
198 >                        cheight = xsiz/nlines;
199 >                        cwidth = cheight/aspect + 0.5;
200 >                }
201          }
202          if (xsiz % SSS)
203                  xsiz += SSS - xsiz%SSS;
204          if (ysiz % SSS)
205                  ysiz += SSS - ysiz%SSS;
206          xdim = (xsiz+7)/8;
207 <        ourbitmap = (BYTE *)calloc(ysiz, xdim);
207 >        ourbitmap = (BYTE *)bmalloc(ysiz*xdim);
208          if (ourbitmap == NULL)
209                  error(SYSTEM, "Out of memory in makemap");
210 +        bzero((char *)ourbitmap, ysiz*xdim);
211   }
212  
213  
# Line 191 | Line 235 | FILE  *fp;
235                          maxline = len;
236                  strncpy(curl->s, buf, len);
237                  curl->s[len] = '\0';
238 < len = uniftext(curl->sp, curl->s, ourfont);
238 >                if (spacing < -1./256.)
239 >                        len = squeeztext(curl->sp, curl->s, ourfont,
240 >                                        (int)(spacing*-256.0));
241 >                else if (spacing > 1./256.)
242 >                        len = proptext(curl->sp, curl->s, ourfont,
243 >                                        (int)(spacing*256.0), 3);
244 >                else
245 >                        len = uniftext(curl->sp, curl->s, ourfont);
246                  if (len > maxwidth)
247                          maxwidth = len;
248                  curl->next = ourtext;
# Line 227 | Line 278 | char  *av[];
278          ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1));
279          if (ourtext->sp == NULL)
280                  goto memerr;
281 < maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont, 50);
281 >        if (spacing < 0.0)
282 >                maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont,
283 >                                (int)(spacing*-256.0));
284 >        else if (spacing > 0.0)
285 >                maxwidth = proptext(ourtext->sp, ourtext->s, ourfont,
286 >                                (int)(spacing*256.0), 3);
287 >        else
288 >                maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont);
289          nlines = 1;
290          return;
291   memerr:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines