summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-11-04 16:09:45 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-05 02:29:32 +0100
commitbdf2225b9bc32a6ac6013b6860f8613d349b765a (patch)
tree4b90b89de4f0690abeb290b6e33ae54c98a11a81 /src
parent087fcc61824a54e49e68b9090b2983ef7dd18ddb (diff)
Restore subpixel rendering support with fontconfig and FreeType
Change-Id: I45cf83374ba5a8b1ae88415950c1e5ab72991598 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfontengine_ft_p.h3
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp39
2 files changed, 35 insertions, 7 deletions
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index bbef0bfcc7..6124eae91b 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -74,6 +74,7 @@
QT_BEGIN_NAMESPACE
class QFontEngineFTRawFont;
+class QFontconfigDatabase;
/*
* This struct represents one font file on disk (like Arial.ttf) and is shared between all the font engines
@@ -189,7 +190,6 @@ public:
QGlyphSet();
~QGlyphSet();
FT_Matrix transformationMatrix;
- unsigned long id; // server sided id, GlyphSet for X11
bool outline_drawing;
void removeGlyphFromCache(glyph_t index, QFixed subPixelPosition);
@@ -346,6 +346,7 @@ protected:
private:
friend class QFontEngineFTRawFont;
+ friend class QFontconfigDatabase;
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 0a4ca116d1..3c37be209e 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -482,10 +482,9 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
fid.index = fontfile->indexValue;
bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
- QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
-
engine = new QFontEngineFT(fontDef);
+ QFontEngineFT::GlyphFormat format;
// try and get the pattern
FcPattern *pattern = FcPatternCreate();
@@ -495,7 +494,6 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
value.u.s = (const FcChar8 *)cs.data();
FcPatternAdd(pattern,FC_FAMILY,value,true);
-
value.u.s = (const FcChar8 *)fid.filename.data();
FcPatternAdd(pattern,FC_FILE,value,true);
@@ -503,12 +501,14 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
value.u.i = fid.index;
FcPatternAdd(pattern,FC_INDEX,value,true);
- if (FcConfigSubstitute(0,pattern,FcMatchPattern)) {
+ FcResult result;
+ FcPattern *match = FcFontMatch(0, pattern, &result);
+ if (match) {
QFontEngineFT::HintStyle default_hint_style;
//hinting
int hint_style = 0;
- if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
+ if (FcPatternGetInteger (match, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
hint_style = QFontEngineFT::HintFull;
switch (hint_style) {
case FC_HINT_NONE:
@@ -525,7 +525,34 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
break;
}
engine->setDefaultHintStyle(default_hint_style);
- }
+
+ if (antialias) {
+ QFontEngineFT::SubpixelAntialiasingType subpixelType = QFontEngineFT::Subpixel_None;
+ int subpixel = FC_RGBA_NONE;
+
+ FcPatternGetInteger(match, FC_RGBA, 0, &subpixel);
+ if (subpixel == FC_RGBA_UNKNOWN)
+ subpixel = FC_RGBA_NONE;
+
+ switch (subpixel) {
+ case FC_RGBA_NONE: subpixelType = QFontEngineFT::Subpixel_None; break;
+ case FC_RGBA_RGB: subpixelType = QFontEngineFT::Subpixel_RGB; break;
+ case FC_RGBA_BGR: subpixelType = QFontEngineFT::Subpixel_BGR; break;
+ case FC_RGBA_VRGB: subpixelType = QFontEngineFT::Subpixel_VRGB; break;
+ case FC_RGBA_VBGR: subpixelType = QFontEngineFT::Subpixel_VBGR; break;
+ default: break;
+ }
+
+ format = subpixelType == QFontEngineFT::Subpixel_None
+ ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_A32;
+ engine->subpixelType = subpixelType;
+ } else
+ format = QFontEngineFT::Format_Mono;
+
+ FcPatternDestroy(match);
+ } else
+ format = antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
+
FcPatternDestroy(pattern);
if (!engine->init(fid,antialias,format)) {