From 3e45d4824611b07835aa7a816d0aee3f5c49e87e Mon Sep 17 00:00:00 2001 From: Balazs Kelemen Date: Thu, 8 Mar 2012 17:02:15 +0100 Subject: [PATCH] Fix QFont hinting preference with fontconfig Consider if the hinting preference of the QFont is not PreferDefaultHinting. Change-Id: I0f50b320356787b6c1eabee5f009e7d326a06925 Reviewed-by: Jiang Jiang --- .../fontconfig/qfontconfigdatabase.cpp | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 69ec3ba08a..28a99cfd17 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -515,24 +515,37 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables:: FcCharSet *charset; if (match) { QFontEngineFT::HintStyle default_hint_style; - - //hinting - int hint_style = 0; - if (FcPatternGetInteger (match, 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; + if (f.hintingPreference != QFont::PreferDefaultHinting) { + switch (f.hintingPreference) { + case QFont::PreferNoHinting: + default_hint_style = QFontEngineFT::HintNone; + break; + case QFont::PreferVerticalHinting: + default_hint_style = QFontEngineFT::HintLight; + break; + case QFont::PreferFullHinting: + default: + default_hint_style = QFontEngineFT::HintFull; + break; + } + } else { + int hint_style = 0; + if (FcPatternGetInteger (match, 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);