From 141ce091298a1364e2f6f56f71ad751931120188 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Mon, 20 Apr 2009 23:51:04 +0000 Subject: Transliterate to UTF-16 and use XDrawText16. This leaves vast font issues, and selection issues, and bypasses #6 in favor of #33. --- zwgc/xshow.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'zwgc/xshow.c') diff --git a/zwgc/xshow.c b/zwgc/xshow.c index 720d4c8..3521318 100644 --- a/zwgc/xshow.c +++ b/zwgc/xshow.c @@ -164,8 +164,9 @@ fixup_and_draw(Display *dpy, for (i = 0; i < lines[line].numblock; i++, block++) { chars += auxblocks[block].len; - ssize = XTextWidth(auxblocks[block].font, auxblocks[block].str, - auxblocks[block].len); + ssize = XTextWidth16(auxblocks[block].font, + (XChar2b *)blocks[block].wstr, + blocks[block].wlen / 2); auxblocks[block].width = ssize; ascent = auxblocks[block].font->ascent; descent = auxblocks[block].font->descent; @@ -394,6 +395,8 @@ xshow(Display *dpy, desctype *desc, int numstr, int numnl) char *style; int free_style = 0; int beepcount = 0; + char *notice_charset = var_get_variable("notice_charset"); + int i; lines = (xlinedesc *)malloc(sizeof(xlinedesc) * (numnl + 1)); @@ -508,6 +511,20 @@ xshow(Display *dpy, desctype *desc, int numstr, int numnl) auxblocks[nextblock].font = mode_to_font(dpy, style, &curmode); auxblocks[nextblock].str = desc->str; auxblocks[nextblock].len = desc->len; + i = ZTransliterate(desc->str, desc->len, + strcmp(notice_charset, "UNKNOWN") ? + notice_charset : "ISO-8859-1", + "UTF-16BE", + &blocks[nextblock].wstr, + &blocks[nextblock].wlen); + if (i) { + var_set_variable("error", strerror(i)); + blocks[nextblock].wlen = desc->len * 2; + blocks[nextblock].wstr = malloc(blocks[nextblock].wlen); + for (i = 0; i < desc->len; i++) + *(short *)&(blocks[nextblock].wstr[i * 2]) = htons((short)(unsigned char)desc->str[i]); + /* XXX */ + } if (curmode.expcolor) blocks[nextblock].fgcolor = curmode.color; else -- cgit v1.2.3