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.3 by greg, Sat Jun 6 07:40:51 1992 UTC vs.
Revision 2.4 by greg, Tue Jun 16 15:34:47 1992 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "font.h"
18  
19 + #define  SSS                    2       /* super-sample size */
20 +
21   #define  MAXLINE                512     /* longest allowable line */
22  
23   #ifndef  DEFPATH
# Line 46 | Line 48 | int  xdim;                             /* size of horizontal scan (bytes) */
48   #define  clrbit(x,y)            bitop(x,y,&=~)
49   #define  tglbit(x,y)            bitop(x,y,^=)
50  
49 typedef unsigned char  GLYPH;
50
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 +        short  *sp;             /* character spacing */
58          struct line  *next;     /* next line up */
59   } LINE;
60  
61   LINE  *ourtext;                         /* our text */
62   int  nlines, maxline;                   /* text dimensions */
63 + int  maxwidth;                          /* maximum line width (dvi) */
64  
65   extern char  *getenv();
66   extern char  *malloc(), *calloc();
# Line 117 | Line 119 | unkopt:
119                                          argv[0], argv[an]);
120                          exit(1);
121                  }
122 +                                        /* load font file */
123 +        if ((libpath = getenv(ULIBVAR)) == NULL)
124 +                libpath = DEFPATH;
125 +        ourfont = getfont(fontfile);
126                                          /* get text */
127          if (an == argc)
128                  gettext(stdin);
# Line 125 | Line 131 | unkopt:
131  
132                                          /* create bit map */
133          makemap();
128                                        /* load font file */
129        if ((libpath = getenv(ULIBVAR)) == NULL)
130                libpath = DEFPATH;
131        ourfont = getfont(fontfile);
134                                          /* convert text to bitmap */
135          maptext();
136                                          /* print header */
# Line 170 | Line 172 | FILE  *fp;
172          int  len;
173  
174          maxline = 0;
175 +        maxwidth = 0;
176          nlines = 0;
177          while (fgets(buf, MAXLINE, fp) != NULL) {
178                  curl = (LINE *)malloc(sizeof(LINE));
179                  if (curl == NULL)
180                          goto memerr;
181                  len = strlen(buf);
182 <                curl->s = malloc(len--);
183 <                if (curl->s == NULL)
182 >                curl->s = malloc(len);
183 >                curl->sp = (short *)malloc(sizeof(short)*len--);
184 >                if (curl->s == NULL | curl->sp == NULL)
185                          goto memerr;
186 +                if (len > maxline)
187 +                        maxline = len;
188                  strncpy(curl->s, buf, len);
189                  curl->s[len] = '\0';
190 + len = uniftext(curl->sp, curl->s, ourfont);
191 +                if (len > maxwidth)
192 +                        maxwidth = len;
193                  curl->next = ourtext;
194                  ourtext = curl;
186                if (len > maxline)
187                        maxline = len;
195                  nlines++;
196          }
197          return;
# Line 214 | Line 221 | char  *av[];
221          *--cp = '\0';
222          ourtext->next = NULL;
223          maxline = strlen(ourtext->s);
224 +        ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1));
225 +        if (ourtext->sp == NULL)
226 +                goto memerr;
227 + maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont);
228          nlines = 1;
229          return;
230   memerr:
# Line 225 | Line 236 | memerr:
236   maptext()                       /* map our text */
237   {
238          register LINE  *curl;
239 <        int  l;
240 <        register int  c;
239 >        int  l, len;
240 >        register int  i, c;
241  
242 <        for (l = 0, curl = ourtext; curl != NULL; l++, curl = curl->next)
243 <                for (c = strlen(curl->s)-1; c >= 0; c--)
244 <                        mapglyph(ourfont->fg[curl->s[c]&0xff], c, l);
242 >        for (l = 0, curl = ourtext; curl != NULL; l += 256, curl = curl->next) {
243 >                len = strlen(curl->s); c = 0;
244 >                for (i = 0; i < len; i++) {
245 >                        c += curl->sp[i];
246 >                        mapglyph(ourfont->fg[curl->s[i]&0xff], c, l);
247 >                }
248 >        }
249   }
250  
251  
# Line 245 | Line 260 | int  tx0, ty0;
260          if (gl == NULL)
261                  return;
262  
248        tx0 <<= 8; ty0 <<= 8;
263          n = gl->nverts;
264          gp = gvlist(gl);
265          mapcoord(p0, gp[2*n-2]+tx0, gp[2*n-1]+ty0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines