--- qfontengine_x11.cpp.orig 2006-10-20 17:35:17.000000000 +0200 +++ qfontengine_x11.cpp 2006-10-31 15:06:32.000000000 +0100 @@ -1553,59 +1553,42 @@ if (hsubpixel) { Q_ASSERT (bitmap.pixel_mode == FT_PIXEL_MODE_GRAY); Q_ASSERT(fe->antialias); + uint *dst = (uint *)glyph_buffer; const uchar *src = bitmap.buffer; - uchar *convoluted = new uchar[bitmap.rows*bitmap.pitch]; - uchar *c = convoluted; - // convolute the bitmap with a triangle filter to get rid of color fringes - // If we take account for a gamma value of 2, we end up with - // weights of 1, 4, 9, 4, 1. We use an approximation of 1, 3, 8, 3, 1 here, - // as this nicely sums up to 16 :) int h = info.height; - while (h--) { - c[0] = c[1] = 0; - // - for (int x = 2; x < bitmap.width - 2; ++x) { - uint sum = src[x-2] + 3*src[x-1] + 8*src[x] + 3*src[x+1] + src[x+2]; - c[x] = (uchar) (sum >> 4); - } - c[bitmap.width - 2] = c[bitmap.width -1] = 0; - src += bitmap.pitch; - c += bitmap.pitch; - } - - uint *dst = (uint *)glyph_buffer; - src = convoluted; - h = info.height; if (fe->subpixel == FC_RGBA_RGB) { while (h--) { - uint *dd = dst; - for (int x = 1; x < bitmap.width - 1; x += 3) { - uint red = src[x]; - uint green = src[x+1]; - uint blue = src[x+2]; - uint res = (red << 16) + (green << 8) + blue; - *dd = res; - ++dd; + const uchar *ss = src + 1; + for (int x = 0; x < info.width; x++) { + uint red = *ss++; + uint green = *ss++; + uint blue = *ss++; + uint high = (red*subpixel_filter[0][0] + green*subpixel_filter[0][1] + blue*subpixel_filter[0][2]) >> 8; + uint mid = (red*subpixel_filter[1][0] + green*subpixel_filter[1][1] + blue*subpixel_filter[1][2]) >> 8; + uint low = (red*subpixel_filter[2][0] + green*subpixel_filter[2][1] + blue*subpixel_filter[2][2]) >> 8; + uint res = (high << 16) + (mid << 8) + low; + dst[x] = res; } dst += info.width; src += bitmap.pitch; } } else { while (h--) { - uint *dd = dst; - for (int x = 1; x < bitmap.width - 1; x += 3) { - uint blue = src[x]; - uint green = src[x+1]; - uint red = src[x+2]; - uint res = (red << 16) + (green << 8) + blue; - *dd = res; - ++dd; + const uchar *ss = src + 1; + for (int x = 0; x < info.width; x++) { + uint blue = *ss++; + uint green = *ss++; + uint red = *ss++; + uint high = (red*subpixel_filter[0][0] + green*subpixel_filter[0][1] + blue*subpixel_filter[0][2]) >> 8; + uint mid = (red*subpixel_filter[1][0] + green*subpixel_filter[1][1] + blue*subpixel_filter[1][2]) >> 8; + uint low = (red*subpixel_filter[2][0] + green*subpixel_filter[2][1] + blue*subpixel_filter[2][2]) >> 8; + uint res = (high << 16) + (mid << 8) + low; + dst[x] = res; } dst += info.width; src += bitmap.pitch; } } - delete [] convoluted; delete [] bitmap.buffer; } else if (vfactor != 1) { uchar *src = bitmap.buffer;