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.2 by greg, Thu Dec 19 14:52:00 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)
# Line 115 | 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 148 | Line 161 | makemap()                      /* create the bit map */
161   }
162  
163  
151 loadfont()                      /* load the font file */
152 {
153        FILE  *fp;
154        char  *err;
155        int  gn, ngv, gv;
156        register GLYPH  *g;
157
158        if ((fp = fropen(fontfile)) == NULL) {
159                fprintf(stderr, "cannot find font file \"%s\"\n",
160                                fontfile);
161                exit(1);
162        }
163        while (fscanf(fp, "%d", &gn) == 1) {    /* get each glyph */
164                if (gn < 0 || gn > 127) {
165                        err = "illegal";
166                        goto fonterr;
167                }
168                if (ourfont[gn] != NULL) {
169                        err = "duplicate";
170                        goto fonterr;
171                }
172                if (fscanf(fp, "%d", &ngv) != 1 ||
173                                ngv < 0 || ngv > 255) {
174                        err = "bad # vertices for";
175                        goto fonterr;
176                }
177                g = (GLYPH *)malloc((2*ngv+1)*sizeof(GLYPH));
178                if (g == NULL)
179                        goto memerr;
180                ourfont[gn] = g;
181                *g++ = ngv;
182                ngv *= 2;
183                while (ngv--) {
184                        if (fscanf(fp, "%d", &gv) != 1 ||
185                                        gv < 0 || gv > 255) {
186                                err = "bad vertex for";
187                                goto fonterr;
188                        }
189                        *g++ = gv;
190                }
191        }
192        fclose(fp);
193        return;
194 fonterr:
195        fprintf(stderr, "%s character (%d) in font file \"%s\"\n",
196                        err, gn, fontfile);
197        exit(1);
198 memerr:
199        fprintf(stderr, "out of memory in loadfont\n");
200        exit(1);
201 }
202
203
164   gettext(fp)                     /* get text from a file */
165   FILE  *fp;
166   {
# Line 270 | 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