summaryrefslogtreecommitdiff
path: root/libdraw/subfontcache.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/subfontcache.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'libdraw/subfontcache.c')
-rw-r--r--libdraw/subfontcache.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/libdraw/subfontcache.c b/libdraw/subfontcache.c
new file mode 100644
index 00000000..fb5c11f4
--- /dev/null
+++ b/libdraw/subfontcache.c
@@ -0,0 +1,38 @@
+#include "lib9.h"
+#include "draw.h"
+
+/*
+ * Easy versions of the cache routines; may be substituted by fancier ones for other purposes
+ */
+
+static char *lastname;
+Subfont *lastsubfont;
+
+Subfont*
+lookupsubfont(Display *d, char *name)
+{
+ if(strcmp(name, "*default*") == 0)
+ return d->defaultsubfont;
+ if(lastname && strcmp(name, lastname)==0 && d==lastsubfont->bits->display){
+ lastsubfont->ref++;
+ return lastsubfont;
+ }
+ return 0;
+}
+
+void
+installsubfont(char *name, Subfont *subfont)
+{
+ free(lastname);
+ lastname = strdup(name);
+ lastsubfont = subfont; /* notice we don't free the old one; that's your business */
+}
+
+void
+uninstallsubfont(Subfont *subfont)
+{
+ if(subfont == lastsubfont){
+ lastname = 0;
+ lastsubfont = 0;
+ }
+}