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