--- programs/xterm/charproc.c.xterm_bold_noluit 2004-01-03 18:36:42.000000000 +0100 +++ programs/xterm/charproc.c 2004-01-08 17:54:53.842813464 +0100 @@ -85,6 +85,8 @@ #include #include +#define HAVE_LANGINFO_CODESET /* FIXME */ + #include #include #include @@ -128,6 +130,10 @@ #include #include +#ifdef HAVE_LANGINFO_CODESET +#include +#endif + #if OPT_ZICONBEEP || OPT_TOOLBAR #define HANDLE_STRUCT_NOTIFY 1 #else @@ -4719,6 +4719,9 @@ { char *locale; Boolean is_utf8; +#ifdef HAVE_LANGINFO_CODESET + char *encoding; +#endif TRACE(("VTInitialize_locale\n")); TRACE(("... request screen.utf8_mode = %d\n", request->screen.utf8_mode)); @@ -4728,12 +4731,15 @@ if ((locale = getenv("LANG")) == 0 || *locale == '\0') locale = ""; #ifdef HAVE_LANGINFO_CODESET - is_utf8 = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0); + encoding = nl_langinfo(CODESET); + is_utf8 = (strcmp(encoding, "UTF-8") == 0); #else is_utf8 = (strstr(locale, "UTF-8") != NULL); #endif TRACE(("... is_utf8 = %s\n", BtoS(is_utf8))); + request->screen.latin9_mode = 0; + request->screen.unicode_font = 0; #if OPT_LUIT_PROG request->misc.callfilter = 0; request->misc.use_encoding = 0; @@ -4741,7 +4747,34 @@ TRACE(("... setup for luit:\n")); TRACE(("... request misc.locale_str = \"%s\"\n", request->misc.locale_str)); - if (x_strcasecmp(request->misc.locale_str, "TRUE") == 0 || + if (x_strcasecmp(request->misc.locale_str, "CHECKFONT") == 0) { + int fl = request->misc.default_font.f_n ? strlen(request->misc.default_font.f_n) : 0; + if (fl > 11 && x_strcasecmp(request->misc.default_font.f_n + fl - 11, "-ISO10646-1") == 0) { + request->screen.unicode_font = 1; + /* unicode font, use TRUE */ +#ifdef HAVE_LANGINFO_CODESET + if (!strcmp(encoding, "ANSI_X3.4-1968") || !strcmp(encoding, "ISO-8859-1")) { + if (request->screen.utf8_mode == 3) + request->screen.utf8_mode = 0; + } else if (!strcmp(encoding, "ISO-8859-15")) { + if (request->screen.utf8_mode == 3) + request->screen.utf8_mode = 0; + request->screen.latin9_mode = 1; + } else { + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = 2; + } +#else + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = 2; +#endif + } else { + /* other encoding, use FALSE */ + if (request->screen.utf8_mode == 3) { + request->screen.utf8_mode = is_utf8 ? 2 : 0; + } + } + } else if (x_strcasecmp(request->misc.locale_str, "TRUE") == 0 || x_strcasecmp(request->misc.locale_str, "ON") == 0 || x_strcasecmp(request->misc.locale_str, "YES") == 0 || x_strcasecmp(request->misc.locale_str, "AUTO") == 0 || @@ -4999,7 +5038,15 @@ } else { wnew->screen.utf8_mode = 0; } + if (request->screen.latin9_mode) { + wnew->screen.latin9_mode = True; + } + if (request->screen.unicode_font) { + wnew->screen.unicode_font = True; + } TRACE(("initialized UTF-8 mode to %d\n", wnew->screen.utf8_mode)); + TRACE(("initialized Latin9 mode to %d\n", wnew->screen.latin9_mode)); + TRACE(("initialized unicode_font to %d\n", wnew->screen.unicode_font)); if (wnew->screen.wide_chars != False) wnew->num_ptrs = (OFF_COM2H + 1); --- programs/xterm/fontutils.c.xterm_bold_noluit 2004-01-03 18:36:50.000000000 +0100 +++ programs/xterm/fontutils.c 2004-01-08 18:01:21.072467929 +0100 @@ -871,7 +871,7 @@ for (ch = 1; ch < 32; ch++) { int n = ch; #if OPT_WIDE_CHARS - if (screen->utf8_mode) { + if (screen->utf8_mode || screen->unicode_font) { n = dec2ucs(ch); if (n == UCS_REPL) continue; --- programs/xterm/ptyx.h.xterm_bold_noluit 2004-01-03 18:36:51.000000000 +0100 +++ programs/xterm/ptyx.h 2004-01-08 17:54:53.848812452 +0100 @@ -1130,6 +1130,9 @@ Boolean wide_chars; /* true when 16-bit chars */ Boolean vt100_graphics; /* true to allow vt100-graphics */ int utf8_mode; /* use UTF-8 decode/encode: 0-2 */ + int latin9_mode; /* poor man's luit, do + * latin9 encoding */ + int unicode_font; /* font uses unicode encoding */ int utf_count; /* state of utf_char */ IChar utf_char; /* in-progress character */ #endif --- programs/xterm/util.c.xterm_bold_noluit 2003-10-29 23:48:29.000000000 +0100 +++ programs/xterm/util.c 2004-01-08 18:04:51.704916187 +0100 @@ -1846,7 +1846,7 @@ y += FontAscent(screen); #if OPT_WIDE_CHARS - if (screen->wide_chars) { + if (screen->wide_chars || screen->unicode_font) { int ascent_adjust = 0; static XChar2b *sbuf; static Cardinal slen; @@ -1862,6 +1862,38 @@ for (n = 0; n < len; n++) { sbuf[n].byte2 = *text; sbuf[n].byte1 = *text2; + if (screen->latin9_mode && !screen->utf8_mode && *text2 == 0) { + if (*text == 0xa4) { + sbuf[n].byte2 = 0xac; + sbuf[n].byte1 = 0x20; + } else if (*text == 0xa6) { + sbuf[n].byte2 = 0x60; + sbuf[n].byte1 = 0x01; + } else if (*text == 0xa8) { + sbuf[n].byte2 = 0x61; + sbuf[n].byte1 = 0x01; + } else if (*text == 0xb4) { + sbuf[n].byte2 = 0x7d; + sbuf[n].byte1 = 0x01; + } else if (*text == 0xb8) { + sbuf[n].byte2 = 0x7e; + sbuf[n].byte1 = 0x01; + } else if (*text == 0xbc) { + sbuf[n].byte2 = 0x52; + sbuf[n].byte1 = 0x01; + } else if (*text == 0xbd) { + sbuf[n].byte2 = 0x53; + sbuf[n].byte1 = 0x01; + } else if (*text == 0xbe) { + sbuf[n].byte2 = 0x78; + sbuf[n].byte1 = 0x01; + } + } + if (screen->unicode_font && *text2 == 0 && (*text == 0x7f || *text < 0x20)) { + int ni = dec2ucs(*text == 0x7f ? 0 : *text); + sbuf[n].byte2 = ni & 0xff; + sbuf[n].byte1 = ni >> 8; + } text++; text2++; if (wideness) {