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){
45 fnt->height = strtol(s, &s, 0);
47 fnt->ascent = strtol(s, &s, 0);
49 if(fnt->height<=0 || fnt->ascent<=0){
50 werrstr("bad height or ascent in font file");
57 memset(fnt->subf, 0, fnt->nsubf * sizeof(fnt->subf[0]));
58 memset(fnt->cache, 0, fnt->ncache*sizeof(fnt->cache[0]));
61 /* must be looking at a number now */
63 werrstr(badform, s-buf);
66 min = strtol(s, &s, 0);
68 /* must be looking at a number now */
70 werrstr(badform, s-buf);
73 max = strtol(s, &s, 0);
75 if(*s==0 || min>Runemax || max>Runemax || min>max){
76 werrstr("illegal subfont range");
82 offset = strtol(s, &t, 0);
83 if(t>s && (*t==' ' || *t=='\t' || *t=='\n'))
87 fnt->sub = realloc(fnt->sub, (fnt->nsub+1)*sizeof(Cachefont*));
89 /* realloc manual says fnt->sub may have been destroyed */
93 c = malloc(sizeof(Cachefont));
96 fnt->sub[fnt->nsub] = c;
101 while(*s && *s!=' ' && *s!='\n' && *s!='\t')
126 for(i=0; i<f->nsub; i++){
128 free(c->subfontname);
132 for(i=0; i<f->nsubf; i++){
134 if(s && (!display || s!=display->defaultsubfont))
137 freeimage(f->cacheimage);
144 if(f->ondisplaylist) {
145 f->ondisplaylist = 0;
147 f->next->prev = f->prev;
149 f->display->lastfont = f->prev;
151 f->prev->next = f->next;
153 f->display->firstfont = f->next;