Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <libg.h>
4 #include <bio.h>
5 #include "hdr.h"
7 Subfont *
8 bf(int n, int size, Bitmap *b, int *done)
9 {
10 Fontchar *fc;
11 int i, j;
12 Subfont *f;
14 fc = (Fontchar *)malloc(sizeof(Fontchar)*(n+1));
15 if(fc == 0){
16 fprint(2, "%s: fontchar malloc(%d) failure\n", argv0, sizeof(Fontchar)*(n+1));
17 exits("fontchar malloc failure");
18 }
19 j = 0;
20 for(i = 0; i <= n; i++){
21 fc[i] = (Fontchar){j, 0, size, 0, size};
22 if(done[i])
23 j += size;
24 else
25 fc[i].width = 0;
26 }
27 fc[n] = (Fontchar){j, 0, size, 0, size};
28 f = subfalloc(n, size, size*7/8, fc, b, ~0, ~0);
29 if(f == 0){
30 fprint(2, "%s: falloc failure\n", argv0);
31 exits("falloc failure");
32 }
33 return(f);
34 }