Blame


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