Subfont * bf(int n, int size, Bitmap *b, int *done) { Fontchar *fc; int i, j; Subfont *f; fc = (Fontchar *)malloc(sizeof(Fontchar)*(n+1)); if(fc == 0){ fprint(2, "%s: fontchar malloc(%d) failure\n", argv0, sizeof(Fontchar)*(n+1)); exits("fontchar malloc failure"); } j = 0; for(i = 0; i <= n; i++){ fc[i] = (Fontchar){j, 0, size, 0, size}; if(done[i]) j += size; else fc[i].width = 0; } fc[n] = (Fontchar){j, 0, size, 0, size}; f = subfalloc(n, size, size*7/8, fc, b, ~0, ~0); if(f == 0){ fprint(2, "%s: falloc failure\n", argv0); exits("falloc failure"); } return(f); }
void main(int argc, char **argv) { int i, errs; Fontchar *fc; Bitmap *b; int nc, ht, as; Subfont *f; binit(0, 0, "font merge"); if(argc < 1) usage(); nf = argc-1; for(i = 0; i < nf; i++) snarf(argv[i+1], i); nc = ft[0].sf->n; ht = ft[0].sf->height; as = ft[0].sf->ascent; errs = 0; for(i = 0; i < nf; i++){ if(nc < ft[i].sf->n) nc = ft[i].sf->n; if(ht != ft[1].sf->height){ fprint(2, "%s: %s.height=%d (!= %s.height=%d)\n", argv[0], ft[i].name, ft[i].sf->height, ft[0].name, ht); errs = 1; } if(as != ft[1].sf->ascent){ fprint(2, "%s: %s.ascent=%d (!= %s.ascent=%d)\n", argv[0], ft[i].name, ft[i].sf->ascent, ft[0].name, ht); errs = 1; } } if(errs) exits("param mismatch"); fc = (Fontchar *)malloc(nc*sizeof(Fontchar)); b = balloc(Rect(0, 0, nc*64, ht), ft[0].bm->ldepth); if(b == 0 || fc == 0){ fprint(2, "%s: couldn't malloc %d chars\n", argv0, nc); exits("out of memory"); } bitblt(b, b->r.min, b, b->r, Zero); choose(fc, b, nc, ht, as); wrbitmapfile(1, b); bitblt(&screen, screen.r.min, b, b->r, S); bflush();sleep(5000); f = subfalloc(nc, ht, as, fc, b, ~0, ~0); wrsubfontfile(1, f); exits(0); }