implemented Xutf8DrawString behavior

This commit is contained in:
Anselm R. Garbe 2006-04-23 20:39:58 +02:00
parent 3931fe18f4
commit 956b52bb2a
2 changed files with 18 additions and 3 deletions

View File

@ -102,7 +102,11 @@ xdrawtext(Display *dpy, BlitzDraw *d)
}
XSetBackground(dpy, d->gc, d->color.bg);
XSetForeground(dpy, d->gc, d->color.fg);
#ifdef X_HAVE_UTF8_STRING
Xutf8DrawString(dpy, d->drawable, d->font.set, d->gc, x, y, text, len);
#else
XDrawString(dpy, d->drawable, d->gc, x, y, text, len);
#endif
}
void

View File

@ -5,20 +5,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <cext.h>
#include "blitz.h"
void
blitz_loadfont(Display *dpy, BlitzFont *font, char *fontstr)
{
char *fontname = fontstr;
char **missing = nil, *def = "?";
int nmissing;
if(font->set)
XFreeFontSet(dpy, font->set);
if(font->font)
XFreeFont(dpy, font->font);
font->font = XLoadQueryFont(dpy, fontstr);
font->font = XLoadQueryFont(dpy, fontname);
if (!font->font) {
font->font = XLoadQueryFont(dpy, "fixed");
fontname = "fixed";
font->font = XLoadQueryFont(dpy, fontname);
if (!font->font) {
fprintf(stderr, "%s", "liblitz: error, cannot load fixed font\n");
fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n");
exit(1);
}
}
font->set = XCreateFontSet(dpy, fontname, &missing, &nmissing, &def);
if(missing)
XFreeStringList(missing);
}