[PATCH] xft and menus recoding from local charset to utf8
- From: Anton Kazennikov <kazen su29 ru>
- To: sawfish-list gnome org
- Subject: [PATCH] xft and menus recoding from local charset to utf8
- Date: Mon, 14 Feb 2005 23:59:52 +0300
Hi.
I like sawfish very much, but I'm russian and cyrillic charset causes some
problems with it. I use KOI8-R charset since not all programs which I
use are compatible with UTF8.
I use xft font rendering since pango is broken(I have pango 1.8.0 and it
displays all text in single font). The problem with xft is that xft don't
displays russian character correctly. It is needed to recode a string to utf8
before displaying it. The included patch is a small modification of a patch
that was already submitted here:
http://mail.gnome.org/archives/sawfish-list/2003-August/msg00016.html
Another patch is for window-list menu. There are similar problems: cyrillic
characters aren't displayed at all. The patch is a very little modification
of the already submitted:
http://mail.gnome.org/archives/sawfish-list/2003-August/msg00011.html
At present, if glib isn't found the patch does nothing.
--
With best regards,
Anton Kazennikov. mailto:ant[at]sendmail.ru ICQ# 98965967
diff -c -r sawfish.orig/config.h.in sawfish/config.h.in
*** sawfish.orig/config.h.in Thu Aug 14 11:17:24 2003
--- sawfish/config.h.in Mon Feb 14 21:07:34 2005
***************
*** 148,151 ****
--- 148,154 ----
#undef HAVE_PANGO_X
#undef HAVE_PANGO_XFT
+ /* Define if you have glib */
+ #undef HAVE_GLIB
+
#endif /* SAWMILL_CONFIG_H */
Only in sawfish: configure
diff -c -r sawfish.orig/configure.in sawfish/configure.in
*** sawfish.orig/configure.in Sat Aug 16 22:37:03 2003
--- sawfish/configure.in Mon Feb 14 23:10:56 2005
***************
*** 120,126 ****
CPPFLAGS="${_cppflags}"
! dnl Checks for pango
PKG_CHECK_MODULES(PANGO, pango >= 1.2.0,
[if $PKG_CONFIG --exists pangoxft; then
AC_DEFINE(HAVE_PANGO_XFT, 1)
--- 120,133 ----
CPPFLAGS="${_cppflags}"
! dnl Checks for pango. Disabled by default
!
! AC_ARG_WITH(pango,
! [ --with-pango Enable pango font rendering engine
! --without-pango], [],
! [with_pango=no])
!
! if test "${with_pango}" = "yes"; then
PKG_CHECK_MODULES(PANGO, pango >= 1.2.0,
[if $PKG_CONFIG --exists pangoxft; then
AC_DEFINE(HAVE_PANGO_XFT, 1)
***************
*** 135,140 ****
--- 142,148 ----
PANGO_LIBS=`$PKG_CONFIG --libs $PANGO_MODULES`
PANGO_CFLAGS=`$PKG_CONFIG --cflags $PANGO_MODULES`
fi], [: nothing])
+ fi
dnl Check for librep
AM_PATH_REP(0.14)
***************
*** 240,245 ****
--- 248,264 ----
AC_DEFINE(HAVE_ESD)
fi
+ AC_ARG_WITH(glib,
+ [ --with-glib Use glib for locale -> utf8
+ --without-glib], [], [with_glib=yes])
+
+ if test "$with_glib" = "yes"; then
+ PKG_CHECK_MODULES(GLIB, glib-2.0 > 2.0)
+ AC_SUBST(GLIB_LIBS)
+ AC_SUBST(GLIB_CFLAGS)
+ AC_DEFINE(HAVE_GLIB)
+ fi
+
AC_ARG_ENABLE(capplet,
[ --enable-capplet Build the sawfish GNOME capplet [default]
--disable-capplet Don't built the capplet], [],
diff -c -r sawfish.orig/lisp/sawfish/wm/ext/beos-window-menu.jl sawfish/lisp/sawfish/wm/ext/beos-window-menu.jl
*** sawfish.orig/lisp/sawfish/wm/ext/beos-window-menu.jl Thu Aug 14 10:55:35 2003
--- sawfish/lisp/sawfish/wm/ext/beos-window-menu.jl Mon Feb 14 18:34:12 2005
***************
*** 25,30 ****
--- 25,31 ----
(export beos-window-menu)
(open rep
+ rep.regexp
sawfish.wm.windows
sawfish.wm.misc
sawfish.wm.custom
***************
*** 38,46 ****
(define (abbreviate name #!optional len)
(unless len (setq len 20))
! (if (> (length name) len)
! (concat (substring name 0 len) "...")
! name))
(define (make-label w)
(let ((name (window-name w))
--- 39,54 ----
(define (abbreviate name #!optional len)
(unless len (setq len 20))
! (setq name (locale-to-utf8 name))
! (let ((namelen (length name)))
! (let loop ((idx len))
! (cond ((>= idx namelen)
! name)
! ((string-match "[\200-\277]" (substring name idx (1+ idx)))
! ;; move to utf-8 mbchar boundary
! (loop (1+ idx)))
! (t
! (concat (substring name 0 idx) "..."))))))
(define (make-label w)
(let ((name (window-name w))
Only in sawfish.orig/po: sawfish.pot
diff -c -r sawfish.orig/src/fonts.c sawfish/src/fonts.c
*** sawfish.orig/src/fonts.c Mon Oct 18 02:58:17 2004
--- sawfish/src/fonts.c Mon Feb 14 22:28:53 2005
***************
*** 42,55 ****
#include <X11/Xlocale.h>
#include <ctype.h>
#ifdef HAVE_X11_XFT_XFT_H
# include <X11/Xft/Xft.h>
#else
# undef HAVE_PANGO
#endif
#ifdef HAVE_PANGO
- # include <glib.h>
# define PANGO_ENABLE_BACKEND
# include <pango/pango.h>
# undef PANGO_ENABLE_BACKEND
--- 42,59 ----
#include <X11/Xlocale.h>
#include <ctype.h>
+ #ifdef HAVE_GLIB
+ # include<glib.h>
+ #endif
+
#ifdef HAVE_X11_XFT_XFT_H
# include <X11/Xft/Xft.h>
#else
# undef HAVE_PANGO
#endif
+
#ifdef HAVE_PANGO
# define PANGO_ENABLE_BACKEND
# include <pango/pango.h>
# undef PANGO_ENABLE_BACKEND
***************
*** 364,372 ****
xft_measure (Lisp_Font *f, u_char *string, size_t length)
{
XGlyphInfo info;
!
! XftTextExtents8 (dpy, f->font, string, length, &info);
!
return info.xOff;
}
--- 368,389 ----
xft_measure (Lisp_Font *f, u_char *string, size_t length)
{
XGlyphInfo info;
! #ifdef HAVE_GLIB
! gsize r, w;
! u_char *utf8str;
! utf8str = g_locale_to_utf8 (string, length, &r, &w, NULL);
! if (utf8str != NULL){
! string = utf8str;
! length = w;
! }
!
! XftTextExtentsUtf8 (dpy, f->font, string, length, &info);
!
! g_free(utf8str);
! #else
! XftTextExtents8 (dpy, f->font, string, length, &info);
! #endif
!
return info.xOff;
}
***************
*** 375,380 ****
--- 392,401 ----
Window id, GC gc, Lisp_Color *fg, int x, int y)
{
static XftDraw *draw;
+ #ifdef HAVE_GLIB
+ gsize r, w;
+ u_char *utf8str;
+ #endif
XftColor xft_color;
***************
*** 389,396 ****
--- 410,430 ----
xft_color.color.blue = fg->blue;
xft_color.color.alpha = fg->alpha;
+ #ifdef HAVE_GLIB
+ utf8str = g_locale_to_utf8 (string, length, &r, &w, NULL);
+ if (utf8str != NULL){
+ string = utf8str;
+ length = w;
+ }
+
+ XftDrawStringUtf8 (draw, &xft_color, f->font,
+ x, y, string, length);
+ g_free(utf8str);
+ #else
XftDrawString8 (draw, &xft_color, f->font,
x, y, string, length);
+ #endif
+
}
static const Lisp_Font_Class xft_class = {
diff -c -r sawfish.orig/src/functions.c sawfish/src/functions.c
*** sawfish.orig/src/functions.c Tue Feb 8 15:47:54 2005
--- sawfish/src/functions.c Mon Feb 14 21:57:59 2005
***************
*** 43,49 ****
#include "sawmill.h"
#include <string.h>
#include <X11/Xatom.h>
!
/* Number of outstanding server grabs made; only when this is zero is
the server ungrabbed. */
static int server_grabs;
--- 43,51 ----
#include "sawmill.h"
#include <string.h>
#include <X11/Xatom.h>
! #ifdef HAVE_GLIB
! #include <glib.h>
! #endif
/* Number of outstanding server grabs made; only when this is zero is
the server ungrabbed. */
static int server_grabs;
***************
*** 1320,1325 ****
--- 1322,1358 ----
}
}
+ DEFUN("locale-to-utf8", Flocale_to_utf8, Slocale_to_utf8,
+ (repv src), rep_Subr1)
+ {
+ #ifdef HAVE_GLIB
+ gsize r, w;
+ u_char *utf8str;
+ repv res;
+
+ rep_DECLARE1 (src, rep_STRINGP);
+
+ utf8str = g_locale_to_utf8 (rep_STR (src), -1, &r, &w, NULL);
+ if (utf8str == NULL) {
+ return src;
+ }
+
+ res = rep_make_string (w + 1);
+ if (!res)
+ return rep_mem_error ();
+
+ strncpy (rep_STR (res), utf8str, w);
+ rep_STR (res)[w] = '\0';
+
+ g_free (utf8str);
+ return res;
+ #else
+ return src;
+ #endif
+ }
+
+
+
/* initialisation */
***************
*** 1360,1365 ****
--- 1393,1399 ----
rep_ADD_SUBR(Shead_dimensions);
rep_ADD_SUBR(Shead_offset);
rep_ADD_SUBR(Sdisplay_message);
+ rep_ADD_SUBR(Slocale_to_utf8);
rep_pop_structure (tem);
tem = rep_push_structure ("sawfish.wm.events");
diff -c -r sawfish.orig/src/Makefile.in sawfish/src/Makefile.in
*** sawfish.orig/src/Makefile.in Thu Aug 14 11:12:53 2003
--- sawfish/src/Makefile.in Mon Feb 14 21:58:18 2005
***************
*** 38,51 ****
sawfish/wm/util/play-sample.la
DL_DIRS = sawfish/wm/util
! override CFLAGS := $(CFLAGS) $(REP_CFLAGS) $(IMAGE_CFLAGS) $(X11_CFLAGS) $(ESD_CFLAGS) $(PANGO_CFLAGS)
all : sawfish libclient.o $(DL_OBJS) .libexec gtk-style
sawfish : $(OBJS) $(LIBOBJS)
$(rep_LIBTOOL) --mode=link $(CC) -export-dynamic $(LDFLAGS) \
-o sawfish $(OBJS) $(LIBOBJS) $(REP_LIBS) $(PANGO_LIBS) \
! $(IMAGE_LIBS) $(X11_LIBS) $(EXTRA_X11_LIBS) $(LIBS)
%.la : %.lo
$(rep_DL_LD) $(LDFLAGS) -o $@ $<
--- 38,51 ----
sawfish/wm/util/play-sample.la
DL_DIRS = sawfish/wm/util
! override CFLAGS := $(CFLAGS) $(REP_CFLAGS) $(IMAGE_CFLAGS) $(X11_CFLAGS) $(ESD_CFLAGS) $(PANGO_CFLAGS) $(GLIB_CFLAGS)
all : sawfish libclient.o $(DL_OBJS) .libexec gtk-style
sawfish : $(OBJS) $(LIBOBJS)
$(rep_LIBTOOL) --mode=link $(CC) -export-dynamic $(LDFLAGS) \
-o sawfish $(OBJS) $(LIBOBJS) $(REP_LIBS) $(PANGO_LIBS) \
! $(IMAGE_LIBS) $(X11_LIBS) $(EXTRA_X11_LIBS) $(LIBS) $(GLIB_LIBS)
%.la : %.lo
$(rep_DL_LD) $(LDFLAGS) -o $@ $<
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]