Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <draw.h>
5 /*
6 * Default version: treat as file name
7 */
9 int _fontpipe(char*);
11 Subfont*
12 _getsubfont(Display *d, char *name)
13 {
14 int fd;
15 Subfont *f;
17 fd = open(name, OREAD);
18 if(fd < 0 && strncmp(name, "/mnt/font/", 10) == 0)
19 fd = _fontpipe(name+10);
21 if(fd < 0){
22 fprint(2, "getsubfont: can't open %s: %r\n", name);
23 return 0;
24 }
25 /*
26 * unlock display so i/o happens with display released, unless
27 * user is doing his own locking, in which case this could break things.
28 * _getsubfont is called only from string.c and stringwidth.c,
29 * which are known to be safe to have this done.
30 */
31 if(d && d->locking == 0)
32 unlockdisplay(d);
33 f = readsubfont(d, name, fd, d && d->locking==0);
34 if(d && d->locking == 0)
35 lockdisplay(d);
36 if(f == 0)
37 fprint(2, "getsubfont: can't read %s: %r\n", name);
38 close(fd);
39 return f;
40 }