--- Xft.h	2002/10/11 17:53:02	1.30
+++ Xft.h	2003/02/25 21:57:53	1.32
@@ -26,8 +26,8 @@
 #define _XFT_H_
 
 #define XFT_MAJOR	2
-#define XFT_MINOR	0
-#define XFT_REVISION	1
+#define XFT_MINOR	1
+#define XFT_REVISION	0
 #define XFT_VERSION	((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION))
 #define XftVersion	XFT_VERSION
 
@@ -325,11 +325,12 @@ XftTextExtentsUtf8 (Display	    *dpy,
 		    XGlyphInfo	    *extents);
 
 void
-XftTextExtentsUtf16 (XftFont		*pub,
+XftTextExtentsUtf16 (Display		*dpy,
+		     XftFont		*pub,
 		     _Xconst FcChar8	*string, 
 		     FcEndian		endian,
-		    int			len,
-		    XGlyphInfo		*extents);
+		     int		len,
+		     XGlyphInfo		*extents);
 
 /* xftfont.c */
 FcPattern *
@@ -605,6 +606,20 @@ XftTextRenderUtf8 (Display	    *dpy,
 		   int		    y,
 		   _Xconst FcChar8  *string,
 		   int		    len);
+
+void
+XftTextRenderUtf16 (Display	    *dpy,
+		    int		    op,
+		    Picture	    src,
+		    XftFont	    *pub,
+		    Picture	    dst,
+		    int		    srcx,
+		    int		    srcy,
+		    int		    x,
+		    int		    y,
+		    _Xconst FcChar8 *string,
+		    FcEndian	    endian,
+		    int		    len);
 
 /* xftstr.c */
 
