diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/libdraw/getsubfont.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/libdraw/getsubfont.c')
-rwxr-xr-x | sys/src/libdraw/getsubfont.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/src/libdraw/getsubfont.c b/sys/src/libdraw/getsubfont.c new file mode 100755 index 000000000..04cc87355 --- /dev/null +++ b/sys/src/libdraw/getsubfont.c @@ -0,0 +1,37 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> + +/* + * Default version: treat as file name + */ + +Subfont* +_getsubfont(Display *d, char *name) +{ + int fd; + Subfont *f; + + fd = open(name, OREAD); + + if(fd < 0){ + fprint(2, "getsubfont: can't open %s: %r\n", name); + return 0; + } + /* + * unlock display so i/o happens with display released, unless + * user is doing his own locking, in which case this could break things. + * _getsubfont is called only from string.c and stringwidth.c, + * which are known to be safe to have this done. + */ + if(d && d->locking == 0) + unlockdisplay(d); + f = readsubfont(d, name, fd, d && d->locking==0); + if(d && d->locking == 0) + lockdisplay(d); + if(f == 0) + fprint(2, "getsubfont: can't read %s: %r\n", name); + close(fd); + setmalloctag(f, getcallerpc(&d)); + return f; +} |