]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libdraw/getsubfont.c
fltfmt: %.0g should print with one significant figure
[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 fd;
13         Subfont *f;
14
15         fd = open(name, OREAD);
16         if(fd < 0){
17                 fprint(2, "getsubfont: can't open %s: %r\n", name);
18                 return 0;
19         }
20         /*
21          * unlock display so i/o happens with display released, unless
22          * user is doing his own locking, in which case this could break things.
23          * _getsubfont is called only from string.c and stringwidth.c,
24          * which are known to be safe to have this done.
25          */
26         if(d && d->locking == 0)
27                 unlockdisplay(d);
28         f = readsubfont(d, name, fd, d && d->locking==0);
29         if(d && d->locking == 0)
30                 lockdisplay(d);
31         close(fd);
32         if(f == 0)
33                 fprint(2, "_getsubfont: can't read %s: %r\n", name);
34         return f;
35 }