unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Non-ASCII in Lucid menus
@ 2005-03-12 23:47 Stefan Monnier
  2005-03-13 11:06 ` Jan D.
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Stefan Monnier @ 2005-03-12 23:47 UTC (permalink / raw)


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));

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: Non-ASCII in Lucid menus
@ 2005-03-18 21:26 Jan D.
  2005-03-18 22:06 ` Stefan Monnier
  0 siblings, 1 reply; 25+ messages in thread
From: Jan D. @ 2005-03-18 21:26 UTC (permalink / raw)
  Cc: Emacs-Devel

Stefan Monnier wrote:

>OTOH, dynamically changing the font by tweaking the `menu' face
>doesn't seem to work on the menu bar.
>

It should work now to change the Motif menu bar by changing the menu face.

    Jan D.

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2005-03-20 11:46 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-12 23:47 Non-ASCII in Lucid menus Stefan Monnier
2005-03-13 11:06 ` Jan D.
2005-03-13 13:44   ` Stefan Monnier
2005-03-13 17:45     ` Jan D.
2005-03-14 20:23       ` Stefan Monnier
2005-03-14 20:56         ` Jan D.
2005-03-14 23:03           ` Miles Bader
2005-03-16 15:36       ` Stefan Monnier
2005-03-16 21:32         ` Jan D.
2005-03-16 23:13           ` Stefan Monnier
2005-03-16 23:38             ` Stefan Monnier
2005-03-17  7:12             ` Jan D.
2005-03-17 13:57               ` Stefan Monnier
2005-03-17 23:01         ` Richard Stallman
2005-03-18  4:32           ` Stefan Monnier
2005-03-18 18:20             ` Richard Stallman
2005-03-18 21:00               ` Stefan Monnier
2005-03-20  0:22                 ` Richard Stallman
2005-03-20  0:50                   ` Stefan Monnier
2005-03-20  3:21                     ` David Kastrup
2005-03-20 11:46                     ` Jan D.
2005-03-13 18:49 ` David Kastrup
2005-03-14  3:00 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-03-18 21:26 Jan D.
2005-03-18 22:06 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).