tsubfontcache.c - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
tsubfontcache.c (701B) | |
--- | |
1 #include <u.h> | |
2 #include <libc.h> | |
3 #include <draw.h> | |
4 | |
5 /* | |
6 * Easy versions of the cache routines; may be substituted by fancier on… | |
7 */ | |
8 | |
9 static char *lastname; | |
10 Subfont *lastsubfont; | |
11 | |
12 Subfont* | |
13 lookupsubfont(Display *d, char *name) | |
14 { | |
15 if(lastname && strcmp(name, lastname)==0) | |
16 if(d==lastsubfont->bits->display){ | |
17 lastsubfont->ref++; | |
18 return lastsubfont; | |
19 } | |
20 return 0; | |
21 } | |
22 | |
23 void | |
24 installsubfont(char *name, Subfont *subfont) | |
25 { | |
26 free(lastname); | |
27 lastname = strdup(name); | |
28 lastsubfont = subfont; /* notice we don't free the old on… | |
29 } | |
30 | |
31 void | |
32 uninstallsubfont(Subfont *subfont) | |
33 { | |
34 if(subfont == lastsubfont){ | |
35 free(lastname); | |
36 lastname = 0; | |
37 lastsubfont = 0; | |
38 } | |
39 } |