6 static void usage(void);
7 static void snarf(char *, int);
8 static void choose(Fontchar *, Bitmap *, int, int, int);
17 main(int argc, char **argv)
25 binit(0, 0, "font merge");
29 for(i = 0; i < nf; i++)
32 ht = ft[0].sf->height;
33 as = ft[0].sf->ascent;
35 for(i = 0; i < nf; i++){
36 if(nc < ft[i].sf->n) nc = ft[i].sf->n;
37 if(ht != ft[1].sf->height){
38 fprint(2, "%s: %s.height=%d (!= %s.height=%d)\n", argv[0],
39 ft[i].name, ft[i].sf->height, ft[0].name, ht);
42 if(as != ft[1].sf->ascent){
43 fprint(2, "%s: %s.ascent=%d (!= %s.ascent=%d)\n", argv[0],
44 ft[i].name, ft[i].sf->ascent, ft[0].name, ht);
49 exits("param mismatch");
50 fc = (Fontchar *)malloc(nc*sizeof(Fontchar));
51 b = balloc(Rect(0, 0, nc*64, ht), ft[0].bm->ldepth);
52 if(b == 0 || fc == 0){
53 fprint(2, "%s: couldn't malloc %d chars\n", argv0, nc);
54 exits("out of memory");
56 bitblt(b, b->r.min, b, b->r, Zero);
57 choose(fc, b, nc, ht, as);
59 bitblt(&screen, screen.r.min, b, b->r, S); bflush();sleep(5000);
60 f = subfalloc(nc, ht, as, fc, b, ~0, ~0);
68 fprint(2, "Usage: %s file ...\n", argv0);
73 snarf(char *name, int i)
79 if((fd = open(name, OREAD)) < 0){
83 if((b = rdbitmapfile(fd)) == 0){
84 fprint(2, "rdbitmapfile failed\n");
87 if((ft[i].bm = balloc(b->r, b->ldepth)) == 0){
88 fprint(2, "ballocsnarf failed\n");
91 bitblt(ft[i].bm, b->r.min, b, b->r, S);
92 if((ft[i].sf = rdsubfontfile(fd, b)) == 0){
93 fprint(2, "rdsubfontfile failed\n");
100 choose(Fontchar *f, Bitmap *b, int nc, int ht, int as)
107 for(n = 0; n < nc; n++, f++){
109 for(j = 0; j < nf; j++){
112 info = ft[j].sf->info;
113 if(info[n+1].x != info[n].x)
118 f->left = info[n].left;
119 f->top = info[n].top;
120 f->bottom = info[n].bottom;
121 f->width = info[n].width;
122 w = info[n+1].x - info[n].x;
123 bitblt(b, Pt(0, lastx), ft[j].bm, Rect(0, info[n].x, ht, info[n+1].x), S);