6 * Default version: treat as file name
11 static void scalesubfont(Subfont*, int);
14 _getsubfont(Display *d, char *name)
21 scale = parsefontscale(name, &fname);
22 fd = open(fname, OREAD);
23 if(fd < 0 && strncmp(fname, "/mnt/font/", 10) == 0)
24 fd = _fontpipe(fname+10);
27 fprint(2, "getsubfont: can't open %s: %r\n", fname);
31 * unlock display so i/o happens with display released, unless
32 * user is doing his own locking, in which case this could break things.
33 * _getsubfont is called only from string.c and stringwidth.c,
34 * which are known to be safe to have this done.
36 if(d && d->locking == 0)
38 f = readsubfont(d, name, fd, d && d->locking==0);
39 if(d && d->locking == 0)
42 fprint(2, "getsubfont: can't read %s: %r\n", name);
45 scalesubfont(f, scale);
50 scalesubfont(Subfont *f, int scale)
56 int srcn, dstn, n, mask, v, pack;
65 srcn = bytesperline(r, f->bits->depth);
67 dstn = bytesperline(r2, f->bits->depth);
69 i = allocimage(f->bits->display, r2, f->bits->chan, 0, DBlack);
70 for(y=r.min.y; y < r.max.y; y++) {
71 n = unloadimage(f->bits, Rect(r.min.x, y, r.max.x, y+1), src, srcn);
73 sysfatal("scalesubfont: bad unload: %d < %d: %r", n, srcn);
74 memset(dst, 0, dstn+1);
75 pack = 8 / f->bits->depth;
76 mask = (1<<f->bits->depth) - 1;
77 for(x=0; x<Dx(r); x++) {
78 v = ((src[x/pack] << ((x%pack)*f->bits->depth)) >> (8 - f->bits->depth)) & mask;
79 for(j=0; j<scale; j++) {
81 dst[x2/pack] |= v << (8 - f->bits->depth) >> ((x2%pack)*f->bits->depth);
85 sysfatal("overflow dst");
86 for(j=0; j<scale; j++)
87 loadimage(i, Rect(r2.min.x, y*scale+j, r2.max.x, y*scale+j+1), dst, dstn);
94 for(j=0; j<f->n; j++) {
95 f->info[j].x *= scale;
96 f->info[j].top *= scale;
97 f->info[j].bottom *= scale;
98 f->info[j].left *= scale;
99 f->info[j].width *= scale;