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

Comparing ray/src/rt/text.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:41:47 1989 UTC vs.
Revision 1.6 by greg, Mon Jul 22 13:02:27 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1990 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 65 | Line 65 | typedef struct font {
65          struct font  *next;             /* next font in list */
66   }  FONT;
67  
68 + extern char  *fgetword();
69 +
70   extern GLYPH  *getglyph();
71  
72   extern FONT  *getfont();
# Line 89 | Line 91 | RAY  *r;
91  
92                                  /* first, discover position in text */
93          ap = m->oargs.farg;
94 <        v[0] = r->rop[0] - ap[0];
95 <        v[1] = r->rop[1] - ap[1];
96 <        v[2] = r->rop[2] - ap[2];
94 >        if (r->rox != NULL)
95 >                multp3(v, r->rop, r->rox->b.xfm);
96 >        else
97 >                VCOPY(v, r->rop);
98 >        v[0] -= ap[0];
99 >        v[1] -= ap[1];
100 >        v[2] -= ap[2];
101          col = x = DOT(v, ap+3) / DOT(ap+3, ap+3);
102          lno = y = DOT(v, ap+6) / DOT(ap+6, ap+6);
103          x -= col;
# Line 159 | Line 165 | int  col;
165                          txt[1] = NULL;
166                  } else {                                /* text file */
167                          if ((s = getpath(tm->oargs.sarg[tndx(tm)],
168 <                                        libpath)) == NULL) {
168 >                                        libpath, R_OK)) == NULL) {
169                                  sprintf(errmsg, "cannot find text file \"%s\"",
170                                                  tm->oargs.sarg[tndx(tm)]);
171                                  error(USER, errmsg);
# Line 200 | Line 206 | FONT *
206   getfont(fname)                          /* return font fname */
207   char  *fname;
208   {
209 +        char  buf[16];
210          FILE  *fp;
211          char  *pathname, *err;
212          int  gn, ngv, gv;
# Line 210 | Line 217 | char  *fname;
217                  if (!strcmp(f->name, fname))
218                          return(f);
219                                                  /* load the font file */
220 <        if ((pathname = getpath(fname, libpath)) == NULL) {
220 >        if ((pathname = getpath(fname, libpath, R_OK)) == NULL) {
221                  sprintf(errmsg, "cannot find font file \"%s\"", fname);
222                  error(USER, errmsg);
223          }
# Line 223 | Line 230 | char  *fname;
230                                  pathname);
231                  error(SYSTEM, errmsg);
232          }
233 <        while (fscanf(fp, "%d", &gn) == 1) {    /* get each glyph */
233 >        while (fgetword(buf,sizeof(buf),fp) != NULL) {  /* get each glyph */
234 >                if (!isint(buf))
235 >                        goto nonint;
236 >                gn = atoi(buf);
237                  if (gn < 0 || gn > 255) {
238                          err = "illegal";
239                          goto fonterr;
# Line 232 | Line 242 | char  *fname;
242                          err = "duplicate";
243                          goto fonterr;
244                  }
245 <                if (fscanf(fp, "%d", &ngv) != 1 ||
246 <                                ngv < 0 || ngv > 255) {
245 >                if (fgetword(buf,sizeof(buf),fp) == NULL || !isint(buf) ||
246 >                                (ngv = atoi(buf)) < 0 || ngv > 255) {
247                          err = "bad # vertices for";
248                          goto fonterr;
249                  }
# Line 244 | Line 254 | char  *fname;
254                  *g++ = ngv;
255                  ngv *= 2;
256                  while (ngv--) {
257 <                        if (fscanf(fp, "%d", &gv) != 1 ||
258 <                                        gv < 0 || gv > 255) {
257 >                        if (fgetword(buf,sizeof(buf),fp) == NULL ||
258 >                                        !isint(buf) ||
259 >                                        (gv = atoi(buf)) < 0 || gv > 255) {
260                                  err = "bad vertex for";
261                                  goto fonterr;
262                          }
# Line 255 | Line 266 | char  *fname;
266          fclose(fp);
267          f->next = fontlist;
268          return(fontlist = f);
269 + nonint:
270 +        sprintf(errmsg, "non-integer in font file \"%s\"", pathname);
271 +        error(USER, errmsg);
272   fonterr:
273          sprintf(errmsg, "%s character (%d) in font file \"%s\"",
274                          err, gn, pathname);
# Line 274 | Line 288 | GLYPH  *gl;
288  
289          if (x < 0.0 || y < 0.0)
290                  return(0);
291 <        xlb = x *= 255.0;               /* get glyph coordinates */
292 <        ylb = y *= 255.0;
291 >        x *= 256.0;                     /* get glyph coordinates */
292 >        y *= 256.0;
293 >        xlb = x + 0.5;
294 >        ylb = y + 0.5;
295          n = *gl++;                      /* get # of vertices */
296          p0 = gl + 2*(n-1);              /* connect last to first */
297          p1 = gl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines