Only in libXft-2.1.10.new/: config.h Only in libXft-2.1.10.new/: config.log Only in libXft-2.1.10.new/: config.status Only in libXft-2.1.10.new/: libtool Only in libXft-2.1.10.new/: libXft-2.1.10-fake-bitmap-glyph.diff Only in libXft-2.1.10.new/: Makefile Only in libXft-2.1.10.new/man: Makefile Only in libXft-2.1.10.new/src: .deps Only in libXft-2.1.10.new/src: .libs Only in libXft-2.1.10.new/src: libXft.la Only in libXft-2.1.10.new/src: Makefile Only in libXft-2.1.10.new/src: xftcolor.lo Only in libXft-2.1.10.new/src: xftcolor.o Only in libXft-2.1.10.new/src: xftcore.lo Only in libXft-2.1.10.new/src: xftcore.o Only in libXft-2.1.10.new/src: xftdbg.lo Only in libXft-2.1.10.new/src: xftdbg.o Only in libXft-2.1.10.new/src: xftdpy.lo Only in libXft-2.1.10.new/src: xftdpy.o Only in libXft-2.1.10.new/src: xftdraw.lo Only in libXft-2.1.10.new/src: xftdraw.o Only in libXft-2.1.10.new/src: xftextent.lo Only in libXft-2.1.10.new/src: xftextent.o Only in libXft-2.1.10.new/src: xftfont.lo Only in libXft-2.1.10.new/src: xftfont.o diff -rup libXft-2.1.10/src/xftfreetype.c libXft-2.1.10.new/src/xftfreetype.c --- libXft-2.1.10/src/xftfreetype.c 2006-06-03 18:30:56.000000000 +0800 +++ libXft-2.1.10.new/src/xftfreetype.c 2006-06-19 01:09:53.000000000 +0800 @@ -566,38 +566,43 @@ XftFontInfoFill (Display *dpy, _Xconst F { #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. - */ - switch (fi->rgba) { - case FC_RGBA_RGB: - case FC_RGBA_BGR: -#ifdef FT_LOAD_TARGET_LCD - fi->load_flags |= FT_LOAD_TARGET_LCD; + switch ( hint_style ) + { + case FC_HINT_SLIGHT: + fi->load_flags |= FT_LOAD_TARGET_LIGHT; + break; + + case FC_HINT_FULL: + switch (fi->rgba) { + case FC_RGBA_RGB: + case FC_RGBA_BGR: + fi->load_flags |= FT_LOAD_TARGET_LCD; + break; + case FC_RGBA_VRGB: + case FC_RGBA_VBGR: + fi->load_flags |= FT_LOAD_TARGET_LCD_V; + break; + + default: + ; + } + break; + + default: /* FC_HINT_MEDIUM */ + ; /* nothing => FT_LOAD_TARGET_NORMAL */ + } +#endif /* if FT_LOAD_TARGET_LIGHT isn't defined, you + * have a *very* old version of FreeType that + * doesn't support playing with the hinting + * algorithm, nothing to do then... + */ #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)) { case FcResultNoMatch: Only in libXft-2.1.10.new/src: xftfreetype.lo Only in libXft-2.1.10.new/src: xftfreetype.o diff -rup libXft-2.1.10/src/xftglyphs.c libXft-2.1.10.new/src/xftglyphs.c --- libXft-2.1.10/src/xftglyphs.c 2006-06-03 18:30:56.000000000 +0800 +++ libXft-2.1.10.new/src/xftglyphs.c 2006-06-19 01:15:28.000000000 +0800 @@ -23,8 +23,23 @@ */ #include "xftint.h" -#include +#include FT_OUTLINE_H +#if HAVE_FT_GLYPHSLOT_EMBOLDEN +#include FT_SYNTHESIS_H +#endif + + +/* define the following macro if you want to use a small FIR filter to + * reduce color fringes for LCD rendering. If undefined, the original + * weird pixel-local color balancing algorithm will be used + */ +#define FIR_FILTER +#ifdef FIR_FILTER +/* note: keep the filter symetric, or bad things will happen */ +static const int fir_filter[5] = { 0x10, 0x40, 0x70, 0x40, 0x10 }; + +#else /* !FIR_FILTER */ static const int filters[3][3] = { /* red */ #if 0 @@ -40,6 +55,7 @@ static const int filters[3][3] = { /* blue */ { 65538*1/13,65538*3/13,65538*9/13 }, }; +#endif /* !FIR_FILTER */ /* * Validate the memory info for a font @@ -131,6 +147,10 @@ XftFontLoadGlyphs (Display *dpy, while (nglyph--) { +#ifdef FIR_FILTER + int margin_top = 0, margin_left = 0; +#endif + glyphindex = *glyphs++; xftg = font->glyphs[glyphindex]; if (!xftg) @@ -169,6 +189,17 @@ XftFontLoadGlyphs (Display *dpy, glyphslot = face->glyph; + if (font->info.embolden && + glyphslot->format == ft_glyph_format_outline && + glyphslot->outline.n_points && + pub->height <= 18 && + !font->info.antialias && + !(font->info.load_flags & FT_LOAD_NO_HINTING)) { + error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_MONO); + if (error) + continue; + } + #if HAVE_FT_GLYPHSLOT_EMBOLDEN /* * Embolden if required @@ -179,7 +210,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. @@ -258,12 +289,41 @@ XftFontLoadGlyphs (Display *dpy, } } - if (font->info.antialias) - pitch = (width * hmul + 3) & ~3; - else - pitch = ((width + 31) & ~31) >> 3; - - size = pitch * height * vmul; + /* now we're going to adjust the margins of the glyph for LCD filtering */ + if (font->info.antialias) { + switch (font->info.rgba) { + case FC_RGBA_RGB: + case FC_RGBA_BGR: +#ifdef FIR_FILTER + margin_left = 1; + left -= 64; + right += 64; + width += 2; +#endif /* FIR_FILTER */ + pitch = (width*3+3) & ~3; + size = pitch*height; + break; + + case FC_RGBA_VRGB: + case FC_RGBA_VBGR: +#ifdef FIR_FILTER + margin_top = 0; + top += 64; + bottom -= 64; + height += 2; +#endif /* FIR_FILTER */ + pitch = (width+3) & ~3; + size = pitch*height*3; + break; + + default: + pitch = (width+3) & ~3; + size = pitch*height; + } + } else { + pitch = ((width+31) & ~31) >> 3; + size = pitch*height; + } xftg->metrics.width = width; xftg->metrics.height = height; @@ -323,8 +383,10 @@ XftFontLoadGlyphs (Display *dpy, if (bufBitmap != bufLocal) free (bufBitmap); bufBitmap = (unsigned char *) malloc (size); - if (!bufBitmap) + if (!bufBitmap) { + bufBitmap = bufLocal; /* prevent free(NULL) later !! */ continue; + } bufSize = size; } memset (bufBitmap, 0, size); @@ -333,7 +395,7 @@ XftFontLoadGlyphs (Display *dpy, * Rasterize into the local buffer */ switch (glyphslot->format) { - case ft_glyph_format_outline: + case FT_GLYPH_FORMAT_OUTLINE: ftbit.width = width * hmul; ftbit.rows = height * vmul; ftbit.pitch = pitch; @@ -351,35 +413,50 @@ XftFontLoadGlyphs (Display *dpy, FT_Outline_Get_Bitmap( _XftFTlibrary, &glyphslot->outline, &ftbit ); break; - case ft_glyph_format_bitmap: + case FT_GLYPH_FORMAT_BITMAP: if (font->info.antialias) { unsigned char *srcLine, *dstLine; int height; + int width = glyphslot->bitmap.width; int x; - int h, v; srcLine = glyphslot->bitmap.buffer; - dstLine = bufBitmap; + dstLine = bufBitmap + margin_left + margin_top*pitch; height = glyphslot->bitmap.rows; while (height--) { - for (x = 0; x < glyphslot->bitmap.width; x++) + unsigned char* src = srcLine; + unsigned char* dst = dstLine; + unsigned int mask = 0x8080; + + for (x = 0; x < width; x++ ) { - /* always MSB bitmaps */ - unsigned char a = ((srcLine[x >> 3] & (0x80 >> (x & 7))) ? - 0xff : 0x00); - if (subpixel) - { - for (v = 0; v < vmul; v++) - for (h = 0; h < hmul; h++) - dstLine[v * pitch + x*hmul + h] = a; - } - else - dstLine[x] = a; - } - dstLine += pitch * vmul; - srcLine += glyphslot->bitmap.pitch; + if ( (src[0] & mask) != 0 ) { + dst[0] = 0xFF; + if ( hmul == 3 ) { + dst[1] = 0xFF; + dst[2] = 0xFF; + } + } + + mask >>= 1; + if ( (mask & 0x80) != 0 ) { + mask = 0x8080; + src += 1; + } + } + + if ( vmul == 3 ) { + memcpy( dstLine + pitch, dstLine, width*3 ); + dstLine += pitch; + + memcpy( dstLine + pitch, dstLine, width*3 ); + dstLine += pitch; + } + + dstLine += pitch; + srcLine += width; } } else @@ -455,74 +532,270 @@ XftFontLoadGlyphs (Display *dpy, if (subpixel) { - int x, y; - unsigned char *in_line, *out_line, *in; - unsigned int *out; - unsigned int red, green, blue; - int rf, gf, bf; - int s; - int o, os; - - /* - * Filter the glyph to soften the color fringes - */ - widthrgba = width; - pitchrgba = (widthrgba * 4 + 3) & ~3; - sizergba = pitchrgba * height; - - os = 1; - switch (font->info.rgba) { - case FC_RGBA_VRGB: - os = pitch; - case FC_RGBA_RGB: - default: - rf = 0; - gf = 1; - bf = 2; - break; - case FC_RGBA_VBGR: - os = pitch; - case FC_RGBA_BGR: - bf = 0; - gf = 1; - rf = 2; - break; - } - if (sizergba > bufSizeRgba) - { - if (bufBitmapRgba != bufLocalRgba) - free (bufBitmapRgba); - bufBitmapRgba = (unsigned char *) malloc (sizergba); - if (!bufBitmapRgba) - continue; - bufSizeRgba = sizergba; - } - memset (bufBitmapRgba, 0, sizergba); - in_line = bufBitmap; - out_line = bufBitmapRgba; - for (y = 0; y < height; y++) - { - in = in_line; - out = (unsigned int *) out_line; - in_line += pitch * vmul; - out_line += pitchrgba; - for (x = 0; x < width * hmul; x += hmul) - { - red = green = blue = 0; - o = 0; - for (s = 0; s < 3; s++) - { - red += filters[rf][s]*in[x+o]; - green += filters[gf][s]*in[x+o]; - blue += filters[bf][s]*in[x+o]; - o += os; - } - red = red / 65536; - green = green / 65536; - blue = blue / 65536; - *out++ = (green << 24) | (red << 16) | (green << 8) | blue; - } - } + widthrgba = width; + pitchrgba = (widthrgba * 4 + 3) & ~3; + sizergba = pitchrgba * height; + + if (sizergba > bufSizeRgba) + { + if (bufBitmapRgba != bufLocalRgba) + free (bufBitmapRgba); + bufBitmapRgba = (unsigned char *) malloc (sizergba); + if (!bufBitmapRgba) { + bufBitmapRgba = bufLocalRgba; /* prevent free(NULL) later !! */ + continue; + } + bufSizeRgba = sizergba; + } + memset (bufBitmapRgba, 0, sizergba); + +#ifdef FIR_FILTER + { + unsigned char* line; + + /* perform in-place FIR filtering in either the horizontal or + * vertical direction + */ + switch (font->info.rgba) { + case FC_RGBA_RGB: + case FC_RGBA_BGR: + { + int h; + + line = bufBitmap; + for ( h = height; h > 0; h--, line += pitch ) { + int pix[6] = { 0, 0, 0, 0, 0, 0 }; + unsigned char* p = line; + unsigned char* limit = line + width*3; + int nn, val, val2; + + val = p[0]; + for (nn = 0; nn < 3; nn++) + pix[2+nn] += val*fir_filter[nn]; + + val = p[1]; + for (nn = 0; nn < 4; nn++) + pix[1+nn] += val*fir_filter[nn]; + + p += 2; + + for ( ; p < limit; p++ ) { + val = p[0]; + for (nn = 0; nn < 5; nn++) + pix[nn] += val*fir_filter[nn]; + + val2 = pix[0]/255; + if (val2 > 255) val2 = 255; + p[-2] = (unsigned char)val2; + + for (nn = 0; nn < 5; nn++) + pix[nn] = pix[nn+1]; + } + for (nn = 0; nn < 2; nn++ ) { + val2 = pix[nn]/255; + if (val2 > 255) val2 = 255; + p[nn-2] = (unsigned char)val2; + } + } + } + break; + + case FC_RGBA_VRGB: + case FC_RGBA_VBGR: + { + int w; + + for (w = 0; w < width; w++ ) { + int pix[6] = { 0, 0, 0, 0, 0, 0 }; + unsigned char* p = bufBitmap + w; + unsigned char* limit = bufBitmap + w + height*3*pitch; + int nn, val, val2; + + val = p[0]; + for (nn = 0; nn < 3; nn++) + pix[2+nn] += val*fir_filter[nn]; + + val = p[pitch]; + for (nn = 0; nn < 4; nn++ ) + pix[1+nn] += val*fir_filter[nn]; + + p += 2*pitch; + for ( ; p < limit; p += pitch ) { + val = p[0]; + for (nn = 0; nn < 5; nn++ ) + pix[nn] += val*fir_filter[nn]; + + val2 = pix[0]/255; + if (val2 > 255) val2 = 255; + p[-2*pitch] = (unsigned char)val2; + + for (nn = 0; nn < 5; nn++) + pix[nn] = pix[nn+1]; + } + + for (nn = 0; nn < 2; nn++) { + val2 = pix[nn]/255; + if (val2 > 255) val2 = 255; + p[(nn-2)*pitch] = (unsigned char)val2; + } + } + } + break; + + default: + ; + } + + /* now copy the resulting RGB graymap into an ARGB map */ + { + unsigned char* in_line = bufBitmap; + unsigned char* out_line = bufBitmapRgba; + int h; + + switch (font->info.rgba) { + case FC_RGBA_RGB: + for (h = height; h > 0; h--) { + unsigned char* in = in_line; + int* out = (int*)out_line; + int w; + + for (w = width; w > 0; w--, in += 3, out += 1) { + int r = in[0]; + int g = in[1]; + int b = in[2]; + + out[0] = (g << 24) | (r << 16) | (g << 8) | (b); + } + + in_line += pitch; + out_line += pitchrgba; + } + break; + + case FC_RGBA_BGR: + for (h = height; h > 0; h--) { + unsigned char* in = in_line; + int* out = (int*)out_line; + int w; + + for (w = width; w > 0; w--, in += 3, out += 1) { + int r = in[0]; + int g = in[1]; + int b = in[2]; + + out[0] = (g << 24) | (b << 16) | (g << 8) | (r); + } + + in_line += pitch; + out_line += pitchrgba; + } + break; + + case FC_RGBA_VRGB: + for (h = height; h > 0; h--) { + unsigned char* in = in_line; + unsigned char* out = out_line; + int w; + + for (w = width; w > 0; w--, in += 1, out += 4) { + int r = in[0*pitch]; + int g = in[1*pitch]; + int b = in[2*pitch]; + + ((int*)out)[0] = (g << 24) | (r << 16) | (g << 8) | (b); + } + + in_line += 3*pitch; + out_line += pitchrgba; + } + break; + + case FC_RGBA_VBGR: + for (h = height; h > 0; h--) { + unsigned char* in = in_line; + unsigned char* out = out_line; + int w; + + for (w = width; w > 0; w--, in += 1, out += 4) { + int r = in[0*pitch]; + int g = in[1*pitch]; + int b = in[2*pitch]; + + ((int*)out)[0] = (g << 24) | (b << 16) | (g << 8) | (r); + } + + in_line += 3*pitch; + out_line += pitchrgba; + } + break; + + default: + ; + } + } + } +#else /* !FIR_FILTER */ + { + int x, y; + unsigned char *in_line, *out_line, *in; + unsigned int *out; + unsigned int red, green, blue; + int rf, gf, bf; + int s; + int o, os; + + /* + * Filter the glyph to soften the color fringes + */ + widthrgba = width; + pitchrgba = (widthrgba * 4 + 3) & ~3; + sizergba = pitchrgba * height; + + os = 1; + switch (font->info.rgba) { + case FC_RGBA_VRGB: + os = pitch; + case FC_RGBA_RGB: + default: + rf = 0; + gf = 1; + bf = 2; + break; + case FC_RGBA_VBGR: + os = pitch; + case FC_RGBA_BGR: + bf = 0; + gf = 1; + rf = 2; + break; + } + in_line = bufBitmap; + out_line = bufBitmapRgba; + for (y = 0; y < height; y++) + { + in = in_line; + out = (unsigned int *) out_line; + in_line += pitch * vmul; + out_line += pitchrgba; + for (x = 0; x < width * hmul; x += hmul) + { + red = green = blue = 0; + o = 0; + for (s = 0; s < 3; s++) + { + red += filters[rf][s]*in[x+o]; + green += filters[gf][s]*in[x+o]; + blue += filters[bf][s]*in[x+o]; + o += os; + } + red = red / 65536; + green = green / 65536; + blue = blue / 65536; + *out++ = (green << 24) | (red << 16) | (green << 8) | blue; + } + } + } +#endif /* !FIR_FILTER */ xftg->glyph_memory = sizergba + sizeof (XftGlyph); if (font->format) Only in libXft-2.1.10.new/src: xftglyphs.c~ Only in libXft-2.1.10.new/src: xftglyphs.c.bak Only in libXft-2.1.10.new/src: xftglyphs.c.orig Only in libXft-2.1.10.new/src: xftglyphs.lo Only in libXft-2.1.10.new/src: xftglyphs.o Only in libXft-2.1.10.new/src: xftinit.lo Only in libXft-2.1.10.new/src: xftinit.o Only in libXft-2.1.10.new/src: xftlist.lo Only in libXft-2.1.10.new/src: xftlist.o Only in libXft-2.1.10.new/src: xftname.lo Only in libXft-2.1.10.new/src: xftname.o Only in libXft-2.1.10.new/src: xftrender.lo Only in libXft-2.1.10.new/src: xftrender.o Only in libXft-2.1.10.new/src: xftstr.lo Only in libXft-2.1.10.new/src: xftstr.o Only in libXft-2.1.10.new/src: xftswap.lo Only in libXft-2.1.10.new/src: xftswap.o Only in libXft-2.1.10.new/src: xftxlfd.lo Only in libXft-2.1.10.new/src: xftxlfd.o Only in libXft-2.1.10.new/: stamp-h1 Only in libXft-2.1.10.new/: xft-config Only in libXft-2.1.10.new/: xft.pc