From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Non-ASCII in Lucid menus
Date: Sat, 12 Mar 2005 18:47:25 -0500 [thread overview]
Message-ID: <877jkce8lv.fsf-monnier+emacs@gnu.org> (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));
next reply other threads:[~2005-03-12 23:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-12 23:47 Stefan Monnier [this message]
2005-03-13 11:06 ` Non-ASCII in Lucid menus 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877jkce8lv.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).