xref: /inferno-os/libdraw/subfont.c (revision 37da2899f40661e3e9631e497da8dc59b971cbd0)
1 #include "lib9.h"
2 #include "draw.h"
3 
4 Subfont*
allocsubfont(char * name,int n,int height,int ascent,Fontchar * info,Image * i)5 allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i)
6 {
7 	Subfont *f;
8 
9 	assert(height != 0 /* allocsubfont */);
10 
11 	f = malloc(sizeof(Subfont));
12 	if(f == 0)
13 		return 0;
14 	f->n = n;
15 	f->height = height;
16 	f->ascent = ascent;
17 	f->info = info;
18 	f->bits = i;
19 	f->ref = 1;
20 	if(name){
21 		f->name = strdup(name);
22 		if(lookupsubfont(i->display, name) == 0)
23 			installsubfont(name, f);
24 	}else
25 		f->name = 0;
26 	return f;
27 }
28