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 2.5 by greg, Fri Jun 19 14:20:22 1992 UTC vs.
Revision 2.14 by greg, Thu May 25 15:13:43 1995 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 77 | Line 77 | typedef struct {
77          TLINE  tl;                      /* line list */
78   }  TEXT;
79  
80 < extern char  *libpath;
80 > extern char  *getlibpath();
81  
82   extern char  *fgetword();
83  
# Line 109 | Line 109 | RAY  *r;
109                          sprintf(errmsg, "undefined modifier \"%s\"", modname);
110                          objerror(m, USER, errmsg);
111                  }
112 <                raytexture(r, omod);
113 <        } else if (m->otype == PAT_BTEXT) {
112 >                if (rayshade(r, omod)) {
113 >                        if (m->omod != OVOID)
114 >                                objerror(m, USER, "inappropriate modifier");
115 >                        return(1);
116 >                }
117 >        }
118 >        if (m->otype == PAT_BTEXT) {
119                  if (foreground)
120                          scalecolor(r->pcol, m->oargs.farg[9]);
121                  else
# Line 127 | Line 132 | RAY  *r;
132                                          m->oargs.farg[14]);
133                  multcolor(r->pcol, cval);
134          }
135 +        return(0);
136   }
137  
138  
# Line 142 | Line 148 | char  *s;
148          if ((tl=(TLINE *)malloc(sizeof(TLINE)+siz)) == NULL ||
149                          (tl->spc=(short *)malloc(siz*sizeof(short))) == NULL)
150                  error(SYSTEM, "out of memory in tlalloc");
145        tl->spc = NULL;
151          tl->next = NULL;
152          strcpy(TLSTR(tl), s);
153          return(tl);
# Line 155 | Line 160 | register OBJREC  *tm;
160   {
161   #define  R      (tm->oargs.farg+3)
162   #define  D      (tm->oargs.farg+6)
163 <        extern char  *strcpy(), *fgets();
163 >        extern char  *strcpy();
164          FVECT  DxR;
165          double  d;
166          FILE  *fp;
# Line 171 | Line 176 | register OBJREC  *tm;
176          if (tm->oargs.nsargs - tndx(tm) < 1 || tm->oargs.nfargs < sndx(tm))
177                  objerror(tm, USER, "bad # arguments");
178          if ((t = (TEXT *)malloc(sizeof(TEXT))) == NULL)
179 <                goto memerr;
179 >                error(SYSTEM, "out of memory in gettext");
180                                                  /* compute vectors */
181          fcross(DxR, D, R);
182          fcross(t->right, DxR, D);
# Line 196 | Line 201 | register OBJREC  *tm;
201                  tlp = tlp->next;
202          } else {                                /* text file */
203                  if ((s = getpath(tm->oargs.sarg[tndx(tm)],
204 <                                libpath, R_OK)) == NULL) {
204 >                                getlibpath(), R_OK)) == NULL) {
205                          sprintf(errmsg, "cannot find text file \"%s\"",
206                                          tm->oargs.sarg[tndx(tm)]);
207                          error(USER, errmsg);
# Line 220 | Line 225 | register OBJREC  *tm;
225                                                  /* compute character spacing */
226          i = sndx(tm);
227          d = i < tm->oargs.nfargs ? tm->oargs.farg[i] : 0.0;
228 <        i = d * 256.0;
228 >        i = d * 255.0;
229 >        t->tl.width = 0;
230          for (tlp = t->tl.next; tlp != NULL; tlp = tlp->next) {
225                if ((tlp->spc = (short *)malloc(
226                                (strlen(TLSTR(tlp))+1)*sizeof(short))) == NULL)
227                        goto memerr;
231                  if (i < 0)
232                          tlp->width = squeeztext(tlp->spc, TLSTR(tlp), t->f, -i);
233                  else if (i > 0)
234                          tlp->width = proptext(tlp->spc, TLSTR(tlp), t->f, i, 3);
235                  else
236                          tlp->width = uniftext(tlp->spc, TLSTR(tlp), t->f);
237 +                if (tlp->width > t->tl.width)
238 +                        t->tl.width = tlp->width;
239          }
240                                                  /* we're done */
241          tm->os = (char *)t;
242          return(t);
238 memerr:
239        error(SYSTEM, "out of memory in gettext");
243   #undef  R
244   #undef  D
245   }
# Line 251 | Line 254 | OBJREC  *m;
254          tp = (TEXT *)m->os;
255          if (tp == NULL)
256                  return;
257 <        for (tlp = tp->tl.next; tlp != NULL; tlp = tlp->next) {
257 >        while ((tlp = tp->tl.next) != NULL) {
258 >                tp->tl.next = tlp->next;
259                  free((char *)tlp->spc);
260                  free((char *)tlp);
261          }
# Line 274 | Line 278 | OBJREC  *m;
278          v[0] = p[0] - m->oargs.farg[0];
279          v[1] = p[1] - m->oargs.farg[1];
280          v[2] = p[2] - m->oargs.farg[2];
281 <        h = x = DOT(v, tp->right)*256.;
281 >        x = DOT(v, tp->right);
282 >        i = sndx(m);
283 >        if (i < m->oargs.nfargs)
284 >                x *= tp->f->mwidth + 255.*fabs(m->oargs.farg[i]);
285 >        else
286 >                x *= 255.;
287 >        h = x;
288          i = y = DOT(v, tp->down);
289          if (x < 0.0 || y < 0.0)
290                  return(0);
291          x -= (double)h;
292 <        y = ((i+1) - y)*256.;
292 >        y = ((i+1) - y)*255.;
293                                  /* find the line position */
294          for (tlp = tp->tl.next; tlp != NULL; tlp = tlp->next)
295                  if (--i < 0)
# Line 287 | Line 297 | OBJREC  *m;
297          if (tlp == NULL || h >= tlp->width)
298                  return(0);
299          for (i = 0; (h -= tlp->spc[i]) >= 0; i++)
300 <                if (h < 256 && inglyph(h+x, y,
300 >                if (h < 255 && inglyph(h+x, y,
301                                  tp->f->fg[TLSTR(tlp)[i]&0xff]))
302                          return(1);
303          return(0);
# Line 295 | Line 305 | OBJREC  *m;
305  
306  
307   inglyph(x, y, gl)               /* (x,y) within font glyph gl? */
308 < double  x, y;           /* real coordinates in range [0,256) */
308 > double  x, y;           /* real coordinates in range [0,255) */
309   register GLYPH  *gl;
310   {
311          int  n, ncross;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines