Re: cwm: utf-8 diff

2011-05-30 Thread Owain Ainsworth
On Fri, May 27, 2011 at 04:28:44PM +0400, Alexander Polakov wrote:
> This diff works for me with some fonts (fixed, snap, even verdana),
> but doesn't work with terminus (black squares instead of chars).

I have been meaning to write this diff for years.

I will try and get to it soon.

Cheers,

-0-
> 
> Index: app/cwm/calmwm.c
> ===
> RCS file: /cvs/xenocara/app/cwm/calmwm.c,v
> retrieving revision 1.54
> diff -u -p -u -r1.54 calmwm.c
> --- app/cwm/calmwm.c  11 May 2011 13:53:51 -  1.54
> +++ app/cwm/calmwm.c  27 May 2011 12:35:51 -
> @@ -30,6 +30,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "calmwm.h"
>  
> @@ -61,6 +62,8 @@ main(int argc, char **argv)
>   const char  *conf_file = NULL;
>   char*display_name = NULL;
>   int  ch;
> +
> + setlocale(LC_CTYPE, "");
>  
>   while ((ch = getopt(argc, argv, "c:d:")) != -1) {
>   switch (ch) {
> Index: app/cwm/font.c
> ===
> RCS file: /cvs/xenocara/app/cwm/font.c,v
> retrieving revision 1.14
> diff -u -p -u -r1.14 font.c
> --- app/cwm/font.c11 May 2011 13:53:51 -  1.14
> +++ app/cwm/font.c27 May 2011 12:35:51 -
> @@ -66,7 +66,7 @@ font_width(struct screen_ctx *sc, const 
>  {
>   XGlyphInfo   extents;
>  
> - XftTextExtents8(X_Dpy, sc->font, (const XftChar8*)text,
> + XftTextExtentsUtf8(X_Dpy, sc->font, (unsigned char*)text,
>   len, &extents);
>  
>   return (extents.xOff);
> @@ -77,9 +77,8 @@ font_draw(struct screen_ctx *sc, const c
>  Drawable d, int x, int y)
>  {
>   XftDrawChange(sc->xftdraw, d);
> - /* Really needs to be UTF8'd. */
> - XftDrawString8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
> - (const FcChar8*)text, len);
> + XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
> + (const unsigned char*)text, len);
>  }
>  
>  XftFont *
> 
> -- 
> Alexander Polakov | plhk.ru
> 

-- 
When the going gets tough, the tough get empirical
-- Jon Carroll



cwm: utf-8 diff

2011-05-27 Thread Alexander Polakov
This diff works for me with some fonts (fixed, snap, even verdana),
but doesn't work with terminus (black squares instead of chars).

Index: app/cwm/calmwm.c
===
RCS file: /cvs/xenocara/app/cwm/calmwm.c,v
retrieving revision 1.54
diff -u -p -u -r1.54 calmwm.c
--- app/cwm/calmwm.c11 May 2011 13:53:51 -  1.54
+++ app/cwm/calmwm.c27 May 2011 12:35:51 -
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "calmwm.h"
 
@@ -61,6 +62,8 @@ main(int argc, char **argv)
const char  *conf_file = NULL;
char*display_name = NULL;
int  ch;
+
+   setlocale(LC_CTYPE, "");
 
while ((ch = getopt(argc, argv, "c:d:")) != -1) {
switch (ch) {
Index: app/cwm/font.c
===
RCS file: /cvs/xenocara/app/cwm/font.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 font.c
--- app/cwm/font.c  11 May 2011 13:53:51 -  1.14
+++ app/cwm/font.c  27 May 2011 12:35:51 -
@@ -66,7 +66,7 @@ font_width(struct screen_ctx *sc, const 
 {
XGlyphInfo   extents;
 
-   XftTextExtents8(X_Dpy, sc->font, (const XftChar8*)text,
+   XftTextExtentsUtf8(X_Dpy, sc->font, (unsigned char*)text,
len, &extents);
 
return (extents.xOff);
@@ -77,9 +77,8 @@ font_draw(struct screen_ctx *sc, const c
 Drawable d, int x, int y)
 {
XftDrawChange(sc->xftdraw, d);
-   /* Really needs to be UTF8'd. */
-   XftDrawString8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
-   (const FcChar8*)text, len);
+   XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
+   (const unsigned char*)text, len);
 }
 
 XftFont *

-- 
Alexander Polakov | plhk.ru