--- xftcore.c	2002/10/16 21:07:08	1.11
+++ xftcore.c	2003/02/15 22:30:51	1.13
@@ -355,7 +355,7 @@ _XftSmoothGlyphMono (XImage		*image,
 	bits = *src++;
 	
 	xspan = x;
-	while (w)
+	while (w--)
 	{
 	    if (bits & bitsMask)
 		XPutPixel (image, xspan, y, pixel);
@@ -1088,7 +1088,6 @@ XftGlyphSpecCore (XftDraw		*draw,
     /*
      * Load missing glyphs
      */
-    nmissing = 0;
     glyphs_loaded = FcFalse;
     x1 = y1 = x2 = y2 = 0;
     for (i = 0; i < nglyphs; i++)
@@ -1096,8 +1095,12 @@ XftGlyphSpecCore (XftDraw		*draw,
 	XGlyphInfo	gi;
 	int		g_x1, g_x2, g_y1, g_y2;
 	
+	nmissing = 0;
 	if (XftFontCheckGlyph (dpy, public, FcTrue, glyphs[i].glyph, missing, &nmissing))
 	    glyphs_loaded = FcTrue;
+	if (nmissing)
+	    XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
+
 	XftGlyphExtents (dpy, public, &glyphs[i].glyph, 1, &gi);
 	g_x1 = glyphs[i].x - gi.x;
 	g_y1 = glyphs[i].y - gi.y;
@@ -1122,8 +1125,6 @@ XftGlyphSpecCore (XftDraw		*draw,
 	    y2 = g_y2;
 	}
     }
-    if (nmissing)
-	XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
     
     if (x1 == x2 || y1 == y2)
 	goto bail1;
@@ -1273,6 +1274,9 @@ XftGlyphFontSpecCore (XftDraw			*draw,
 	}
     }
     
+    if (x1 == x2 || y1 == y2)
+	goto bail1;
+
     for (i = 0; i < nglyphs; i++)
 	if (((XftFontInt *) glyphs[i].font)->info.antialias)
 	    break;
--- xftextent.c	2002/10/11 17:53:02	1.9
+++ xftextent.c	2002/12/14 01:59:38	1.10
@@ -220,6 +220,50 @@ XftTextExtentsUtf8 (Display	    *dpy,
     glyphs = glyphs_local;
     size = NUM_LOCAL;
     while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
+    {
+	if (i == size)
+	{
+	    glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+	    if (!glyphs_new)
+	    {
+		if (glyphs != glyphs_local)
+		    free (glyphs);
+		memset (extents, '\0', sizeof (XGlyphInfo));
+		return;
+	    }
+	    memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+	    size *= 2;
+	    if (glyphs != glyphs_local)
+		free (glyphs);
+	    glyphs = glyphs_new;
+	}
+	glyphs[i++] = XftCharIndex (dpy, pub, ucs4);
+	string += l;
+	len -= l;
+    }
+    XftGlyphExtents (dpy, pub, glyphs, i, extents);
+    if (glyphs != glyphs_local)
+	free (glyphs);
+}
+
+void
+XftTextExtentsUtf16 (Display		*dpy,
+		     XftFont		*pub,
+		     _Xconst FcChar8	*string, 
+		     FcEndian		endian,
+		     int		len,
+		     XGlyphInfo		*extents)
+{
+    FT_UInt	    *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+    FcChar32	    ucs4;
+    int		    i;
+    int		    l;
+    int		    size;
+
+    i = 0;
+    glyphs = glyphs_local;
+    size = NUM_LOCAL;
+    while (len && (l = FcUtf16ToUcs4 (string, endian, &ucs4, len)) > 0)
     {
 	if (i == size)
 	{
--- xftrender.c	2002/10/11 17:53:02	1.14
+++ xftrender.c	2002/12/14 01:59:38	1.15
@@ -673,7 +673,7 @@ XftTextRender8 (Display		*dpy,
     }
     for (i = 0; i < len; i++)
 	glyphs[i] = XftCharIndex (dpy, pub, string[i]);
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -705,7 +705,7 @@ XftTextRender16 (Display	    *dpy,
     }
     for (i = 0; i < len; i++)
 	glyphs[i] = XftCharIndex (dpy, pub, string[i]);
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -738,7 +738,7 @@ XftTextRender16BE (Display	    *dpy,
     for (i = 0; i < len; i++)
 	glyphs[i] = XftCharIndex (dpy, pub, 
 				  (string[i*2]<<8) | string[i*2+1]);
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -771,7 +771,7 @@ XftTextRender16LE (Display	    *dpy,
     for (i = 0; i < len; i++)
 	glyphs[i] = XftCharIndex (dpy, pub, 
 				  string[i*2] | (string[i*2+1]<<8));
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -803,7 +803,7 @@ XftTextRender32 (Display	    *dpy,
     }
     for (i = 0; i < len; i++)
 	glyphs[i] = XftCharIndex (dpy, pub, string[i]);
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -839,7 +839,7 @@ XftTextRender32BE (Display	    *dpy,
 				  (string[i*4+1] << 16) |
 				  (string[i*4+2] << 8) |
 				  (string[i*4+3]));
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -875,7 +875,7 @@ XftTextRender32LE (Display	    *dpy,
 				  (string[i*4+1] << 8) |
 				  (string[i*4+2] << 16) |
 				  (string[i*4+3] << 24));
-    XftGlyphRender (dpy, PictOpOver, src, pub, dst, 
+    XftGlyphRender (dpy, op, src, pub, dst, 
 		     srcx, srcy, x, y, glyphs, len);
     if (glyphs != glyphs_local)
 	free (glyphs);
@@ -904,6 +904,56 @@ XftTextRenderUtf8 (Display	    *dpy,
     glyphs = glyphs_local;
     size = NUM_LOCAL;
     while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
+    {
+	if (i == size)
+	{
+	    glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
+	    if (!glyphs_new)
+	    {
+		if (glyphs != glyphs_local)
+		    free (glyphs);
+		return;
+	    }
+	    memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
+	    size *= 2;
+	    if (glyphs != glyphs_local)
+		free (glyphs);
+	    glyphs = glyphs_new;
+	}
+	glyphs[i++] = XftCharIndex (dpy, pub, ucs4);
+	string += l;
+	len -= l;
+    }
+    XftGlyphRender (dpy, op, src, pub, dst,
+		     srcx, srcy, x, y, glyphs, i);
+    if (glyphs != glyphs_local)
+	free (glyphs);
+}
+
+void
+XftTextRenderUtf16 (Display	    *dpy,
+		    int		    op,
+		    Picture	    src,
+		    XftFont	    *pub,
+		    Picture	    dst,
+		    int		    srcx,
+		    int		    srcy,
+		    int		    x,
+		    int		    y,
+		    _Xconst FcChar8 *string,
+		    FcEndian	    endian,
+		    int		    len)
+{
+    FT_UInt	    *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
+    FcChar32	    ucs4;
+    int		    i;
+    int		    l;
+    int		    size;
+
+    i = 0;
+    glyphs = glyphs_local;
+    size = NUM_LOCAL;
+    while (len && (l = FcUtf16ToUcs4 (string, endian, &ucs4, len)) > 0)
     {
 	if (i == size)
 	{
