2006-04-23 22:00:47 +04:00
|
|
|
/*
|
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2006-04-23 22:39:58 +04:00
|
|
|
#include <cext.h>
|
2006-04-23 22:00:47 +04:00
|
|
|
|
|
|
|
#include "blitz.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
blitz_loadfont(Display *dpy, BlitzFont *font, char *fontstr)
|
|
|
|
{
|
2006-04-24 03:01:49 +04:00
|
|
|
char *fontname = fontstr;
|
|
|
|
char **missing = nil, *def = "?";
|
|
|
|
int nmissing;
|
|
|
|
if(font->set)
|
|
|
|
XFreeFontSet(dpy, font->set);
|
2006-04-24 01:32:36 +04:00
|
|
|
if(font->xfont)
|
|
|
|
XFreeFont(dpy, font->xfont);
|
2006-04-24 03:01:49 +04:00
|
|
|
font->xfont = XLoadQueryFont(dpy, fontname);
|
|
|
|
if (!font->xfont) {
|
|
|
|
fontname = "fixed";
|
|
|
|
font->xfont = XLoadQueryFont(dpy, fontname);
|
|
|
|
}
|
2006-04-24 01:32:36 +04:00
|
|
|
if (!font->xfont) {
|
|
|
|
fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2006-04-24 03:01:49 +04:00
|
|
|
font->set = XCreateFontSet(dpy, fontname, &missing, &nmissing, &def);
|
|
|
|
|
|
|
|
if(missing)
|
|
|
|
XFreeStringList(missing);
|
2006-04-23 22:00:47 +04:00
|
|
|
}
|