xft.c (1108B)
1 /* Copyright ©2010 Kris Maglione <maglione.k at Gmail> 2 * See LICENSE file for license details. 3 */ 4 #include <stuff/x.h> 5 #include <stuff/util.h> 6 7 Xft *xft; 8 9 #ifdef HAVE_RTLD 10 #include <dlfcn.h> 11 12 bool 13 havexft(void) { 14 void *libxft; 15 16 if(xft == nil) { 17 libxft = dlopen("libXft.so", RTLD_LAZY); 18 if(libxft == nil) 19 return false; 20 xft = emalloc(sizeof *xft); 21 *(void**)(uintptr_t)&xft->drawcreate = dlsym(libxft, "XftDrawCreate"); 22 *(void**)(uintptr_t)&xft->drawdestroy = dlsym(libxft, "XftDrawDestroy"); 23 *(void**)(uintptr_t)&xft->fontopen = dlsym(libxft, "XftFontOpenXlfd"); 24 *(void**)(uintptr_t)&xft->fontopenname = dlsym(libxft, "XftFontOpenName"); 25 *(void**)(uintptr_t)&xft->fontclose = dlsym(libxft, "XftFontClose"); 26 *(void**)(uintptr_t)&xft->textextents = dlsym(libxft, "XftTextExtentsUtf8"); 27 *(void**)(uintptr_t)&xft->drawstring = dlsym(libxft, "XftDrawStringUtf8"); 28 } 29 return xft && xft->drawcreate && xft->drawdestroy && xft->fontopen 30 && xft->fontopenname && xft->fontclose && xft->textextents && xft->drawstring; 31 } 32 33 #else 34 bool 35 havexft(void) { 36 return false; 37 } 38 #endif 39