rsc | 76193d7 | 2003-09-30 17:47:42 +0000 | [diff] [blame] | 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 | |
| 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 | */ |
rsc | 4e20688 | 2004-04-25 20:26:27 +0000 | [diff] [blame] | 27 | if(d && d->locking == 0) |
rsc | 76193d7 | 2003-09-30 17:47:42 +0000 | [diff] [blame] | 28 | unlockdisplay(d); |
rsc | 4e20688 | 2004-04-25 20:26:27 +0000 | [diff] [blame] | 29 | f = readsubfont(d, name, fd, d && d->locking==0); |
| 30 | if(d && d->locking == 0) |
rsc | 76193d7 | 2003-09-30 17:47:42 +0000 | [diff] [blame] | 31 | lockdisplay(d); |
| 32 | if(f == 0) |
| 33 | fprint(2, "getsubfont: can't read %s: %r\n", name); |
| 34 | close(fd); |
| 35 | return f; |
| 36 | } |