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.10 by greg, Tue Jul 7 18:24:34 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 +                        xsiz = xsiz = 0;
121                          break;
122                  case 'a':                       /* aspect ratio */
123                          aspect = atof(argv[++an]);
124                          break;
125 +                case 's':                       /* spacing */
126 +                        spacing = atof(argv[++an]);
127 +                        break;
128                  default:;
129   unkopt:
130                          fprintf(stderr, "%s: unknown option: %s\n",
# Line 148 | Line 158 | unkopt:
158  
159   makemap()                       /* create the bit map */
160   {
161 <        cwidth = cheight/aspect + 0.5;
161 >        double  pictaspect;
162 >        
163          if (direct == 'r' || direct == 'l') {
164 <                xsiz = (long)maxwidth*cwidth >> 8;
165 <                ysiz = nlines*cheight;
164 >                if (xsiz == 0 || ysiz == 0) {
165 >                        cwidth = cheight/aspect + 0.5;
166 >                        xsiz = (long)maxwidth*cwidth >> 8;
167 >                        ysiz = nlines*cheight;
168 >                } else if (aspect > FTINY) {
169 >                        pictaspect = 256*nlines*aspect/maxwidth;
170 >                        if (pictaspect*xsiz < ysiz)
171 >                                ysiz = pictaspect*xsiz + 0.5;
172 >                        else
173 >                                xsiz = ysiz/pictaspect + 0.5;
174 >                        cheight = ysiz/nlines;
175 >                        cwidth = cheight/aspect + 0.5;
176 >                } else {
177 >                        pictaspect = (double)ysiz/xsiz;
178 >                        aspect = pictaspect*maxwidth/(256*nlines);
179 >                        cheight = ysiz/nlines;
180 >                        cwidth = cheight/aspect + 0.5;
181 >                }
182          } else {                        /* reverse orientation */
183 <                xsiz = nlines*cheight;
184 <                ysiz = (long)maxwidth*cwidth >> 8;
183 >                if (xsiz == 0 || ysiz == 0) {
184 >                        cwidth = cheight/aspect + 0.5;
185 >                        xsiz = nlines*cheight;
186 >                        ysiz = (long)maxwidth*cwidth >> 8;
187 >                } else if (aspect > FTINY) {
188 >                        pictaspect = maxwidth/(256*nlines*aspect);
189 >                        if (pictaspect*xsiz < ysiz)
190 >                                ysiz = pictaspect*xsiz + 0.5;
191 >                        else
192 >                                xsiz = ysiz/pictaspect + 0.5;
193 >                        cheight = xsiz/nlines;
194 >                        cwidth = cheight/aspect + 0.5;
195 >                } else {
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