Fathi Boudra wrote:
Hi,
This will be fixed in Qt 4.5.1 (ref
http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=248387).
In conclusion I hope you do not include the proposed patch in Debian or in
qt-copy :)
thanks for your reply.
Qt snapshots aren't updated since 2-3 weeks.
Is it possible to get the patch now and apply it to qt-copy ?
cheers,
Fathi
Sure, I've attached the patch to this mail.
Note that to enable the legacy LCD filtering you need to edit your
fonts.conf settings (http://fontconfig.org/fontconfig-user.html). It
should contain the snippet mentioned in this qt-interest post:
http://article.gmane.org/gmane.comp.lib.qt.general/11465
There is currently a bug in Cairo that causes it to use Legacy LCD
filtering by default (ref the discussion at
http://bugs.freedesktop.org/show_bug.cgi?id=10301). Thus, if you want Qt
applications to look like GTK applications you need to manually set the
LCD filtering method to Legacy as described in the qt-interest post above.
Cheers,
Samuel
>From b7f4094bcb9eccfb14c5b1f1e6502a4b11c78047 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Samuel=20R=C3=B8dal?= <sroe...@trolltech.com>
Date: Mon, 16 Mar 2009 14:26:22 +0100
Subject: [PATCH] X11: Use legacy LCD filtering if specified in font config.
If Freetype is built without subpixel rendering, we should use
the Qt 3 intrapixel filter instead of the bitmap convolution
when the Legacy LCD filter is chosen.
Task-number: 248387
Reviewed-by: Jens
---
src/gui/text/qfontengine_ft.cpp | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 264d8de..f2389e3 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -529,7 +529,7 @@ static const uint subpixel_filter[3][3] = {
};
#endif
-static void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr)
+static void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter)
{
int h = height;
const int offs = bgr ? -1 : 1;
@@ -540,8 +540,16 @@ static void convertRGBToARGB(const uchar *src, uint *dst, int width, int height,
uint red = src[x+1-offs];
uint green = src[x+1];
uint blue = src[x+1+offs];
- uint alpha = green;
- uint res = (alpha << 24) + (red << 16) + (green << 8) + blue;
+ uint res;
+#if !defined(QT_USE_FREETYPE_LCDFILTER)
+ if (legacyFilter) {
+ 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;
+ res = (mid << 24) + (high << 16) + (mid << 8) + low;
+ } else
+#endif
+ res = (green << 24) + (red << 16) + (green << 8) + blue;
*dd = res;
++dd;
}
@@ -941,7 +949,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
glyph_buffer = new uchar[glyph_buffer_size];
if (hsubpixel)
- convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_RGB);
+ convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_RGB, false);
else if (vfactor != 1)
convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_VRGB);
} else
@@ -1042,8 +1050,16 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
Q_ASSERT (bitmap.pixel_mode == FT_PIXEL_MODE_GRAY);
Q_ASSERT(antialias);
uchar *convoluted = new uchar[bitmap.rows*bitmap.pitch];
- convoluteBitmap(bitmap.buffer, convoluted, bitmap.width, info.height, bitmap.pitch);
- convertRGBToARGB(convoluted + 1, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_RGB);
+ bool useLegacyLcdFilter = false;
+#if defined(FT_LCD_FILTER_H)
+ useLegacyLcdFilter = (lcdFilterType == FT_LCD_FILTER_LEGACY);
+#endif
+ uchar *buffer = bitmap.buffer;
+ if (!useLegacyLcdFilter) {
+ convoluteBitmap(bitmap.buffer, convoluted, bitmap.width, info.height, bitmap.pitch);
+ buffer = convoluted;
+ }
+ convertRGBToARGB(buffer + 1, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_RGB, useLegacyLcdFilter);
delete [] convoluted;
} else if (vfactor != 1) {
convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_VRGB);
--
1.6.2