Package: icewm-experimental
Version: 1.2.20+21pre1-4
Severity: wishlist
Tags: patch

The attached patch adds support for bidirectional text rendering (using
fribidi).

Basically it filters text that is to be filtered to the screen via
fribidi's fribidi_log2vis() . The aptch is only for the Xft rendering
case and only when multi-byte support is in effect.

This is mostly useful for menu items (if your language is a RTL one,
such as Arabic and Hebrew) and window titles (such as ones from web
browsers). It makes the desktop much more usable in those cases.

The patch applies to the version of IceWM in Sarge. I expect it to aply
to later versions without many modifications, but I haven't review that
code yet.

I have also submitted it at
http://sourceforge.net/tracker/index.php?func=detail&aid=1440618&group_id=31&atid=300031
though have recieved no feedback for it so far.

-- 
Tzafrir Cohen
[EMAIL PROTECTED]
http://www.technion.ac.il/~tzafrir
#! /bin/sh /usr/share/dpatch/dpatch-run
## fribidi.dpatch by  Tzafrir Cohen <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: bidi rendering with fribidi

@DPATCH@
diff -urNad icewm-1.2.20+21pre1/src/Makefile.in 
/tmp/dpep.r7HGDA/icewm-1.2.20+21pre1/src/Makefile.in
--- icewm-1.2.20+21pre1/src/Makefile.in 2005-07-29 10:29:28.597623136 +0300
+++ /tmp/dpep.r7HGDA/icewm-1.2.20+21pre1/src/Makefile.in        2005-07-29 
10:29:30.448397904 +0300
@@ -41,7 +41,7 @@
 LFLAGS =       @LDFLAGS@
 LIBS =        -lsupc++  @LIBS@
 
-CORE_LIBS =     @CORE_LIBS@ # `fc-config --libs`
+CORE_LIBS =     @CORE_LIBS@ -lfribidi # `fc-config --libs`
 IMAGE_LIBS =    @IMAGE_LIBS@
 AUDIO_LIBS =    @AUDIO_LIBS@
 GNOME1_LIBS =    @GNOME1_LIBS@
diff -urNad icewm-1.2.20+21pre1/src/yfontxft.cc 
/tmp/dpep.r7HGDA/icewm-1.2.20+21pre1/src/yfontxft.cc
--- icewm-1.2.20+21pre1/src/yfontxft.cc 2005-07-29 10:29:25.376015194 +0300
+++ /tmp/dpep.r7HGDA/icewm-1.2.20+21pre1/src/yfontxft.cc        2005-07-29 
10:30:07.830848602 +0300
@@ -6,6 +6,7 @@
 #include "ypaint.h"
 #include "yxapp.h"
 #include "intl.h"
+#include <stdio.h>
 
 
/******************************************************************************/
 
@@ -44,6 +45,11 @@
     XftFont ** fFonts;
 };
 
+#ifdef CONFIG_I18N
+    #define CONFIG_FRIBIDI
+    #include <fribidi/fribidi.h>
+#endif
+
 class XftGraphics {
 public:
 #ifdef CONFIG_I18N
@@ -68,10 +74,26 @@
                            char_t * str, size_t len)
     {
         XftColor *c = *g.color();
+#ifdef CONFIG_FRIBIDI
+        char_t *vis_str = new char_t[len+1];
+        if (vis_str != NULL) {
+          FriBidiCharType pbase_dir = FRIBIDI_TYPE_N;
+          fribidi_log2vis(str, len, &pbase_dir, //input
+              vis_str, // output
+              NULL, NULL, NULL // "statistics" that we don't need
+          );
+          str = vis_str;
+        }
+        vis_str[len] = 0;
+#endif
         XftDrawString(g.handleXft(), c, font,
                       x - g.xorigin(),
                       y - g.yorigin(),
                       str, len);
+#ifdef CONFIG_FRIBIDI
+        if (vis_str != NULL)
+          delete vis_str;
+#endif
     }
 
     static void textExtents(XftFont * font, char_t * str, size_t len,

Reply via email to