Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <draw.h>
5 Subfont*
6 allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i)
7 {
8 Subfont *f, *cf;
10 assert(height != 0 /* allocsubfont */);
12 f = malloc(sizeof(Subfont));
13 if(f == 0)
14 return 0;
15 fprint(2, "allocsubfont %p\n", f);
16 f->n = n;
17 f->height = height;
18 f->ascent = ascent;
19 f->info = info;
20 f->bits = i;
21 f->ref = 1;
22 if(name){
23 /*
24 * if already caching this subfont, leave older
25 * (and hopefully more widely used) copy in cache.
26 * this case should not happen -- we got called
27 * because cachechars needed this subfont and it
28 * wasn't in the cache.
29 */
30 f->name = strdup(name);
31 if((cf=lookupsubfont(i->display, name)) == 0)
32 installsubfont(name, f);
33 else
34 freesubfont(cf); /* drop ref we just picked up */
35 }else
36 f->name = 0;
37 return f;
38 }