Revert "Avoid fontconfig access in fontEngine creation"

This reverts commit 8dcb52df8e.

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>
This commit is contained in:
Jiang Jiang 2011-11-03 15:15:16 +01:00 committed by Qt by Nokia
parent e142a64a33
commit 35f56b0cf9
2 changed files with 43 additions and 25 deletions

View File

@ -50,7 +50,6 @@ struct FontFile
{
QString fileName;
int indexValue;
int hintStyle;
};
class QBasicFontDatabase : public QPlatformFontDatabase

View File

@ -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;