aboutsummaryrefslogtreecommitdiff
path: root/src/libdraw/getsubfont.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-09-30 17:47:42 +0000
committerrsc <devnull@localhost>2003-09-30 17:47:42 +0000
commit76193d7cb0457807b2f0b95f909ab5de19480cd7 (patch)
tree97e538c7e38181431e90289a0fe8b6b7ce1f8f3c /src/libdraw/getsubfont.c
parented7c8e8d02c02bdbff1e88a6d8d1419f39af48ad (diff)
downloadplan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.tar.gz
plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.tar.bz2
plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.zip
Initial revision
Diffstat (limited to 'src/libdraw/getsubfont.c')
-rw-r--r--src/libdraw/getsubfont.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libdraw/getsubfont.c b/src/libdraw/getsubfont.c
new file mode 100644
index 00000000..b7a8e44a
--- /dev/null
+++ b/src/libdraw/getsubfont.c
@@ -0,0 +1,36 @@
+#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->locking == 0)
+ unlockdisplay(d);
+ f = readsubfont(d, name, fd, d->locking==0);
+ if(d->locking == 0)
+ lockdisplay(d);
+ if(f == 0)
+ fprint(2, "getsubfont: can't read %s: %r\n", name);
+ close(fd);
+ return f;
+}