#include #include #include #include #include Display *d; Window w; Screen s; int main(void) { XEvent evt; char s[80]; XFontStruct *fontInfo; GC gc; XChar2b *ws; XSetWindowAttributes attr; int i; setlocale(LC_ALL, ""); d = XOpenDisplay(NULL); w = XCreateSimpleWindow(d, DefaultRootWindow(d), 50, 50, 500, 375, 0, BlackPixel(d, 0), WhitePixel(d, 0)); attr.event_mask = KeyPressMask; XChangeWindowAttributes(d, w, CWEventMask, &attr); XStoreName(d, w, "Draw String"); if (! w) { printf("Error creating window!\n"); exit(1); } XMapWindow(d, w); fontInfo = XLoadQueryFont(d, "-misc-fixed-medium-r-normal--20-*-iso10646-1"); if (! fontInfo) { fprintf(stderr, "Error loading font!\n"); exit(1); } printf("min_byte1: %d\n", fontInfo->min_byte1); printf("max_byte1: %d\n", fontInfo->max_byte1); printf("min_char_or_byte2: %d\n", fontInfo->min_char_or_byte2); printf("max_char_or_byte2: %d\n", fontInfo->max_char_or_byte2); gc = XCreateGC(d, w, 0, NULL); XSetForeground(d, gc, BlackPixel(d, 0)); XSetBackground(d, gc, WhitePixel(d, 0)); XSetFont(d, gc, fontInfo->fid); ws = (XChar2b *)malloc(sizeof(XChar2b) * 16); for (i = 0; i < 16; i++) { ws[i].byte1 = 0x16; ws[i].byte2 = 0xA0 + i; } strcpy(s, "Here are some runes"); XDrawString(d, w, gc, 5, 25, s, strlen(s)); XDrawString16(d, w, gc, 5, 50, ws, 16); while(1) { while(XPending(d)) { XNextEvent(d, &evt); if (evt.type == KeyPress) goto end; } usleep(1000); } end: XDestroyWindow(d, w); XCloseDisplay(d); return 0; } .