jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

xrender font patch


This patch solve problem with input non ASCII characters
(Cyrillic for me) in xjed.

--
Igor Homyakov
<homyakov AT ramax.spb.ru>
diff -ubr jed-0.99-16/src/xterm.c jed-0.99-16.my/src/xterm.c
--- jed-0.99-16/src/xterm.c	2002-10-20 10:55:31 +0400
+++ jed-0.99-16.my/src/xterm.c	2002-11-26 14:20:59 +0300
@@ -29,6 +29,7 @@
 # include <X11/Intrinsic.h>
 # if XJED_HAS_XRENDERFONT
 #  include <X11/Xft/Xft.h>
+#  include <wchar.h>
 # endif
 # if !SKIP_LOCALE_CODE
 #  if XtSpecificationRelease >= 6
@@ -368,9 +369,12 @@
    int b = XWin->border;
 
 #if XJED_HAS_XRENDERFONT
+
    if ((XWin->face_size > 0)
        && (XWin->xftdraw != NULL))
      {
+	size_t len = mbsnrtowcs(NULL, &s, n, 0, NULL);
+
 	/* if (!XWin->xftdraw) */
 	/*   XWin->xftdraw = XftDrawCreate(This_XDisplay, This_XWindow, DefaultVisual(This_XDisplay, This_XScreen), XWin->color_map); */
 
@@ -379,10 +383,22 @@
 		     row * XWin->font_height /*+ b + XWin->font_base*/,
 		     n * XWin->font_width, 
 		     XWin->font_height);
+	if (len != -1) 
+	  {
+	     wchar_t wtext[ 4 * ( len + 1 ) ];
+	     mbsnrtowcs(wtext, &s, n, len + 1, NULL);
+	     XftDrawString32(XWin->xftdraw, Pixel2XftColor(gc->fg), XWin->xftfont,
+			     col * XWin->font_width + b, 
+			     row * XWin->font_height + b + XWin->font_base, 
+			     (XftChar32 *)wtext, len);
+	  }    
+	else 
+	  {
 	XftDrawString8(XWin->xftdraw, Pixel2XftColor(gc->fg), XWin->xftfont, 
 		       col * XWin->font_width + b,
 		       row * XWin->font_height + b + XWin->font_base,
 		       (unsigned char *) s, n);
+	  }
 	
 	return 0;
      }

[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]