summaryrefslogtreecommitdiff
path: root/libdraw/getsubfont.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /libdraw/getsubfont.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'libdraw/getsubfont.c')
-rw-r--r--libdraw/getsubfont.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libdraw/getsubfont.c b/libdraw/getsubfont.c
new file mode 100644
index 00000000..0208d634
--- /dev/null
+++ b/libdraw/getsubfont.c
@@ -0,0 +1,36 @@
+#include "lib9.h"
+#include "kernel.h"
+#include "draw.h"
+
+/*
+ * Default version: treat as file name
+ */
+
+Subfont*
+_getsubfont(Display *d, char *name)
+{
+ int fd;
+ Subfont *f;
+
+ fd = libopen(name, OREAD);
+
+ if(fd < 0){
+ _drawprint(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->local == 0)
+ unlockdisplay(d);
+ f = readsubfont(d, name, fd, d->local == 0);
+ if(d->local == 0)
+ lockdisplay(d);
+ if(f == 0)
+ _drawprint(2, "getsubfont: can't read %s: %r\n", name);
+ libclose(fd);
+ return f;
+}