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.11 by greg, Wed Jul 8 13:58:10 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 38 | Line 38 | int  direct = 'r';                     /* direction (right, up, left, do
38  
39   int  cheight = 32*SSS;                  /* character height */
40   double  aspect = 1.67;                  /* height/width character aspect */
41 + double  spacing = 0.0;                  /* character spacing */
42   int  cwidth;                            /* computed character width */
43  
44   unsigned char  *ourbitmap;              /* our output bitmap */
# Line 65 | Line 66 | int  nlines, maxline;                  /* text dimensions */
66   int  maxwidth;                          /* maximum line width (dvi) */
67  
68   extern char  *getenv();
68 extern char  *malloc(), *calloc();
69  
70  
71   main(argc, argv)
# Line 109 | Line 109 | char  *argv[];
109                                  goto unkopt;
110                          }
111                          break;
112 +                case 'x':                       /* x resolution */
113 +                        xsiz = atoi(argv[++an])*SSS;
114 +                        break;
115 +                case 'y':
116 +                        ysiz = atoi(argv[++an])*SSS;
117 +                        break;
118                  case 'h':                       /* height of characters */
119                          cheight = atoi(argv[++an])*SSS;
120                          break;
121                  case 'a':                       /* aspect ratio */
122                          aspect = atof(argv[++an]);
123                          break;
124 +                case 's':                       /* spacing */
125 +                        spacing = atof(argv[++an]);
126 +                        break;
127                  default:;
128   unkopt:
129                          fprintf(stderr, "%s: unknown option: %s\n",
# Line 148 | Line 157 | unkopt:
157  
158   makemap()                       /* create the bit map */
159   {
160 <        cwidth = cheight/aspect + 0.5;
160 >        double  pictaspect;
161 >        
162          if (direct == 'r' || direct == 'l') {
163 <                xsiz = (long)maxwidth*cwidth >> 8;
164 <                ysiz = nlines*cheight;
163 >                if (xsiz <= 0) {
164 >                        cwidth = cheight/aspect + 0.5;
165 >                        xsiz = (long)maxwidth*cwidth >> 8;
166 >                        ysiz = nlines*cheight;
167 >                } else if (aspect > FTINY) {
168 >                        if (ysiz <= 0)
169 >                                ysiz = cheight*nlines;
170 >                        pictaspect = 256*nlines*aspect/maxwidth;
171 >                        if (pictaspect*xsiz < ysiz)
172 >                                ysiz = pictaspect*xsiz + 0.5;
173 >                        else
174 >                                xsiz = ysiz/pictaspect + 0.5;
175 >                        cheight = ysiz/nlines;
176 >                        cwidth = cheight/aspect + 0.5;
177 >                } else {
178 >                        if (ysiz <= 0)
179 >                                ysiz = cheight*nlines;
180 >                        pictaspect = (double)ysiz/xsiz;
181 >                        aspect = pictaspect*maxwidth/(256*nlines);
182 >                        cheight = ysiz/nlines;
183 >                        cwidth = cheight/aspect + 0.5;
184 >                }
185          } else {                        /* reverse orientation */
186 <                xsiz = nlines*cheight;
187 <                ysiz = (long)maxwidth*cwidth >> 8;
186 >                if (ysiz <= 0) {
187 >                        cwidth = cheight/aspect + 0.5;
188 >                        xsiz = nlines*cheight;
189 >                        ysiz = (long)maxwidth*cwidth >> 8;
190 >                } else if (aspect > FTINY) {
191 >                        if (xsiz <= 0)
192 >                                xsiz = cheight*nlines;
193 >                        pictaspect = maxwidth/(256*nlines*aspect);
194 >                        if (pictaspect*xsiz < ysiz)
195 >                                ysiz = pictaspect*xsiz + 0.5;
196 >                        else
197 >                                xsiz = ysiz/pictaspect + 0.5;
198 >                        cheight = xsiz/nlines;
199 >                        cwidth = cheight/aspect + 0.5;
200 >                } else {
201 >                        if (xsiz <= 0)
202 >                                xsiz = cheight*nlines;
203 >                        pictaspect = (double)ysiz/xsiz;
204 >                        aspect = maxwidth/(256*nlines*pictaspect);
205 >                        cheight = xsiz/nlines;
206 >                        cwidth = cheight/aspect + 0.5;
207 >                }
208          }
209          if (xsiz % SSS)
210                  xsiz += SSS - xsiz%SSS;
211          if (ysiz % SSS)
212                  ysiz += SSS - ysiz%SSS;
213          xdim = (xsiz+7)/8;
214 <        ourbitmap = (BYTE *)calloc(ysiz, xdim);
214 >        ourbitmap = (BYTE *)bmalloc(ysiz*xdim);
215          if (ourbitmap == NULL)
216                  error(SYSTEM, "Out of memory in makemap");
217 +        bzero((char *)ourbitmap, ysiz*xdim);
218   }
219  
220  
# Line 191 | Line 242 | FILE  *fp;
242                          maxline = len;
243                  strncpy(curl->s, buf, len);
244                  curl->s[len] = '\0';
245 < len = uniftext(curl->sp, curl->s, ourfont);
245 >                if (spacing < -1./256.)
246 >                        len = squeeztext(curl->sp, curl->s, ourfont,
247 >                                        (int)(spacing*-256.0));
248 >                else if (spacing > 1./256.)
249 >                        len = proptext(curl->sp, curl->s, ourfont,
250 >                                        (int)(spacing*256.0), 3);
251 >                else
252 >                        len = uniftext(curl->sp, curl->s, ourfont);
253                  if (len > maxwidth)
254                          maxwidth = len;
255                  curl->next = ourtext;
# Line 227 | Line 285 | char  *av[];
285          ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1));
286          if (ourtext->sp == NULL)
287                  goto memerr;
288 < maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont, 50);
288 >        if (spacing < 0.0)
289 >                maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont,
290 >                                (int)(spacing*-256.0));
291 >        else if (spacing > 0.0)
292 >                maxwidth = proptext(ourtext->sp, ourtext->s, ourfont,
293 >                                (int)(spacing*256.0), 3);
294 >        else
295 >                maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont);
296          nlines = 1;
297          return;
298   memerr:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines