blob: 2cbec8126474c33a6b17d546d8caf5ef2c3d1a0d [file] [log] [blame]
rsc76193d72003-09-30 17:47:42 +00001#include <u.h>
2#include <libc.h>
3#include <draw.h>
4
5/*
6 * Default version: treat as file name
7 */
8
9Subfont*
10_getsubfont(Display *d, char *name)
11{
12 int fd;
13 Subfont *f;
14
15 fd = open(name, OREAD);
16
17 if(fd < 0){
18 fprint(2, "getsubfont: can't open %s: %r\n", name);
19 return 0;
20 }
21 /*
22 * unlock display so i/o happens with display released, unless
23 * user is doing his own locking, in which case this could break things.
24 * _getsubfont is called only from string.c and stringwidth.c,
25 * which are known to be safe to have this done.
26 */
rsc4e206882004-04-25 20:26:27 +000027 if(d && d->locking == 0)
rsc76193d72003-09-30 17:47:42 +000028 unlockdisplay(d);
rsc4e206882004-04-25 20:26:27 +000029 f = readsubfont(d, name, fd, d && d->locking==0);
30 if(d && d->locking == 0)
rsc76193d72003-09-30 17:47:42 +000031 lockdisplay(d);
32 if(f == 0)
33 fprint(2, "getsubfont: can't read %s: %r\n", name);
34 close(fd);
35 return f;
36}