From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Non-ASCII in Lucid menus Date: Sat, 12 Mar 2005 18:47:25 -0500 Message-ID: <877jkce8lv.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1110672364 20187 80.91.229.2 (13 Mar 2005 00:06:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 13 Mar 2005 00:06:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 13 01:06:04 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DAGcG-0003zi-Oe for ged-emacs-devel@m.gmane.org; Sun, 13 Mar 2005 01:05:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DAGrd-0003nA-U3 for ged-emacs-devel@m.gmane.org; Sat, 12 Mar 2005 19:21:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DAGnT-0002d9-2J for emacs-devel@gnu.org; Sat, 12 Mar 2005 19:17:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DAGn3-0002VB-It for emacs-devel@gnu.org; Sat, 12 Mar 2005 19:17:21 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DAGmz-0002PT-6v for emacs-devel@gnu.org; Sat, 12 Mar 2005 19:17:01 -0500 Original-Received: from [209.226.175.184] (helo=tomts22-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DAGKM-0007fK-Pk for emacs-devel@gnu.org; Sat, 12 Mar 2005 18:47:26 -0500 Original-Received: from alfajor ([65.92.241.52]) by tomts22-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050312234726.XBBK1919.tomts22-srv.bellnexxia.net@alfajor>; Sat, 12 Mar 2005 18:47:26 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id D083A2FDED; Sat, 12 Mar 2005 18:47:25 -0500 (EST) Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34528 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34528 The patch below makes the Lucid menu use fontsets to draw its text, so that it's able to write non-ASCII (the set of chars supported is dependent on the locale, and of course on the fonts). I'm very much an idiot when it comes to X11 programming, xfaces.c, and lwlib, so this might be riddled with bugs and misunderstandings, but after some trial-and-error this not only works for me, but it even looks sensible to me. Any objection? Stefan PS: The use of XrmPutLineResource in xfaces.c seems amazingly brittle and hackish, but that's what the rest of the code uses. Index: src/xfaces.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xfaces.c,v retrieving revision 1.314 diff -u -r1.314 xfaces.c --- src/xfaces.c 18 Feb 2005 22:55:53 -0000 1.314 +++ src/xfaces.c 12 Mar 2005 23:40:23 -0000 @@ -4695,6 +4695,17 @@ #else const char *suffix = ""; #endif +#ifdef HAVE_X_I18N + extern char *xic_create_fontsetname P_ ((char *base_fontname)); + const char *fontsetname = xic_create_fontsetname (face->font_name); + sprintf (line, "%s.pane.menubar*fontSet: %s", + myname, fontsetname); + XrmPutLineResource (&rdb, line); + sprintf (line, "%s.%s*fontSet: %s", + myname, popup_path, fontsetname); + XrmPutLineResource (&rdb, line); + xfree (fontsetname); +#endif sprintf (line, "%s.pane.menubar*font%s: %s", myname, suffix, face->font_name); XrmPutLineResource (&rdb, line); Index: src/coding.h =================================================================== RCS file: /cvsroot/emacs/emacs/src/coding.h,v retrieving revision 1.70 diff -u -r1.70 coding.h --- src/coding.h 30 Nov 2004 08:01:45 -0000 1.70 +++ src/coding.h 12 Mar 2005 23:40:23 -0000 @@ -591,9 +591,8 @@ ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ : name)) -#ifdef WINDOWSNT /* Encode the string STR using the specified coding system - for w32 system functions, if any. */ + for system functions, if any. */ #define ENCODE_SYSTEM(str) \ (! NILP (Vlocale_coding_system) \ && !EQ (Vlocale_coding_system, make_number (0)) \ @@ -601,20 +600,13 @@ : str) /* Decode the string STR using the specified coding system - for w32 system functions, if any. */ + for system functions, if any. */ #define DECODE_SYSTEM(name) \ (! NILP (Vlocale_coding_system) \ && !EQ (Vlocale_coding_system, make_number (0)) \ ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ : str) -#else /* WINDOWSNT */ - -#define ENCODE_SYSTEM(str) string_make_unibyte(str) -#define DECODE_SYSTEM(name) name - -#endif /* !WINDOWSNT */ - #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) /* Extern declarations. */ Index: lwlib/xlwmenuP.h =================================================================== RCS file: /cvsroot/emacs/emacs/lwlib/xlwmenuP.h,v retrieving revision 1.9 diff -u -r1.9 xlwmenuP.h --- lwlib/xlwmenuP.h 12 Mar 2005 23:38:43 -0000 1.9 +++ lwlib/xlwmenuP.h 12 Mar 2005 23:40:23 -0000 @@ -44,6 +44,9 @@ { /* slots set by the resources */ XFontStruct* font; +#ifdef HAVE_X_I18N + XFontSet fontset; +#endif Pixel foreground; Pixel disabled_foreground; Pixel button_foreground; Index: lwlib/xlwmenu.c =================================================================== RCS file: /cvsroot/emacs/emacs/lwlib/xlwmenu.c,v retrieving revision 1.61 diff -u -r1.61 xlwmenu.c --- lwlib/xlwmenu.c 27 Dec 2004 15:22:36 -0000 1.61 +++ lwlib/xlwmenu.c 12 Mar 2005 23:40:23 -0000 @@ -137,6 +137,10 @@ { {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(menu.font),XtRString, "XtDefaultFont"}, +#ifdef HAVE_X_I18N + {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), + offset(menu.fontset), XtRString, "XtDefaultFontSet"}, +#endif {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(menu.foreground), XtRString, "XtDefaultForeground"}, {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel), @@ -353,11 +357,17 @@ XlwMenuWidget mw; char *s; { +#ifdef HAVE_X_I18N + XRectangle ink, logical; + XmbTextExtents (mw->menu.fontset, s, strlen (s), &ink, &logical); + return logical.width; +#else XCharStruct xcs; int drop; XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs); return xcs.width; +#endif } static int @@ -1028,7 +1038,12 @@ x_offset += ws->button_width; - XDrawString (XtDisplay (mw), ws->window, text_gc, x_offset, +#ifdef HAVE_X_I18N + XmbDrawString (XtDisplay (mw), ws->window, mw->menu.fontset, +#else + XDrawString (XtDisplay (mw), ws->window, +#endif + text_gc, x_offset, y + v_spacing + shadow + font_ascent, display_string, strlen (display_string)); @@ -1053,7 +1068,12 @@ } else if (val->key) { - XDrawString (XtDisplay (mw), ws->window, text_gc, +#ifdef HAVE_X_I18N + XmbDrawString (XtDisplay (mw), ws->window, mw->menu.fontset, +#else + XDrawString (XtDisplay (mw), ws->window, +#endif + text_gc, x + label_width + mw->menu.arrow_spacing, y + v_spacing + shadow + font_ascent, val->key, strlen (val->key));