summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-11-03 15:15:16 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-04 15:58:17 +0100
commit35f56b0cf97a9cc39ef4cdbedc9f502ffcc61ea1 (patch)
tree1f437a6e33fbf6e19414dd87dfd059bf515ed106 /src/platformsupport
parente142a64a33a54c433a38d330d64292b7e7698c92 (diff)
Revert "Avoid fontconfig access in fontEngine creation"
This reverts commit 8dcb52df8e2e949232ccded9fad5a4f25ba6dda2. Turns out that hint style is retrieved from font match instead of pattern match, which shouldn't be retreived until font engine creation. Change-Id: I90e779a3823e6a6604cdadb52586fcd5e22c295b Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h1
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp67
2 files changed, 43 insertions, 25 deletions
diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h
index 2a529be2d5..3816ec5862 100644
--- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h
@@ -50,7 +50,6 @@ struct FontFile
{
QString fileName;
int indexValue;
- int hintStyle;
};
class QBasicFontDatabase : public QPlatformFontDatabase
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 3f4aeb2d4a..0a4ca116d1 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -319,7 +319,7 @@ void QFontconfigDatabase::populateFontDatabase()
FC_FAMILY, FC_WEIGHT, FC_SLANT,
FC_SPACING, FC_FILE, FC_INDEX,
FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT,
- FC_WIDTH, FC_HINT_STYLE,
+ FC_WIDTH,
#if FC_VERSION >= 20297
FC_CAPABILITY,
#endif
@@ -409,31 +409,9 @@ void QFontconfigDatabase::populateFontDatabase()
}
#endif
- QFontEngineFT::HintStyle default_hint_style;
-
- // hinting
- int hint_style = 0;
- if (FcPatternGetInteger(fonts->fonts[i], FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
- hint_style = QFontEngineFT::HintFull;
- switch (hint_style) {
- case FC_HINT_NONE:
- default_hint_style = QFontEngineFT::HintNone;
- break;
- case FC_HINT_SLIGHT:
- default_hint_style = QFontEngineFT::HintLight;
- break;
- case FC_HINT_MEDIUM:
- default_hint_style = QFontEngineFT::HintMedium;
- break;
- default:
- default_hint_style = QFontEngineFT::HintFull;
- break;
- }
-
FontFile *fontFile = new FontFile;
fontFile->fileName = QLatin1String((const char *)file_value);
fontFile->indexValue = indexValue;
- fontFile->hintStyle = default_hint_style;
QFont::Style style = (slant_value == FC_SLANT_ITALIC)
? QFont::StyleItalic
@@ -507,7 +485,48 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
engine = new QFontEngineFT(fontDef);
- engine->setDefaultHintStyle(QFontEngineFT::HintStyle(fontfile->hintStyle));
+
+ // try and get the pattern
+ FcPattern *pattern = FcPatternCreate();
+
+ FcValue value;
+ value.type = FcTypeString;
+ QByteArray cs = fontDef.family.toUtf8();
+ 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);
+
+ value.type = FcTypeInteger;
+ value.u.i = fid.index;
+ FcPatternAdd(pattern,FC_INDEX,value,true);
+
+ if (FcConfigSubstitute(0,pattern,FcMatchPattern)) {
+ QFontEngineFT::HintStyle default_hint_style;
+
+ //hinting
+ int hint_style = 0;
+ if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
+ hint_style = QFontEngineFT::HintFull;
+ switch (hint_style) {
+ case FC_HINT_NONE:
+ default_hint_style = QFontEngineFT::HintNone;
+ break;
+ case FC_HINT_SLIGHT:
+ default_hint_style = QFontEngineFT::HintLight;
+ break;
+ case FC_HINT_MEDIUM:
+ default_hint_style = QFontEngineFT::HintMedium;
+ break;
+ default:
+ default_hint_style = QFontEngineFT::HintFull;
+ break;
+ }
+ engine->setDefaultHintStyle(default_hint_style);
+ }
+ FcPatternDestroy(pattern);
if (!engine->init(fid,antialias,format)) {
delete engine;