[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xft: Changes to 'upstream-unstable'



 NEWS                     |   16 -
 README                   |    2 
 configure.ac             |  149 ++--------
 include/X11/Xft/Xft.h.in |   42 +-
 src/xftcolor.c           |    6 
 src/xftcore.c            |   96 +++---
 src/xftdpy.c             |   62 ++--
 src/xftdraw.c            |   46 +--
 src/xftextent.c          |   14 
 src/xftfont.c            |   16 -
 src/xftfreetype.c        |  161 ++++------
 src/xftglyphs.c          |  696 +++++++++++++++++++++++++++--------------------
 src/xftinit.c            |    4 
 src/xftint.h             |   23 -
 src/xftlist.c            |    6 
 src/xftname.c            |    8 
 src/xftrender.c          |   54 +--
 src/xftswap.c            |    2 
 src/xftxlfd.c            |   28 -
 19 files changed, 736 insertions(+), 695 deletions(-)

New commits:
commit 0847b64af14acefaa7aa86b3cec8632497babe73
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Sat Jun 2 09:36:29 2012 -0700

    libXft 2.3.1
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/configure.ac b/configure.ac
index b54311e..dd415ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,7 +27,7 @@ AC_PREREQ([2.60])
 # version.  This version number will be substituted into Xft.h
 # Please bump the minor library number at each release as well.
 #
-AC_INIT([libXft], [2.3.0],
+AC_INIT([libXft], [2.3.1],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXft])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])

commit 1066d2b34db6124fbb0105f5d30f560217fd2a5a
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Sat Mar 10 23:09:21 2012 -0800

    Dead code removal
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/src/xftint.h b/src/xftint.h
index 5cb57ae..1658977 100644
--- a/src/xftint.h
+++ b/src/xftint.h
@@ -68,16 +68,6 @@
 # define _X_EXPORT /**/
 #endif
 
