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));
29 fnt->name = strdup(name);
30 fnt->ncache = NFCACHE+NFLOOK;
32 fnt->cache = malloc(fnt->ncache * sizeof(fnt->cache[0]));
33 fnt->subf = malloc(fnt->nsubf * sizeof(fnt->subf[0]));
34 if(fnt->name==nil || fnt->cache==nil || fnt->subf==nil){
43 fnt->height = strtol(s, &s, 0);
45 fnt->ascent = strtol(s, &s, 0);
47 if(fnt->height<=0 || fnt->ascent<=0){
48 werrstr("bad height or ascent in font file");
55 memset(fnt->subf, 0, fnt->nsubf * sizeof(fnt->subf[0]));
56 memset(fnt->cache, 0, fnt->ncache*sizeof(fnt->cache[0]));
59 /* must be looking at a number now */
61 werrstr(badform, s-buf);
64 min = strtol(s, &s, 0);
66 /* must be looking at a number now */
68 werrstr(badform, s-buf);
71 max = strtol(s, &s, 0);
73 if(*s==0 || min>Runemax || max>Runemax || min>max){
74 werrstr("illegal subfont range");
80 offset = strtol(s, &t, 0);
81 if(t>s && (*t==' ' || *t=='\t' || *t=='\n'))
85 sub = realloc(fnt->sub, (fnt->nsub+1)*sizeof(Cachefont*));
89 c = malloc(sizeof(Cachefont));
96 while(*s && *s!=' ' && *s!='\n' && *s!='\t')
105 sub[fnt->nsub++] = c;
121 for(i=0; i<f->nsub; i++){
123 free(c->subfontname);
127 for(i=0; i<f->nsubf; i++){
130 if(f->display == nil || s != f->display->defaultsubfont)
134 freeimage(f->cacheimage);