8 while(*s==' ' || *s=='\n' || *s=='\t')
14 buildfont(Display *d, char *buf, char *name)
21 char badform[] = "bad font format: number expected (char position %d)";
24 fnt = malloc(sizeof(Font));
27 memset(fnt, 0, sizeof(Font));
30 fnt->name = strdup(name);
31 fnt->namespec = strdup(name);
32 fnt->ncache = NFCACHE+NFLOOK;
34 fnt->cache = malloc(fnt->ncache * sizeof(fnt->cache[0]));
35 fnt->subf = malloc(fnt->nsubf * sizeof(fnt->subf[0]));
36 if(fnt->name==0 || fnt->cache==0 || fnt->subf==0){
46 fnt->height = strtol(s, &s, 0);
48 fnt->ascent = strtol(s, &s, 0);
50 if(fnt->height<=0 || fnt->ascent<=0){
51 werrstr("bad height or ascent in font file");
58 memset(fnt->subf, 0, fnt->nsubf * sizeof(fnt->subf[0]));
59 memset(fnt->cache, 0, fnt->ncache*sizeof(fnt->cache[0]));
62 /* must be looking at a number now */
64 werrstr(badform, s-buf);
67 min = strtol(s, &s, 0);
69 /* must be looking at a number now */
71 werrstr(badform, s-buf);
74 max = strtol(s, &s, 0);
76 if(*s==0 || min>Runemax || max>Runemax || min>max){
77 werrstr("illegal subfont range");
83 offset = strtol(s, &t, 0);
84 if(t>s && (*t==' ' || *t=='\t' || *t=='\n'))
88 fnt->sub = realloc(fnt->sub, (fnt->nsub+1)*sizeof(Cachefont*));
90 /* realloc manual says fnt->sub may have been destroyed */
94 c = malloc(sizeof(Cachefont));
97 fnt->sub[fnt->nsub] = c;
102 while(*s && *s!=' ' && *s!='\n' && *s!='\t')
127 for(i=0; i<f->nsub; i++){
129 free(c->subfontname);
133 for(i=0; i<f->nsubf; i++){
138 freeimage(f->cacheimage);
145 if(f->ondisplaylist) {
146 f->ondisplaylist = 0;
148 f->next->prev = f->prev;
150 f->display->lastfont = f->prev;
152 f->prev->next = f->next;
154 f->display->firstfont = f->next;