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.20 by greg, Sat Feb 22 02:07:29 2003 UTC vs.
Revision 2.28 by greg, Fri Nov 19 22:51:31 2021 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   *  text.c - functions for text patterns and mixtures.
6   */
7  
8 < /* ====================================================================
9 < * The Radiance Software License, Version 1.0
10 < *
11 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 < *
14 < * Redistribution and use in source and binary forms, with or without
15 < * modification, are permitted provided that the following conditions
16 < * are met:
17 < *
18 < * 1. Redistributions of source code must retain the above copyright
19 < *         notice, this list of conditions and the following disclaimer.
20 < *
21 < * 2. Redistributions in binary form must reproduce the above copyright
22 < *       notice, this list of conditions and the following disclaimer in
23 < *       the documentation and/or other materials provided with the
24 < *       distribution.
25 < *
26 < * 3. The end-user documentation included with the redistribution,
27 < *           if any, must include the following acknowledgment:
28 < *             "This product includes Radiance software
29 < *                 (http://radsite.lbl.gov/)
30 < *                 developed by the Lawrence Berkeley National Laboratory
31 < *               (http://www.lbl.gov/)."
32 < *       Alternately, this acknowledgment may appear in the software itself,
33 < *       if and wherever such third-party acknowledgments normally appear.
34 < *
35 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
36 < *       and "The Regents of the University of California" must
37 < *       not be used to endorse or promote products derived from this
38 < *       software without prior written permission. For written
39 < *       permission, please contact [email protected].
40 < *
41 < * 5. Products derived from this software may not be called "Radiance",
42 < *       nor may "Radiance" appear in their name, without prior written
43 < *       permission of Lawrence Berkeley National Laboratory.
44 < *
45 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
49 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 < * SUCH DAMAGE.
57 < * ====================================================================
58 < *
59 < * This software consists of voluntary contributions made by many
60 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
61 < * information on Lawrence Berkeley National Laboratory, please see
62 < * <http://www.lbl.gov/>.
63 < */
8 > #include "copyright.h"
9  
10   #include  "ray.h"
11 <
11 > #include  "paths.h"
12   #include  "otypes.h"
13 <
13 > #include  "rtotypes.h"
14   #include  "font.h"
15  
16   /*
# Line 131 | Line 76 | typedef struct {
76          TLINE  tl;                      /* line list */
77   }  TEXT;
78  
79 < TEXT  *gettext();
79 > static TLINE * tlalloc(char *s);
80 > static TEXT * gettext(OBJREC *tm);
81 > static int intext(FVECT p, OBJREC *m);
82 > static int inglyph(double x, double y, GLYPH *gl);
83  
136 TLINE  *tlalloc();
84  
85 <
86 < do_text(m, r)
87 < register OBJREC  *m;
88 < RAY  *r;
85 > int
86 > do_text(
87 >        OBJREC  *m,
88 >        RAY  *r
89 > )
90   {
91          FVECT  v;
92          int  foreground;
# Line 185 | Line 133 | RAY  *r;
133   }
134  
135  
136 < TLINE *
137 < tlalloc(s)                      /* allocate and assign text line */
138 < char  *s;
136 > static TLINE *
137 > tlalloc(                        /* allocate and assign text line */
138 >        char  *s
139 > )
140   {
141 <        register int  siz;
142 <        register TLINE  *tl;
141 >        int  siz;
142 >        TLINE  *tl;
143  
144          siz = strlen(s) + 1;
145          if ((tl=(TLINE *)malloc(sizeof(TLINE)+siz)) == NULL ||
# Line 202 | Line 151 | char  *s;
151   }
152  
153  
154 < TEXT *
155 < gettext(tm)                     /* get text structure for material */
156 < register OBJREC  *tm;
154 > static TEXT *
155 > gettext(                        /* get text structure for material */
156 >        OBJREC  *tm
157 > )
158   {
159   #define  R      (tm->oargs.farg+3)
160   #define  D      (tm->oargs.farg+6)
# Line 213 | Line 163 | register OBJREC  *tm;
163          FILE  *fp;
164          char  linbuf[512];
165          TEXT  *t;
166 <        register int  i;
167 <        register TLINE  *tlp;
168 <        register char  *s;
166 >        int  i;
167 >        TLINE  *tlp;
168 >        char  *s;
169  
170          if ((t = (TEXT *)tm->os) != NULL)
171                  return(t);
# Line 251 | Line 201 | register OBJREC  *tm;
201                  tlp = tlp->next;
202          } else {                                /* text file */
203                  if ((s = getpath(tm->oargs.sarg[tndx(tm)],
204 <                                getlibpath(), R_OK)) == NULL) {
204 >                                getrlibpath(), R_OK)) == NULL) {
205                          sprintf(errmsg, "cannot find text file \"%s\"",
206                                          tm->oargs.sarg[tndx(tm)]);
207 <                        error(USER, errmsg);
207 >                        error(SYSTEM, errmsg);
208                  }
209                  if ((fp = fopen(s, "r")) == NULL) {
210                          sprintf(errmsg, "cannot open text file \"%s\"", s);
# Line 272 | Line 222 | register OBJREC  *tm;
222          tlp->next = NULL;
223                                                  /* get the font */
224          t->f = getfont(tm->oargs.sarg[fndx(tm)]);
225 +        if (!t->f)
226 +                objerror(tm, USER, "font load error");
227                                                  /* compute character spacing */
228          i = sndx(tm);
229          d = i < tm->oargs.nfargs ? tm->oargs.farg[i] : 0.0;
# Line 295 | Line 247 | register OBJREC  *tm;
247   }
248  
249  
250 < freetext(m)                     /* free text structures associated with m */
251 < OBJREC  *m;
250 > void
251 > freetext(                       /* free text structures associated with m */
252 >        OBJREC  *m
253 > )
254   {
255 <        register TEXT  *tp;
256 <        register TLINE  *tlp;
255 >        TEXT  *tp;
256 >        TLINE  *tlp;
257  
258          tp = (TEXT *)m->os;
259          if (tp == NULL)
# Line 315 | Line 269 | OBJREC  *m;
269   }
270  
271  
272 < intext(p, m)                    /* check to see if p is in text glyph */
273 < FVECT  p;
274 < OBJREC  *m;
272 > static int
273 > intext(                 /* check to see if p is in text glyph */
274 >        FVECT  p,
275 >        OBJREC  *m
276 > )
277   {
278 <        register TEXT  *tp;
279 <        register TLINE  *tlp;
278 >        TEXT  *tp;
279 >        TLINE  *tlp;
280          FVECT  v;
281          double  y, x;
282 <        register int  i, h;
282 >        int  i, h;
283                                  /* first, compute position in text */
284          tp = gettext(m);
285          v[0] = p[0] - m->oargs.farg[0];
# Line 355 | Line 311 | OBJREC  *m;
311   }
312  
313  
314 < inglyph(x, y, gl)               /* (x,y) within font glyph gl? */
315 < double  x, y;           /* real coordinates in range [0,255) */
316 < register GLYPH  *gl;
314 > static int
315 > inglyph(                /* (x,y) within font glyph gl? */
316 >        double  x,              /* real coordinates in range [0,255) */
317 >        double  y,
318 >        GLYPH  *gl
319 > )
320   {
321          int  n, ncross;
322          int  xlb, ylb;
323          int  tv;
324 <        register GORD  *p0, *p1;
324 >        GORD  *p0, *p1;
325  
326          if (gl == NULL)
327                  return(0);
# Line 380 | Line 339 | register GLYPH  *gl;
339                                          /* positive x axis cross test */
340          while (n--) {
341                  if ((p0[1]<<1 > ylb) ^ (p1[1]<<1 > ylb)) {
342 <                        tv = p0[0]<<1 > xlb | (p1[0]<<1 > xlb) << 1;
342 >                        tv = (p0[0]<<1 > xlb) | ((p1[0]<<1 > xlb) << 1);
343                          if (tv == 03)
344                                  ncross++;
345                          else if (tv)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines