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 1.3 by greg, Thu May 30 08:22:52 1991 UTC vs.
Revision 2.3 by greg, Sat Jun 6 07:40:51 1992 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *      7/1/87
11   */
12  
13 < #include  <stdio.h>
13 > #include  "standard.h"
14  
15   #include  "color.h"
16  
17 + #include  "font.h"
18 +
19   #define  MAXLINE                512     /* longest allowable line */
20  
21 + #ifndef  DEFPATH
22 + #define  DEFPATH                ":/usr/local/lib/ray"
23 + #endif
24 + #ifndef  ULIBVAR
25 + #define  ULIBVAR                "RAYPATH"
26 + #endif
27 +
28   char  *fontfile = "helvet.fnt";         /* our font file */
29  
30   COLR  bgcolr = WHTCOLR;                 /* background color */
# Line 39 | Line 48 | int  xdim;                             /* size of horizontal scan (bytes) */
48  
49   typedef unsigned char  GLYPH;
50  
51 < GLYPH  *ourfont[128];                   /* our font */
51 > FONT  *ourfont;                         /* our font */
52  
53 + char  *libpath;                         /* library search path */
54 +
55   typedef struct line {
56          char  *s;               /* line w/o LF */
57          struct line  *next;     /* next line up */
# Line 49 | Line 60 | typedef struct line {
60   LINE  *ourtext;                         /* our text */
61   int  nlines, maxline;                   /* text dimensions */
62  
63 + extern char  *getenv();
64   extern char  *malloc(), *calloc();
53 extern FILE  *fropen();
65  
66  
67   main(argc, argv)
68   int  argc;
69   char  *argv[];
70   {
60        double  atof();
71          int  an;
72  
73          for (an = 1; an < argc && argv[an][0] == '-'; an++)
# Line 116 | Line 126 | unkopt:
126                                          /* create bit map */
127          makemap();
128                                          /* load font file */
129 <        loadfont();
129 >        if ((libpath = getenv(ULIBVAR)) == NULL)
130 >                libpath = DEFPATH;
131 >        ourfont = getfont(fontfile);
132                                          /* convert text to bitmap */
133          maptext();
134                                          /* print header */
# Line 149 | Line 161 | makemap()                      /* create the bit map */
161   }
162  
163  
152 loadfont()                      /* load the font file */
153 {
154        FILE  *fp;
155        char  *err;
156        int  gn, ngv, gv;
157        register GLYPH  *g;
158
159        if ((fp = fropen(fontfile)) == NULL) {
160                fprintf(stderr, "cannot find font file \"%s\"\n",
161                                fontfile);
162                exit(1);
163        }
164        while (fscanf(fp, "%d", &gn) == 1) {    /* get each glyph */
165                if (gn < 0 || gn > 127) {
166                        err = "illegal";
167                        goto fonterr;
168                }
169                if (ourfont[gn] != NULL) {
170                        err = "duplicate";
171                        goto fonterr;
172                }
173                if (fscanf(fp, "%d", &ngv) != 1 ||
174                                ngv < 0 || ngv > 255) {
175                        err = "bad # vertices for";
176                        goto fonterr;
177                }
178                g = (GLYPH *)malloc((2*ngv+1)*sizeof(GLYPH));
179                if (g == NULL)
180                        goto memerr;
181                ourfont[gn] = g;
182                *g++ = ngv;
183                ngv *= 2;
184                while (ngv--) {
185                        if (fscanf(fp, "%d", &gv) != 1 ||
186                                        gv < 0 || gv > 255) {
187                                err = "bad vertex for";
188                                goto fonterr;
189                        }
190                        *g++ = gv;
191                }
192        }
193        fclose(fp);
194        return;
195 fonterr:
196        fprintf(stderr, "%s character (%d) in font file \"%s\"\n",
197                        err, gn, fontfile);
198        exit(1);
199 memerr:
200        fprintf(stderr, "out of memory in loadfont\n");
201        exit(1);
202 }
203
204
164   gettext(fp)                     /* get text from a file */
165   FILE  *fp;
166   {
# Line 271 | Line 230 | maptext()                      /* map our text */
230  
231          for (l = 0, curl = ourtext; curl != NULL; l++, curl = curl->next)
232                  for (c = strlen(curl->s)-1; c >= 0; c--)
233 <                        mapglyph(ourfont[curl->s[c]], c, l);
233 >                        mapglyph(ourfont->fg[curl->s[c]&0xff], c, l);
234   }
235  
236  
237   mapglyph(gl, tx0, ty0)          /* convert a glyph */
238 < register GLYPH  *gl;
238 > GLYPH  *gl;
239   int  tx0, ty0;
240   {
241          int  n;
242 +        register GORD  *gp;
243          int  p0[2], p1[2];
244  
245          if (gl == NULL)
246                  return;
247  
248          tx0 <<= 8; ty0 <<= 8;
249 <        n = *gl++;
250 <        mapcoord(p0, gl[2*n-2]+tx0, gl[2*n-1]+ty0);
249 >        n = gl->nverts;
250 >        gp = gvlist(gl);
251 >        mapcoord(p0, gp[2*n-2]+tx0, gp[2*n-1]+ty0);
252          while (n--) {
253 <                mapcoord(p1, gl[0]+tx0, gl[1]+ty0);
253 >                mapcoord(p1, gp[0]+tx0, gp[1]+ty0);
254                  mapedge(p0[0], p0[1], p1[0]-p0[0], p1[1]-p0[1]);
255                  p0[0] = p1[0]; p0[1] = p1[1];
256 <                gl += 2;
256 >                gp += 2;
257          }
258   }
259  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines