diff -ur XaoS-3.2.orig/src/filter/grlib.c XaoS-3.2/src/filter/grlib.c --- XaoS-3.2.orig/src/filter/grlib.c 2002-09-25 10:52:09.000000000 -0500 +++ XaoS-3.2/src/filter/grlib.c 2008-04-07 19:18:41.000000000 -0500 @@ -5,6 +5,9 @@ #include #include #endif +#ifdef HAVE_GETTEXT +#include +#endif #include #include @@ -379,12 +382,72 @@ return (i); } +#ifdef HAVE_GETTEXT +int +xiconv(int encoding, + char *out, int *outlen, + const char *in, int *inlen) { + /* + * Since the built-in text system only supports Latin-1 and Lqtin-2 + * encodings, we must convert strings from the user's native encoding to + * either Latin-1 or Latin-2 encoding as appropriate for the selected + * language before passing them into the built-in text system. This + * function wraps the gnu iconv library for this purpose. + */ + + iconv_t cd; + char tocode[16]; + size_t icv_inlen = *inlen, icv_outlen = *outlen; + const char *icv_in = (const char *) in; + char *icv_out = (char *) out; + int ret; + + sprintf(tocode, "ISO-8859-%d", encoding); + cd = iconv_open(tocode, ""); + if (cd == (iconv_t)(-1)) + return -1; + + ret = iconv(cd, + &icv_in, &icv_inlen, + &icv_out, &icv_outlen); + + if (in != NULL) { + *inlen -= icv_inlen; + *outlen -= icv_outlen; + out[*outlen] = '\0'; + } else { + *inlen = 0; + *outlen = 0; + } + + if (icv_inlen != 0 || ret == (size_t) -1) + return -1; + + ret = iconv_close(cd); + + if (ret == -1) + return -1; + + return 0; +} +#endif + int xprint (struct image *image, CONST struct xfont *current, int x, int y, - CONST char *text, int fgcolor, int bgcolor, int mode) + CONST char *text, int encoding, int fgcolor, int bgcolor, int mode) { int i = 0; int aacolor = 0; +#ifdef HAVE_GETTEXT + char intext[BUFSIZ]; + int inlen = strlen(text); + char outtext[BUFSIZ]; + int outlen = BUFSIZ; + + strncpy(intext, text, BUFSIZ); + if (encoding && xiconv(encoding, outtext, &outlen, intext, &inlen) == 0) + text = outtext; +#endif if (!text[0]) return 0; /*Do some clipping */ diff -ur XaoS-3.2.orig/src/include/grlib.h XaoS-3.2/src/include/grlib.h --- XaoS-3.2.orig/src/include/grlib.h 2002-09-25 10:52:09.000000000 -0500 +++ XaoS-3.2/src/include/grlib.h 2008-04-07 19:21:41.000000000 -0500 @@ -10,8 +10,9 @@ int width, height, realwidth; } xsmallfont, xbigfont, xaafont, xsmallfontil1, xbigfontil1, xmedfontil1; - int xprint (struct image *image, CONST struct xfont *font, int x, int y, - CONST char *text, int fgcolor, int bgcolor, int mode); + int xiconv(int encoding, char *out, int *outlen, const char *in, int *inlen); + int xprint (struct image *image, CONST struct xfont *current, int x, int y, + CONST char *text, int encoding, int fgcolor, int bgcolor, int mode); #define TEXT_PRESSED 1 #define xtextheight(font) ((font)->height+1) diff -ur XaoS-3.2.orig/src/ui/dialog.c XaoS-3.2/src/ui/dialog.c --- XaoS-3.2.orig/src/ui/dialog.c 2003-01-10 04:26:14.000000000 -0600 +++ XaoS-3.2/src/ui/dialog.c 2008-04-07 19:32:11.000000000 -0500 @@ -155,7 +155,7 @@ (pressed != 0 || selected != 0) * BORDER_PRESSED | BORDER_LIGHT); xprint (uih->image, uih->font, (x1 + x2 - width) / 2 + pressed, - y + BORDERHEIGHT + pressed, text, selected + y + BORDERHEIGHT + pressed, text, uih->encoding, selected || pressed ? BGCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), TEXT_PRESSED); } @@ -164,7 +164,7 @@ uih_drawborder (uih, x1, y, x2 - x1, BUTTONHEIGHT, (pressed != 0) * BORDER_PRESSED | BORDER_LIGHT); xprint (uih->image, uih->font, (x1 + x2 - width) / 2 + pressed, - y + BORDERHEIGHT + pressed, text, + y + BORDERHEIGHT + pressed, text, uih->encoding, selected ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), /*TEXT_PRESSED */ 0); } @@ -191,7 +191,7 @@ { xprint (uih->image, uih->font, YESNOX + (yesnodialog.width - yesnodialog.questionwidth) / 2, - YESNOY + BORDERHEIGHT, yesnodialog.question, FGCOLOR (uih), + YESNOY + BORDERHEIGHT, yesnodialog.question, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); ui_drawbutton (yestext, yesnodialog.pressed == 0, yesnodialog.selected == 0, YESNOX + BORDERWIDTH + 1, @@ -514,7 +514,7 @@ char *c = (char *) malloc (d->ndisplayed + 2); strncpy (c, d->text + d->start, d->ndisplayed); c[d->ndisplayed] = 0; - xprint (uih->image, uih->font, d->x, d->y, c, + xprint (uih->image, uih->font, d->x, d->y, c, uih->encoding, (uih->palette->type & BITMAPS) ? BGCOLOR (uih) : ((active && d->clear) ? SELCOLOR (uih) : @@ -661,14 +661,14 @@ dialog.half - dialog.x - 2 * BORDERWIDTH, BUTTONHEIGHT, FGCOLOR (uih)); xprint (uih->image, uih->font, dialog.half - item->width, - item->y + BORDERHEIGHT, item->dialog->question, + item->y + BORDERHEIGHT, item->dialog->question, uih->encoding, SELECTED (item) ? BGCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), TEXT_PRESSED); } else { xprint (uih->image, uih->font, dialog.half - item->width, - item->y + BORDERHEIGHT, item->dialog->question, + item->y + BORDERHEIGHT, item->dialog->question, uih->encoding, SELECTED (item) ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), 0); } @@ -862,7 +862,7 @@ BUTTONHEIGHT, BORDER_PRESSED | BORDER_LIGHT); ui_drawtext (data->text, SELECTED (item) && !data->active); xprint (uih->image, uih->font, dialog.half - item->width, - item->y + BORDERHEIGHT, item->dialog->question, + item->y + BORDERHEIGHT, item->dialog->question, uih->encoding, SELECTED (item) ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), 0); ui_drawquestion (item); ui_drawbutton ("B", data->pressed && SELECTED (item), SELECTED (item) @@ -1050,10 +1050,10 @@ ui_drawtext (data->text[0], SELECTED (item) && !data->active); ui_drawtext (data->text[1], SELECTED (item) && data->active); xprint (uih->image, uih->font, dialog.half + half, item->y + BORDERHEIGHT, - "+", FGCOLOR (uih), BGCOLOR (uih), 0); + "+", uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); xprint (uih->image, uih->font, dialog.x + dialog.width - BORDERWIDTH - ENDSIZE, - item->y + BORDERHEIGHT, "i", FGCOLOR (uih), BGCOLOR (uih), 0); + item->y + BORDERHEIGHT, "i", uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); ui_drawquestion (item); } static int @@ -1166,7 +1166,7 @@ { xprint (uih->image, uih->font, choice->x + BORDERWIDTH, choice->y + BORDERHEIGHT + i * xtextheight (uih->font), - choice->texts[i], + choice->texts[i], uih->encoding, i == choice->active ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), 0); } @@ -1245,7 +1245,7 @@ uih_drawborder (uih, dialog.half, item->y, item->width1, BUTTONHEIGHT | BORDER_LIGHT, 0); xprint (uih->image, uih->font, dialog.half + BORDERWIDTH, - item->y + BORDERHEIGHT, data->texts[data->selected], + item->y + BORDERHEIGHT, data->texts[data->selected], uih->encoding, SELECTED (item) ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), 0); ui_drawquestion (item); } diff -ur XaoS-3.2.orig/src/ui/filesel.c XaoS-3.2/src/ui/filesel.c --- XaoS-3.2.orig/src/ui/filesel.c 2004-10-30 15:30:04.000000000 -0500 +++ XaoS-3.2/src/ui/filesel.c 2008-04-07 19:24:49.000000000 -0500 @@ -209,12 +209,12 @@ } if (uih->palette->type & BITMAPS) xprint (uih->image, uih->font, filex + 2 * BORDERWIDTH, ypos, - snames[i + namestart], + snames[i + namestart], uih->encoding i + namestart == selectedname ? FGCOLOR (uih) : BGCOLOR (uih), BGCOLOR (uih), TEXT_PRESSED); else xprint (uih->image, uih->font, filex + 2 * BORDERWIDTH, ypos, - snames[i + namestart], (i + namestart) == selectedname + snames[i + namestart], uih->encoding, (i + namestart) == selectedname && active == AFILELIST ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), 0); ypos += h; @@ -244,13 +244,13 @@ if (uih->palette->type & BITMAPS) xprint (uih->image, uih->font, filex + filewidth / 2 + 2 * BORDERWIDTH, ypos, - sdirs[i + dirstart], + sdirs[i + dirstart], uih->encoding, i + dirstart == selecteddir ? FGCOLOR (uih) : BGCOLOR (uih), BGCOLOR (uih), TEXT_PRESSED); else xprint (uih->image, uih->font, filex + filewidth / 2 + 2 * BORDERWIDTH, ypos, - sdirs[i + dirstart], (i + dirstart) == selecteddir + sdirs[i + dirstart], uih->encoding, (i + dirstart) == selecteddir && active == ADIRLIST ? SELCOLOR (uih) : FGCOLOR (uih), BGCOLOR (uih), 0); ypos += h; diff -ur XaoS-3.2.orig/src/ui/ui.c XaoS-3.2/src/ui/ui.c --- XaoS-3.2.orig/src/ui/ui.c 2004-11-24 01:11:46.000000000 -0600 +++ XaoS-3.2/src/ui/ui.c 2008-04-07 19:34:17.000000000 -0500 @@ -452,63 +452,63 @@ int h = xtextheight (uih->font); sprintf (str, gettext ("Fractal name:%s"), uih->fcontext->currentformula->name[!uih->fcontext->mandelbrot]); - xprint (uih->image, uih->font, 0, statusstart, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("Fractal type:%s"), uih->fcontext-> mandelbrot ? gettext ("Mandelbrot") : gettext ("Julia")); - xprint (uih->image, uih->font, 0, statusstart + h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("View:[%1.12f,%1.12f]"), (double) uih->fcontext->s.cr, (double) uih->fcontext->s.ci); - xprint (uih->image, uih->font, 0, statusstart + 2 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 2 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("size:[%1.12f,%1.12f]"), (double) uih->fcontext->s.rr, (double) uih->fcontext->s.ri); - xprint (uih->image, uih->font, 0, statusstart + 3 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 3 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("Rotation:%4.2f Screen size:%i:%i"), (double) uih->fcontext->angle, uih->image->width, uih->image->height); - xprint (uih->image, uih->font, 0, statusstart + 4 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 4 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("Iterations:%-4i Palette size:%i"), uih->fcontext->maxiter, uih->image->palette->size); - xprint (uih->image, uih->font, 0, statusstart + 5 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 5 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, "Bailout:%4.2f", (double) uih->fcontext->bailout); - xprint (uih->image, uih->font, 0, statusstart + 6 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 6 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("Autopilot:%-4s Plane:%s"), uih->autopilot ? gettext ("On") : gettext ("Off"), planename[uih->fcontext->plane]); - xprint (uih->image, uih->font, 0, statusstart + 7 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 7 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("incoloring:%s outcoloring:%s"), incolorname[uih->fcontext->incoloringmode], outcolorname[uih->fcontext->coloringmode]); - xprint (uih->image, uih->font, 0, statusstart + 8 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 8 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, gettext ("zoomspeed:%f"), (float) uih->maxstep * 1000); - xprint (uih->image, uih->font, 0, statusstart + 9 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 9 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); if (uih->fcontext->mandelbrot) strcpy (str, gettext ("Parameter:none")); else sprintf (str, gettext ("Parameter:[%f,%f]"), (float) uih->fcontext->pre, (float) uih->fcontext->pim); - xprint (uih->image, uih->font, 0, statusstart + 10 * h, str, FGCOLOR (uih), + xprint (uih->image, uih->font, 0, statusstart + 10 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); #ifdef MEMCHECK { struct mallinfo i = mallinfo (); sprintf (str, "Allocated arena:%i Wasted:%i %i", i.arena, i.ordblks, i.fordblks); - xprint (uih->image, uih->font, 0, statusstart + 11 * h, str, + xprint (uih->image, uih->font, 0, statusstart + 11 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); sprintf (str, "Mmaped blocks%i Mmaped area:%i keep:%i", i.hblks, i.hblkhd, i.keepcost); - xprint (uih->image, uih->font, 0, statusstart + 12 * h, str, + xprint (uih->image, uih->font, 0, statusstart + 12 * h, str, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); } #endif @@ -548,7 +548,7 @@ static void ui_drawministatus (uih_context * uih, void *data) { - xprint (uih->image, uih->font, 0, ministatusstart, statustext, + xprint (uih->image, uih->font, 0, ministatusstart, statustext, uih->encoding, FGCOLOR (uih), BGCOLOR (uih), 0); } static void diff -ur XaoS-3.2.orig/src/ui/uihelp.c XaoS-3.2/src/ui/uihelp.c --- XaoS-3.2.orig/src/ui/uihelp.c 2004-11-24 01:11:47.000000000 -0600 +++ XaoS-3.2/src/ui/uihelp.c 2008-04-07 19:27:47.000000000 -0500 @@ -227,7 +227,7 @@ fgcolor = SELCOLOR (uih); } } - xprint (uih->image, uih->font, x + helpx, y + helpy, curritem->text, + xprint (uih->image, uih->font, x + helpx, y + helpy, curritem->text, 0, fgcolor, bgcolor, flags); curritem = curritem->next; } diff -ur XaoS-3.2.orig/src/ui/uimenu.c XaoS-3.2/src/ui/uimenu.c --- XaoS-3.2.orig/src/ui/uimenu.c 2003-01-08 05:35:57.000000000 -0600 +++ XaoS-3.2/src/ui/uimenu.c 2008-04-07 19:27:27.000000000 -0500 @@ -155,7 +155,7 @@ s[1] = 0; if (!(m->flags & MENU_HORIZONTAL)) xprint (c->image, c->font, m->x + (m->width - m->namewidth) / 2, - m->y + BORDERWIDTH, m->fullname, SELCOLOR (c), BGCOLOR (c), 0); + m->y + BORDERWIDTH, m->fullname, c->encoding, SELCOLOR (c), BGCOLOR (c), 0); for (i = 0; i < m->n; i++) { int color = (i == m->selected ? SELCOLOR (c) : FGCOLOR (c)); @@ -182,15 +182,15 @@ s[0] = '0' + (i == 9 ? 0 : i + 1); else s[0] = 'A' + (i - 10); - xprint (c->image, c->font, m->items[i].x, m->items[i].y, s, color, + xprint (c->image, c->font, m->items[i].x, m->items[i].y, s, c->encoding, color, BGCOLOR (c), pressed); if (menu_enabled (m->items[i].item, uih)) { xprint (c->image, c->font, m->items[i].x + width1, - m->items[i].y, "X", color, BGCOLOR (c), pressed); + m->items[i].y, "X", c->encoding, color, BGCOLOR (c), pressed); } xprint (c->image, c->font, m->items[i].x + width1 + MENUPAUSE, - m->items[i].y, m->items[i].item->name, color, BGCOLOR (c), + m->items[i].y, m->items[i].item->name, c->encoding, color, BGCOLOR (c), pressed); if (m->items[i].item->key) { @@ -198,18 +198,18 @@ sprintf (ch, " %s ", m->items[i].item->key); xprint (c->image, c->font, m->items[i].x + m->items[i].width - SUBMENUWIDTH - - xtextwidth (uih->font, ch), m->items[i].y, ch, + xtextwidth (uih->font, ch), m->items[i].y, ch, c->encoding, LIGHTGRAYCOLOR (c), BGCOLOR (c), pressed); } if (m->items[i].item->type == MENU_SUBMENU) xprint (c->image, c->font, m->items[i].x + m->items[i].width - SUBMENUWIDTH, - m->items[i].y, ">", color, BGCOLOR (c), pressed); + m->items[i].y, ">", c->encoding, color, BGCOLOR (c), pressed); } else { xprint (c->image, c->font, m->items[i].x, m->items[i].y, - m->items[i].item->name, color, BGCOLOR (c), pressed); + m->items[i].item->name, c->encoding, color, BGCOLOR (c), pressed); if (m->items[i].item->key) { char ch[20]; @@ -217,7 +217,7 @@ xprint (c->image, c->font, m->items[i].x + xtextwidth (uih->font, m->items[i].item->name) + 2, - m->items[i].y, ch, LIGHTGRAYCOLOR (c), BGCOLOR (c), + m->items[i].y, ch, c->encoding, LIGHTGRAYCOLOR (c), BGCOLOR (c), pressed); } } diff -ur XaoS-3.2.orig/src/ui-hlp/messg.c XaoS-3.2/src/ui-hlp/messg.c --- XaoS-3.2.orig/src/ui-hlp/messg.c 2002-09-25 10:52:10.000000000 -0500 +++ XaoS-3.2/src/ui-hlp/messg.c 2008-04-07 19:36:25.000000000 -0500 @@ -42,11 +42,11 @@ w = xtextwidth (c->font, c->messg.message[n]); x = (c->image->width - w) / 2; if (c->messg.messagetype[n]) - xprint (c->image, c->font, x, y, c->messg.message[n], + xprint (c->image, c->font, x, y, c->messg.message[n], c->encoding, (c->image->flags & AAIMAGE) ? BGCOLOR (c) : SELCOLOR (c), BGCOLOR (c), 0); else - xprint (c->image, c->font, x, y, c->messg.message[n], + xprint (c->image, c->font, x, y, c->messg.message[n], c->encoding, (c->image->flags & AAIMAGE) ? BGCOLOR (c) : FGCOLOR (c), BGCOLOR (c), 0); } diff -ur XaoS-3.2.orig/src/ui-hlp/playtext.c XaoS-3.2/src/ui-hlp/playtext.c --- XaoS-3.2.orig/src/ui-hlp/playtext.c 2002-09-25 10:52:10.000000000 -0500 +++ XaoS-3.2/src/ui-hlp/playtext.c 2008-04-07 19:35:53.000000000 -0500 @@ -155,7 +155,7 @@ break; } string += - xprint (c->image, c->font, x, y, string, fgcolor, bgcolor, flags) + 1; + xprint (c->image, c->font, x, y, string, 0, fgcolor, bgcolor, flags) + 1; y += xtextheight (c->font); } }