-#ifndef HAVE_CONFIG_H
-# if (FREETYPE_MAJOR > 2 ||						    \
-      (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 1 ||			    \
-			       (FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 5))))
-#  define HAVE_FT_BITMAP_SIZE_Y_PPEM 1
-# else
-#  define HAVE_FT_BITMAP_SIZE_Y_PPEM 0
-# endif
-#endif
-
 typedef struct _XftMatcher {
     char    *object;
     double  (*compare) (char *object, FcValue value1, FcValue value2);

commit 84b8b5b46773f9b686d57f28092824b86bffed9d
Author: Mikael Magnusson <mikachu@gmail.com>
Date:   Sun Mar 11 02:41:55 2012 +0100

    Fixup for 550b2f76401c2 which broke bold fonts
    
    The commit removed the line
    AC_CHECK_FUNCS(FT_Get_Next_Char FT_Get_BDF_Property FT_Get_PS_Font_Info FT_Has_PS_Glyph_Names FT_GlyphSlot_Embolden)
    but failed to remove the #if lines that this commit removes, resulting
    in that code never being executed.
    
    Fixes: https://bugs.freedesktop.org/attachment.cgi?id=58280
    
    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/src/xftglyphs.c b/src/xftglyphs.c
index 4a3b9d6..2f3dc5a 100644
--- a/src/xftglyphs.c
+++ b/src/xftglyphs.c
@@ -24,9 +24,7 @@
 #include <freetype/ftoutln.h>
 #include <freetype/ftlcdfil.h>
 
-#if HAVE_FT_GLYPHSLOT_EMBOLDEN
 #include <freetype/ftsynth.h>
-#endif
 
 /*
  * Validate the memory info for a font
@@ -434,12 +432,10 @@ XftFontLoadGlyphs (Display	    *dpy,
 
 	glyphslot = face->glyph;
 
-#if HAVE_FT_GLYPHSLOT_EMBOLDEN
 	/*
 	 * Embolden if required
 	 */
 	if (font->info.embolden) FT_GlyphSlot_Embolden(glyphslot);
-#endif
 
 	/*
 	 * Compute glyph metrics from FreeType information

commit b543efafefb71fb1f87ee9c1c261e86c8ca29e76
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Wed Mar 7 20:12:27 2012 -0800

    libXft 2.3.0
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/NEWS b/NEWS
index 01e6dbe..b547c78 100644
--- a/NEWS
+++ b/NEWS
@@ -1,12 +1,22 @@
 			Xft
 		X FreeType library
-		  Version 2.2.0
-		    2010-10-29
+		  Version 2.3.0
+		    2012-03-07
 
-Xft version 2.1 is the first stand alone release of Xft, a library that
+Xft version 2.1 was the first stand alone release of Xft, a library that
 connects X applications with the FreeType font rasterization library. Xft
 uses fontconfig to locate fonts so it has no configuration files.
 
+Version 2.3.0
+
+Subpixel LCD text rendering improvements
+
+Dropped support for versions of freetype2, fontconfig & libXrender that
+pre-dated pkgconfig support.
+
+Raised minimum required versions to freetype2 2.1.6 & fontconfig 2.5.92.
+
+
 Version 2.2.0
 
 Dropped xft-config, now that pkg-config is well established.
diff --git a/README b/README
index b1097eb..3dede12 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
 			Xft
 		X FreeType library
 
-Xft version 2.1 is the first stand alone release of Xft, a library that
+Xft version 2.1 was the first stand alone release of Xft, a library that
 connects X applications with the FreeType font rasterization library. Xft
 uses fontconfig to locate fonts so it has no configuration files.
 
diff --git a/configure.ac b/configure.ac
index 61d6c4d..b54311e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,7 +27,7 @@ AC_PREREQ([2.60])
 # version.  This version number will be substituted into Xft.h
 # Please bump the minor library number at each release as well.
 #
-AC_INIT([libXft], [2.2.0],
+AC_INIT([libXft], [2.3.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXft])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])

commit 301029c9a1d9429009eaf08bb726357d4e94780d
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Mon Oct 24 23:39:25 2011 -0700

    Fix undefined ftbit in XftFontLoadGlyphs
    
    https://bugs.freedesktop.org/show_bug.cgi?id=42173
    
    Fixes regression from: 6f1d7bcdd461b1f6cc64370793f52d7c170187d0
    
    Fixed by examining original patch before rebase from:
    https://bugs.freedesktop.org/show_bug.cgi?id=29151
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/src/xftglyphs.c b/src/xftglyphs.c
index 2639d12..4a3b9d6 100644
--- a/src/xftglyphs.c
+++ b/src/xftglyphs.c
@@ -570,6 +570,9 @@ XftFontLoadGlyphs (Display	    *dpy,
 	    xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y));
 	}
 
+	// compute the size of the final bitmap
+	ftbit = &glyphslot->bitmap;
+
 	width = ftbit->width;
 	height = ftbit->rows;
 

commit 550b2f76401c292d982700b60326e0a837e391b4
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Mon Oct 10 13:00:35 2011 -0700

    Remove fontconfig and freetype ifdef-fu and instead require non-ancinet versions of both
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/configure.ac b/configure.ac
index 8df0cb0..61d6c4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,29 +67,10 @@ AC_SUBST([XFT_LT_VERSION])
 PKG_CHECK_MODULES(XRENDER, xrender >= 0.8.2 x11)
 
 # Check freetype configuration
-AC_ARG_WITH(freetype-config, [  --with-freetype-config=PROG   Use FreeType configuration program PROG], freetype_config=$withval, freetype_config=auto)
-
-if test "$freetype_config" = "auto"; then
-	PKG_CHECK_MODULES(FREETYPE, freetype2,
-		freetype_config=no, freetype_config=yes)
-fi
-
-if test "$freetype_config" = "yes"; then
-	AC_PATH_PROG(ft_config,freetype-config,no)
-	if test "$ft_config" = "no"; then
-		AC_MSG_ERROR([You must have freetype installed; see http://www.freetype.org/])
-	fi
-else
-	ft_config="$freetype_config"
-fi
-
-if test "$freetype_config" != "no"; then
-	FREETYPE_CFLAGS="`$ft_config --cflags`"
-	FREETYPE_LIBS="`$ft_config --libs`"
-fi
+PKG_CHECK_MODULES(FREETYPE, freetype2 >= 2.1.6)
 
 # Check fontconfig configuration
-PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2)
+PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.5.92)
 
 AC_SUBST(XRENDER_CFLAGS)
 AC_SUBST(XRENDER_LIBS)
@@ -98,22 +79,6 @@ AC_SUBST(FREETYPE_LIBS)
 AC_SUBST(FONTCONFIG_CFLAGS)
 AC_SUBST(FONTCONFIG_LIBS)
 
-fontconfig_save_libs="$LIBS"
-fontconfig_save_cflags="$CFLAGS"
-LIBS="$LIBS $FREETYPE_LIBS"
-CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
-AC_CHECK_FUNCS(FT_Get_Next_Char FT_Get_BDF_Property FT_Get_PS_Font_Info FT_Has_PS_Glyph_Names FT_GlyphSlot_Embolden)
-AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
-		HAVE_FT_BITMAP_SIZE_Y_PPEM=1,
-		HAVE_FT_BITMAP_SIZE_Y_PPEM=0,
-[#include <ft2build.h>
-#include FT_FREETYPE_H])
-AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
-		   [FT_Bitmap_Size structure includes y_ppem field])
-
-LIBS="$fontconfig_save_libs"
-CFLAGS="$fontconfig_save_cflags"
-
 if test "$VERSION" = "" ; then
        VERSION=$PACKAGE_VERSION;
 fi
diff --git a/src/xftdpy.c b/src/xftdpy.c
index 73b0bed..c5b756e 100644
--- a/src/xftdpy.c
+++ b/src/xftdpy.c
@@ -369,22 +369,16 @@ _XftDefaultInit (Display *dpy)
 	goto bail1;
     if (!_XftDefaultInitInteger (dpy, pat, FC_RGBA))
 	goto bail1;
-#ifdef FC_LCD_FILTER
     if (!_XftDefaultInitInteger (dpy, pat, FC_LCD_FILTER))
 	goto bail1;
-#endif
     if (!_XftDefaultInitBool (dpy, pat, FC_ANTIALIAS))
 	goto bail1;
-#ifdef FC_EMBOLDEN
     if (!_XftDefaultInitBool (dpy, pat, FC_EMBOLDEN))
 	goto bail1;
-#endif
     if (!_XftDefaultInitBool (dpy, pat, FC_AUTOHINT))
 	goto bail1;
-#ifdef FC_HINT_STYLE
     if (!_XftDefaultInitInteger (dpy, pat, FC_HINT_STYLE))
 	goto bail1;
-#endif
     if (!_XftDefaultInitBool (dpy, pat, FC_HINTING))
 	goto bail1;
     if (!_XftDefaultInitBool (dpy, pat, FC_MINSPACE))
@@ -475,28 +469,24 @@ XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
 			   XftDefaultGetBool (dpy, FC_ANTIALIAS, screen,
 					      True));
     }
-#ifdef FC_EMBOLDEN
     if (FcPatternGet (pattern, FC_EMBOLDEN, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddBool (pattern, FC_EMBOLDEN,
 			   XftDefaultGetBool (dpy, FC_EMBOLDEN, screen,
 					      False));
     }
-#endif
     if (FcPatternGet (pattern, FC_HINTING, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddBool (pattern, FC_HINTING,
 			  XftDefaultGetBool (dpy, FC_HINTING, screen,
 					     True));
     }
-#ifdef FC_HINT_STYLE
     if (FcPatternGet (pattern, FC_HINT_STYLE, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddInteger (pattern, FC_HINT_STYLE,
 			     XftDefaultGetInteger (dpy, FC_HINT_STYLE, screen,
 						   FC_HINT_FULL));
     }
-#endif
     if (FcPatternGet (pattern, FC_AUTOHINT, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddBool (pattern, FC_AUTOHINT,
@@ -525,14 +515,12 @@ XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
 			      XftDefaultGetInteger (dpy, FC_RGBA, screen,
 						    subpixel));
     }
-#ifdef FC_LCD_FILTER
     if (FcPatternGet (pattern, FC_LCD_FILTER, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddInteger (pattern, FC_LCD_FILTER,
 			     XftDefaultGetInteger (dpy, FC_LCD_FILTER, screen,
 						   FC_LCD_DEFAULT));
     }
-#endif
     if (FcPatternGet (pattern, FC_MINSPACE, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddBool (pattern, FC_MINSPACE,
diff --git a/src/xftfreetype.c b/src/xftfreetype.c
index 4f71023..a3b8332 100644
--- a/src/xftfreetype.c
+++ b/src/xftfreetype.c
@@ -176,13 +176,8 @@ _XftUnlockFile (XftFtFile *f)
 	_XftLockError ("too many file unlocks");
 }
 
-#if HAVE_FT_BITMAP_SIZE_Y_PPEM
 #define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem)
 #define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem)
-#else
-#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6)
-#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6)
-#endif
 
 _X_HIDDEN FcBool
 _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix)
@@ -224,12 +219,9 @@ _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix
 	     * files have but a single strike per file, we can
 	     * simply try both sizes.
 	     */
-	    if (
-#if HAVE_FT_BITMAP_SIZE_Y_PPEM
-		FT_Set_Char_Size (face, face->available_sizes[best].x_ppem,
+	    if (FT_Set_Char_Size (face, face->available_sizes[best].x_ppem,
 				  face->available_sizes[best].y_ppem, 0, 0) != 0
 		&&
-#endif
 		FT_Set_Char_Size (face, face->available_sizes[best].width << 6,
 				  face->available_sizes[best].height << 6,
 				  0, 0) != 0)
@@ -379,9 +371,7 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
     double	    aspect;
     FcMatrix	    *font_matrix;
     FcBool	    hinting, vertical_layout, autohint, global_advance;
-#ifdef FC_HINT_STYLE
     int             hint_style;
-#endif
     FcChar32	    hash, *hashp;
     FT_Face	    face;
     int		    nhash;
@@ -469,7 +459,6 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
 	goto bail1;
     }
 
-#ifdef FC_LCD_FILTER
     /*
      * Get lcd_filter value
      */
@@ -482,7 +471,6 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
     default:
 	goto bail1;
     }
-#endif
 
     /*
      * Get matrix and transform values
@@ -557,7 +545,6 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
 	goto bail1;
     }
 
-#ifdef FC_EMBOLDEN
     switch (FcPatternGetBool (pattern, FC_EMBOLDEN, 0, &fi->embolden)) {
     case FcResultNoMatch:
 	fi->embolden = FcFalse;
@@ -567,11 +554,7 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
     default:
 	goto bail1;
     }
-#else
-    fi->embolden = FcFalse;
-#endif
 
-#ifdef FC_HINT_STYLE
     switch (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style)) {
     case FcResultNoMatch:
 	hint_style = FC_HINT_FULL;
@@ -581,12 +564,9 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
     default:
 	goto bail1;
     }
-#endif
 
     if (!hinting
-#ifdef FC_HINT_STYLE
 	|| hint_style == FC_HINT_NONE
-#endif
 	)
     {
 	fi->load_flags |= FT_LOAD_NO_HINTING;
@@ -597,15 +577,11 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
      */
     if (fi->antialias)
     {
-#ifdef FC_HINT_STYLE
-#ifdef FT_LOAD_TARGET_LIGHT
 	if (FC_HINT_NONE < hint_style && hint_style < FC_HINT_FULL)
 	{
 	    fi->load_flags |= FT_LOAD_TARGET_LIGHT;
 	}
 	else
-#endif
-#endif
 	{
 	    /* autohinter will snap stems to integer widths, when
 	     * the LCD targets are used.
@@ -613,23 +589,17 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
 	    switch (fi->rgba) {
 	    case FC_RGBA_RGB:
 	    case FC_RGBA_BGR:
-#ifdef FT_LOAD_TARGET_LCD
 		fi->load_flags |= FT_LOAD_TARGET_LCD;
-#endif
 		break;
 	    case FC_RGBA_VRGB:
 	    case FC_RGBA_VBGR:
-#ifdef FT_LOAD_TARGET_LCD_V
 		fi->load_flags |= FT_LOAD_TARGET_LCD_V;
-#endif
 		break;
 	    }
 	}
     }
-#ifdef FT_LOAD_TARGET_MONO
     else
 	fi->load_flags |= FT_LOAD_TARGET_MONO;
-#endif
 
     /* set vertical layout if requested */
     switch (FcPatternGetBool (pattern, FC_VERTICAL_LAYOUT, 0, &vertical_layout)) {

commit 21a59c10803582c8f90d3b5f32e8f0240c050adf
Author: Tom \"spot\" Callaway <tcallawa@redhat.com>
Date:   Thu Oct 6 15:58:29 2011 -0400

    compiler noise cleanups related to subpixel LCD support
    
    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/src/xftglyphs.c b/src/xftglyphs.c
index 03d94ed..2639d12 100644
--- a/src/xftglyphs.c
+++ b/src/xftglyphs.c
@@ -358,7 +358,7 @@ XftFontLoadGlyphs (Display	    *dpy,
     unsigned char   bufLocal[4096];
     unsigned char   *bufBitmap = bufLocal;
     int		    bufSize = sizeof (bufLocal);
-    int		    size, pitch;
+    int		    size;
     int		    width;
     int		    height;
     int		    left, right, top, bottom;
@@ -572,7 +572,6 @@ XftFontLoadGlyphs (Display	    *dpy,
 
 	width = ftbit->width;
 	height = ftbit->rows;
-	pitch = (width+3) & ~3;
 
 	if (XftDebug() & XFT_DBG_GLYPH)
 	{
@@ -674,12 +673,9 @@ XftFontLoadGlyphs (Display	    *dpy,
 		/* swap bits in each byte */
 		if (BitmapBitOrder (dpy) != MSBFirst)
 		{
-		    unsigned char   *line;
-		    unsigned char   c;
-		    int		    i;
+		    unsigned char   *line = (unsigned char*)bufBitmap;
+		    int		    i = size;
 
-		    line = (unsigned char *) bufBitmap;
-		    i = size;
 		    while (i--)
 		    {
 			int c = *line;

commit 6f1d7bcdd461b1f6cc64370793f52d7c170187d0
Author: Tom \"spot\" Callaway <tcallawa@redhat.com>
Date:   Thu Oct 6 15:41:10 2011 -0400

    Subpixel LCD text rendering improvements
    
    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/src/xftdpy.c b/src/xftdpy.c
index 8f453b3..73b0bed 100644
--- a/src/xftdpy.c
+++ b/src/xftdpy.c
@@ -369,6 +369,10 @@ _XftDefaultInit (Display *dpy)
 	goto bail1;
     if (!_XftDefaultInitInteger (dpy, pat, FC_RGBA))
 	goto bail1;
+#ifdef FC_LCD_FILTER
+    if (!_XftDefaultInitInteger (dpy, pat, FC_LCD_FILTER))
+	goto bail1;
+#endif
     if (!_XftDefaultInitBool (dpy, pat, FC_ANTIALIAS))
 	goto bail1;
 #ifdef FC_EMBOLDEN
@@ -521,6 +525,14 @@ XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
 			      XftDefaultGetInteger (dpy, FC_RGBA, screen,
 						    subpixel));
     }
+#ifdef FC_LCD_FILTER
+    if (FcPatternGet (pattern, FC_LCD_FILTER, 0, &v) == FcResultNoMatch)
+    {
+	FcPatternAddInteger (pattern, FC_LCD_FILTER,
+			     XftDefaultGetInteger (dpy, FC_LCD_FILTER, screen,
+						   FC_LCD_DEFAULT));
+    }
+#endif
     if (FcPatternGet (pattern, FC_MINSPACE, 0, &v) == FcResultNoMatch)
     {
 	FcPatternAddBool (pattern, FC_MINSPACE,
diff --git a/src/xftfreetype.c b/src/xftfreetype.c
index 3f8dfef..4f71023 100644
--- a/src/xftfreetype.c
+++ b/src/xftfreetype.c
@@ -469,6 +469,21 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
 	goto bail1;
     }
 
+#ifdef FC_LCD_FILTER
+    /*
+     * Get lcd_filter value
+     */
+    switch (FcPatternGetInteger (pattern, FC_LCD_FILTER, 0, &fi->lcd_filter)) {
+    case FcResultNoMatch:
+	fi->lcd_filter = FC_LCD_DEFAULT;
+	break;
+    case FcResultMatch:
+	break;
+    default:
+	goto bail1;
+    }
+#endif
+
     /*
      * Get matrix and transform values
      */
diff --git a/src/xftglyphs.c b/src/xftglyphs.c
index e0cfdea..03d94ed 100644
--- a/src/xftglyphs.c
+++ b/src/xftglyphs.c
@@ -22,27 +22,12 @@
 
 #include "xftint.h"
 #include <freetype/ftoutln.h>
+#include <freetype/ftlcdfil.h>
 
 #if HAVE_FT_GLYPHSLOT_EMBOLDEN
 #include <freetype/ftsynth.h>
 #endif
 
-static const int    filters[3][3] = {
-    /* red */
-#if 0
-{    65538*4/7,65538*2/7,65538*1/7 },
-    /* green */
-{    65536*1/4, 65536*2/4, 65537*1/4 },
-    /* blue */
-{    65538*1/7,65538*2/7,65538*4/7 },
-#endif
-{    65538*9/13,65538*3/13,65538*1/13 },
-    /* green */
-{    65538*1/6, 65538*4/6, 65538*1/6 },
-    /* blue */
-{    65538*1/13,65538*3/13,65538*9/13 },
-};
-
 /*
  * Validate the memory info for a font
  */
@@ -69,6 +54,293 @@ _XftFontValidateMemory (Display *dpy, XftFont *public)
 		font->glyph_memory, glyph_memory);
 }
 
+/* we sometimes need to convert the glyph bitmap in a FT_GlyphSlot
+ * into a different format. For example, we want to convert a
+ * FT_PIXEL_MODE_LCD or FT_PIXEL_MODE_LCD_V bitmap into a 32-bit
+ * ARGB or ABGR bitmap.
+ *
+ * this function prepares a target descriptor for this operation.
+ *
+ * input :: target bitmap descriptor. The function will set its
+ *          'width', 'rows' and 'pitch' fields, and only these
+ *
+ * slot  :: the glyph slot containing the source bitmap. this
+ *          function assumes that slot->format == FT_GLYPH_FORMAT_BITMAP
+ *
+ * mode  :: the requested final rendering mode. supported values are
+ *          MONO, NORMAL (i.e. gray), LCD and LCD_V
+ *
+ * the function returns the size in bytes of the corresponding buffer,
+ * it's up to the caller to allocate the corresponding memory block
+ * before calling _fill_xrender_bitmap
+ *
+ * it also returns -1 in case of error (e.g. incompatible arguments,
+ * like trying to convert a gray bitmap into a monochrome one)
+ */
+static int
+_compute_xrender_bitmap_size( FT_Bitmap*	target,
+			      FT_GlyphSlot	slot,
+			      FT_Render_Mode	mode )
+{
+    FT_Bitmap*	ftbit;
+    int		width, height, pitch;
+
+    if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
+	return -1;
+
+    // compute the size of the final bitmap
+    ftbit = &slot->bitmap;
+
+    width = ftbit->width;
+    height = ftbit->rows;
+    pitch = (width+3) & ~3;
+
+    switch ( ftbit->pixel_mode )
+    {
+    case FT_PIXEL_MODE_MONO:
+	if ( mode == FT_RENDER_MODE_MONO )
+	{
+	    pitch = (((width+31) & ~31) >> 3);
+	    break;
+	}
+	/* fall-through */
+
+    case FT_PIXEL_MODE_GRAY:
+	if ( mode == FT_RENDER_MODE_LCD ||
+	     mode == FT_RENDER_MODE_LCD_V )
+	{
+	    /* each pixel is replicated into a 32-bit ARGB value */
+	    pitch = width*4;
+	}
+	break;
+
+    case FT_PIXEL_MODE_LCD:
+	if ( mode != FT_RENDER_MODE_LCD )
+	    return -1;
+
+	/* horz pixel triplets are packed into 32-bit ARGB values */
+	width /= 3;
+	pitch = width*4;
+	break;
+
+    case FT_PIXEL_MODE_LCD_V:
+	if ( mode != FT_RENDER_MODE_LCD_V )
+	    return -1;
+
+	/* vert pixel triplets are packed into 32-bit ARGB values */
+	height /= 3;
+	pitch = width*4;
+	break;
+
+    default:  /* unsupported source format */
+	return -1;
+    }
+
+    target->width = width;
+    target->rows = height;
+    target->pitch = pitch;
+    target->buffer = NULL;
+
+    return pitch * height;
+}
+
+/* this functions converts the glyph bitmap found in a FT_GlyphSlot
+ * into a different format (see _compute_xrender_bitmap_size)
+ *
+ * you should call this function after _compute_xrender_bitmap_size
+ *
+ * target :: target bitmap descriptor. Note that its 'buffer' pointer
+ *           must point to memory allocated by the caller
+ *
+ * slot   :: the glyph slot containing the source bitmap
+ *
+ * mode   :: the requested final rendering mode
+ *
+ * bgr    :: boolean, set if BGR or VBGR pixel ordering is needed
+ */
+static void
+_fill_xrender_bitmap( FT_Bitmap*	target,
+		      FT_GlyphSlot	slot,
+		      FT_Render_Mode	mode,
+		      int		bgr )
+{
+    FT_Bitmap*   ftbit = &slot->bitmap;
+
+    {
+	unsigned char*	srcLine	= ftbit->buffer;
+        unsigned char*	dstLine	= target->buffer;
+        int		src_pitch = ftbit->pitch;
+        int		width = target->width;
+        int		height = target->rows;
+        int		pitch = target->pitch;
+        int		subpixel;
+        int		h;
+
+        subpixel = ( mode == FT_RENDER_MODE_LCD ||
+		     mode == FT_RENDER_MODE_LCD_V );
+
+	if ( src_pitch < 0 )
+	    srcLine -= src_pitch*(ftbit->rows-1);
+
+	switch ( ftbit->pixel_mode )
+	{
+	case FT_PIXEL_MODE_MONO:
+	    if ( subpixel )  /* convert mono to ARGB32 values */
+	    {
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		{
+		    int x;
+
+		    for ( x = 0; x < width; x++ )
+		    {
+			if ( srcLine[(x >> 3)] & (0x80 >> (x & 7)) )
+			    ((unsigned int*)dstLine)[x] = 0xffffffffU;
+		    }
+		}
+	    }
+	    else if ( mode == FT_RENDER_MODE_NORMAL )  /* convert mono to 8-bit gray */
+	    {
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		{
+		    int x;
+
+		    for ( x = 0; x < width; x++ )
+		    {
+			if ( srcLine[(x >> 3)] & (0x80 >> (x & 7)) )
+			    dstLine[x] = 0xff;
+		    }
+		}
+	    }
+	    else  /* copy mono to mono */
+	    {
+		int bytes = (width+7) >> 3;
+
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		    memcpy( dstLine, srcLine, bytes );
+	    }
+	    break;
+
+	case FT_PIXEL_MODE_GRAY:
+	    if ( subpixel )  /* convert gray to ARGB32 values */
+	    {
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		{
+		    int		   x;
+		    unsigned int*  dst = (unsigned int*)dstLine;
+
+		    for ( x = 0; x < width; x++ )
+		    {
+			unsigned int pix = srcLine[x];
+
+			pix |= (pix << 8);
+			pix |= (pix << 16);
+
+			dst[x] = pix;
+		    }
+		}
+	    }
+	    else  /* copy gray into gray */
+	    {
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		    memcpy( dstLine, srcLine, width );
+	    }
+	    break;
+
+	case FT_PIXEL_MODE_LCD:
+	    if ( !bgr )
+	    {
+		/* convert horizontal RGB into ARGB32 */
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		{
+		    int		   x;
+		    unsigned char* src = srcLine;
+		    unsigned int*  dst = (unsigned int*)dstLine;
+
+		    for ( x = 0; x < width; x++, src += 3 )
+		    {
+			unsigned int pix;
+
+			pix = ((unsigned int)src[0] << 16) |
+			      ((unsigned int)src[1] <<  8) |
+			      ((unsigned int)src[2]      ) |
+			      ((unsigned int)src[1] << 24) ;
+
+			dst[x] = pix;
+		    }
+		}
+	    }
+	    else
+	    {
+		/* convert horizontal BGR into ARGB32 */
+		for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch )
+		{
+		    int		   x;
+		    unsigned char* src = srcLine;
+		    unsigned int*  dst = (unsigned int*)dstLine;
+
+		    for ( x = 0; x < width; x++, src += 3 )
+		    {
+			unsigned int pix;
+
+			pix = ((unsigned int)src[2] << 16) |
+			      ((unsigned int)src[1] <<  8) |
+			      ((unsigned int)src[0]      ) |
+			      ((unsigned int)src[1] << 24) ;
+
+			dst[x] = pix;
+		    }
+		}
+	    }
+	    break;
+
+	default:  /* FT_PIXEL_MODE_LCD_V */
+	    /* convert vertical RGB into ARGB32 */
+	    if ( !bgr )
+	    {
+		for ( h = height; h > 0; h--, srcLine += 3*src_pitch, dstLine += pitch )
+		{
+		    int		   x;
+		    unsigned char* src = srcLine;
+		    unsigned int*  dst = (unsigned int*)dstLine;
+
+		    for ( x = 0; x < width; x++, src += 1 )
+		    {
+			unsigned int  pix;
+
+			pix = ((unsigned int)src[0]           << 16) |
+			      ((unsigned int)src[src_pitch]   <<  8) |
+			      ((unsigned int)src[src_pitch*2]      ) |
+			      ((unsigned int)src[src_pitch]   << 24) ;
+
+			dst[x] = pix;
+		    }
+		}
+	    }
+	    else
+	    {
+	    for ( h = height; h > 0; h--, srcLine += 3*src_pitch, dstLine += pitch )
+		{
+		    int		   x;
+		    unsigned char* src = srcLine;
+		    unsigned int*  dst = (unsigned int*)dstLine;
+
+		    for ( x = 0; x < width; x++, src += 1 )
+		    {
+			unsigned int  pix;
+
+			pix = ((unsigned int)src[src_pitch*2] << 16) |
+			      ((unsigned int)src[src_pitch]   <<  8) |
+			      ((unsigned int)src[0]                ) |
+			      ((unsigned int)src[src_pitch]   << 24) ;
+
+			dst[x] = pix;
+		    }
+		}
+	    }
+	}
+    }
+}
+
 _X_EXPORT void
 XftFontLoadGlyphs (Display	    *dpy,
 		   XftFont	    *pub,
@@ -87,20 +359,14 @@ XftFontLoadGlyphs (Display	    *dpy,
     unsigned char   *bufBitmap = bufLocal;
     int		    bufSize = sizeof (bufLocal);
     int		    size, pitch;
-    unsigned char   bufLocalRgba[4096];
-    unsigned char   *bufBitmapRgba = bufLocalRgba;
-    int		    bufSizeRgba = sizeof (bufLocalRgba);
-    int		    sizergba, pitchrgba, widthrgba;
     int		    width;
     int		    height;
     int		    left, right, top, bottom;
-    int		    hmul = 1;
-    int		    vmul = 1;
-    FT_Bitmap	    ftbit;
-    FT_Matrix	    matrix;
+    FT_Bitmap*	    ftbit;
+    FT_Bitmap	    local;
     FT_Vector	    vector;
-    Bool	    subpixel = False;
     FT_Face	    face;
+    FT_Render_Mode  mode = FT_RENDER_MODE_MONO;
 
     if (!info)
 	return;
@@ -110,24 +376,19 @@ XftFontLoadGlyphs (Display	    *dpy,
     if (!face)
 	return;
 
-    matrix.xx = matrix.yy = 0x10000L;
-    matrix.xy = matrix.yx = 0;
-
     if (font->info.antialias)
     {
 	switch (font->info.rgba) {
 	case FC_RGBA_RGB:
 	case FC_RGBA_BGR:
-	    matrix.xx *= 3;
-	    subpixel = True;
-	    hmul = 3;
+	    mode = FT_RENDER_MODE_LCD;
 	    break;
 	case FC_RGBA_VRGB:
 	case FC_RGBA_VBGR:
-	    matrix.yy *= 3;
-	    vmul = 3;
-	    subpixel = True;
+	    mode = FT_RENDER_MODE_LCD_V;
 	    break;
+	default:
+	    mode = FT_RENDER_MODE_NORMAL;
 	}
     }
 
@@ -148,6 +409,8 @@ XftFontLoadGlyphs (Display	    *dpy,
 	if (xftg->glyph_memory)
 	    continue;
 
+	FT_Library_SetLcdFilter( _XftFTlibrary, font->info.lcd_filter);
+
 	error = FT_Load_Glyph (face, glyphindex, font->info.load_flags);
 	if (error)
 	{
@@ -181,7 +444,7 @@ XftFontLoadGlyphs (Display	    *dpy,
 	/*
 	 * Compute glyph metrics from FreeType information
 	 */
-	if(font->info.transform && glyphslot->format != ft_glyph_format_bitmap)
+	if(font->info.transform && glyphslot->format != FT_GLYPH_FORMAT_BITMAP)
 	{
 	    /*
 	     * calculate the true width by transforming all four corners.
@@ -260,17 +523,14 @@ XftFontLoadGlyphs (Display	    *dpy,
 	    }
 	}
 
-	if (font->info.antialias)
-	    pitch = (width * hmul + 3) & ~3;
-	else
-	    pitch = ((width + 31) & ~31) >> 3;
-
-	size = pitch * height * vmul;
+	if ( glyphslot->format != FT_GLYPH_FORMAT_BITMAP )


Reply to: