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

Comparing ray/src/common/font.c (file contents):
Revision 2.3 by greg, Wed Jun 24 17:52:58 1992 UTC vs.
Revision 2.8 by greg, Thu May 20 14:32:50 1993 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17  
18   extern char  *libpath;                  /* list of library directories */
19  
20 + extern char  *fgetword();
21 +
22   static FONT     *fontlist = NULL;       /* list of loaded fonts */
23  
24  
# Line 30 | Line 32 | char  *fname;
32          unsigned  wsum, hsum, ngly;
33          int  gn, ngv;
34          register int  gv;
35 <        register GLYPH  *g;
35 >        register GLYPH  *g;
36          GORD  *gp;
37          register FONT  *f;
38  
# Line 122 | Line 124 | memerr:
124   }
125  
126  
127 + freefont(fname)                 /* free a font (free all if fname==NULL) */
128 + char  *fname;
129 + {
130 +        FONT  head;
131 +        register FONT  *fl, *f;
132 +        register int  i;
133 +
134 +        head.next = fontlist;
135 +        fl = &head;
136 +        while ((f = fl->next) != NULL)
137 +                if (fname == NULL || !strcmp(fname, f->name)) {
138 +                        fl->next = f->next;
139 +                        for (i = 0; i < 256; i++)
140 +                                if (f->fg[i] != NULL)
141 +                                        free((char *)f->fg[i]);
142 +                        freestr(f->name);
143 +                        free((char *)f);
144 +                } else
145 +                        fl = f;
146 +        fontlist = head.next;
147 + }
148 +
149 +
150   int
151   uniftext(sp, tp, f)                     /* uniformly space text line */
152 < register short  *sp;            /* returned character spacing */
152 > register short  *sp;            /* returned character spacing */
153   register char  *tp;             /* text line */
154   register FONT  *f;              /* font */
155   {
# Line 148 | Line 173 | FONT  *f;                      /* font */
173   int  cis;                       /* intercharacter spacing */
174   {
175          int  linelen;
176 <        register GLYPH  *gp;
176 >        register GLYPH  *gp;
177  
178 +        linelen = 0;
179          gp = NULL;
180          while (*tp && (gp = f->fg[*tp++&0xff]) == NULL)
181                  *sp++ = 0;
182          cis /= 2;
183 <        linelen = *sp = cis;
183 >        *sp = cis;
184          while (gp != NULL) {
185                  if (gp->nverts) {               /* regular character */
186                          linelen += *sp++ += cis - gp->left;
# Line 189 | Line 215 | int  nsi;                      /* minimum number of spaces for indent */
215                                          /* start by squeezing it */
216          squeeztext(sp, tp, f, cis);
217                                          /* now, realign spacing */
218 <        len = 0;
193 <        width = alen = *sp++;
218 >        width = *sp++;
219          while (*tp) {
220 +                len = alen = 0;
221                  nsp = sp;
222                  for (end = tp; *end; end = tab) {
223                          tab = end + 1;
# Line 204 | Line 230 | int  nsi;                      /* minimum number of spaces for indent */
230                                  }
231                                  len += tab - end;
232                          }
233 <                        if (tab - end > nsi)
233 >                        if (nsi && tab - end > nsi)
234                                  break;
235                  }
236                  len *= f->mwidth + cis;         /* compute target length */
# Line 215 | Line 241 | int  nsi;                      /* minimum number of spaces for indent */
241                          *sp++ += alen;
242                          len -= alen;
243                  }
218                len = 0;
219                alen = 0;
244                  tp = tab;
245          }
246          return(width);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines