[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Non-ASCII in Lucid menus
From: |
Stefan Monnier |
Subject: |
Non-ASCII in Lucid menus |
Date: |
Sat, 12 Mar 2005 18:47:25 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
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));
- Non-ASCII in Lucid menus,
Stefan Monnier <=
- Re: Non-ASCII in Lucid menus, Jan D., 2005/03/13
- Re: Non-ASCII in Lucid menus, Stefan Monnier, 2005/03/16
- Re: Non-ASCII in Lucid menus, Jan D., 2005/03/16
- Re: Non-ASCII in Lucid menus, Stefan Monnier, 2005/03/16
- Re: Non-ASCII in Lucid menus, Stefan Monnier, 2005/03/16