tags 531036 + patch
kthxbye

Hi,

while the ratmen UTF-8 patch doesn't apply using patch, it does apply
quite well manually.

Here's a new, applying and working patch including changelog entries,
etc. To ease the upgrade for me from this version to the one hopefully
you will release soon, I gave my version the number 2.3.19+utf8 while
I do expect the next version to be 2.3.20:

diff -ru ratmenu-2.3.19/debian/changelog ratmenu-2.3.19+utf8/debian/changelog
--- ratmenu-2.3.19/debian/changelog     2009-12-03 08:27:55.000000000 +0100
+++ ratmenu-2.3.19+utf8/debian/changelog        2010-03-17 22:46:13.000000000 
+0100
@@ -1,3 +1,12 @@
+ratmenu (2.3.19+utf8) unstable; urgency=low
+
+  [Axel Beckert]
+  * Port UTF-8 patch for ratmen
+    (http://www.rubyist.net/~rubikitch/computer/ratmen/i18n.patch) to
+    ratmenu.
+
+ -- Axel Beckert <a...@debian.org>  Wed, 17 Mar 2010 22:45:00 +0100
+
 ratmenu (2.3.19) unstable; urgency=low
 
   * debian/control: version debhelper depends (lintian
diff -ru ratmenu-2.3.19/ratmenu.c ratmenu-2.3.19+utf8/ratmenu.c
--- ratmenu-2.3.19/ratmenu.c    2008-09-28 03:44:52.000000000 +0200
+++ ratmenu-2.3.19+utf8/ratmenu.c       2010-03-17 22:38:02.000000000 +0100
@@ -67,12 +67,16 @@
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
 #include <X11/Xresource.h>
+#include <X11/Xlocale.h>
 
 char version[] = "@(#) ratmenu version 2.3";
 
 #define FONT "9x15bold"
 #define        MenuMask (ExposureMask|StructureNotifyMask|KeyPressMask)
 #define CTL(c) (c - '`')
+#define XTextWidth XmbTextEscapement
+#define XLoadQueryFont XLoadQueryFontSet
+XFontSet XLoadQueryFontSet(Display *, const char *);
 
 Display *dpy;          /* lovely X stuff */
 int screen;
@@ -85,7 +89,8 @@
 char *bgcname = NULL;
 Colormap dcmap;
 XColor color;
-XFontStruct *font;
+XFontSet font;
+short font__ascent, font__descent;
 Atom wm_protocols;
 Atom wm_delete_window;
 int g_argc;                    /* for XSetWMProperties to use */
@@ -125,6 +130,24 @@
 void xresources(void);
 void defaults(void);
 
+XFontSet XLoadQueryFontSet(Display *disp, const char *fontset_name)
+{
+  XFontSet fontset;
+  int  missing_charset_count;
+  char **missing_charset_list;
+  char *def_string;
+  
+  fontset = XCreateFontSet(disp, fontset_name,
+                           &missing_charset_list, &missing_charset_count,
+                           &def_string);
+  if (missing_charset_count /* && debug */) {
+    fprintf(stderr, "Missing charsets in FontSet(%s) creation.\n", 
fontset_name);
+    XFreeStringList(missing_charset_list);
+  }
+  return fontset;
+}
+
+
 /* main --- crack arguments, set up X stuff, run the main menu loop */
 
 int
@@ -134,10 +157,13 @@
        char *cp;
        XGCValues gv;
        unsigned long mask;
+       XFontSetExtents *extent;
 
        g_argc = argc;
        g_argv = argv;
 
+       setlocale(LC_CTYPE, "");
+
        /* set default label name */
        if ((cp = strrchr(argv[0], '/')) == NULL)
                labelname = argv[0];
@@ -235,13 +261,15 @@
                fprintf(stderr, "%s: fatal: cannot load font %s\n", progname, 
fontname);
                exit(1);
        }
+       extent = XExtentsOfFontSet(font);
+       font__ascent = extent->max_logical_extent.height * 4 / 5;
+       font__descent = extent->max_logical_extent.height / 5;
 
        gv.foreground = fg^bg;
        gv.background = bg;
-       gv.font = font->fid;
        gv.function = GXxor;
        gv.line_width = 0;
-       mask = GCForeground | GCBackground | GCFunction | GCFont | GCLineWidth;
+       mask = GCForeground | GCBackground | GCFunction | GCLineWidth;
 
        root = RootWindow(dpy, screen);
        gc = XCreateGC(dpy, root, mask, &gv);
@@ -313,7 +341,7 @@
        }
        wide = dx;
 
-       high = font->ascent + font->descent + 1;
+       high = font__ascent + font__descent + 1;
        visible = dpyheight / high;
        if (visible > numitems) { visible = numitems; }
        dy = visible * high;
@@ -501,8 +529,8 @@
                } else {/* align == right */
                        tx = wide - XTextWidth(font, labels[j], 
strlen(labels[j]));
                }
-                ty = i*high + font->ascent + 1;
-                XDrawString(dpy, menuwin, gc, tx, ty, labels[j], 
strlen(labels[j]));
+                ty = i*high + font__ascent + 1;
+                XmbDrawString(dpy, menuwin, font, gc, tx, ty, labels[j], 
strlen(labels[j]));
        }
        XFillRectangle(dpy, menuwin, gc, 0, 0, wide, high); 
 }
@@ -528,8 +556,8 @@
                        } else {/* align == right */
                                tx = wide - XTextWidth(font, labels[i+off], 
strlen(labels[i+off]));
                        }
-                       ty = i*high + font->ascent + 1;
-                       XDrawString(dpy, menuwin, gc, tx, ty, labels[i+off], 
strlen(labels[i+off]));
+                       ty = i*high + font__ascent + 1;
+                       XmbDrawString(dpy, menuwin, font, gc, tx, ty, 
labels[i+off], strlen(labels[i+off]));
                }
                XFillRectangle(dpy, menuwin, gc, 0, (curitem-off)*high, wide, 
high); 
        } else {

You may also want to check the line where I just commented out an in
ratmenu non-existing debug flag.

One small optimization I saw in ratmen, was not to calculate i+off
several times but to store it once in a variable j. Which was also one
of the reasons why the original patch didn't apply.

Looking forward to see ratmenu with UTF-8 support in Debian. Then I
can ditch my locally created ratmen package again. :-)

                Regards, Axel
-- 
 ,''`.  |  Axel Beckert <a...@debian.org>, http://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE
  `-    |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to