From 6593531a4dccdfb878d2ee3a789f0e937d73e8e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Wed, 5 Nov 2014 08:58:46 +0000 Subject: [PATCH] Windows: Respect hinting preferences with FreeType engine. One of the fontEngine()'s methods was missing hinting. This bug only manifests on Windows because on Linux QFontConfigDataBase already sets hinting on both code paths. Task-number: QTBUG-42534 Change-Id: I3a66a9d4aaa5e390fee305a3d5aacfeba38a1fc3 Reviewed-by: Konstantin Ritt --- .../basic/qbasicfontdatabase.cpp | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index 43903acfe1..52505c570b 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -106,6 +106,24 @@ void QBasicFontDatabase::populateFontDatabase() } } +inline static void setHintingPreference(QFontEngine *engine, QFont::HintingPreference hintingPreference) +{ + switch (hintingPreference) { + case QFont::PreferNoHinting: + engine->setDefaultHintStyle(QFontEngineFT::HintNone); + break; + case QFont::PreferFullHinting: + engine->setDefaultHintStyle(QFontEngineFT::HintFull); + break; + case QFont::PreferVerticalHinting: + engine->setDefaultHintStyle(QFontEngineFT::HintLight); + break; + case QFont::PreferDefaultHinting: + // Leave it as it is + break; + } +} + QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, void *usrPtr) { FontFile *fontfile = static_cast (usrPtr); @@ -120,6 +138,8 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, void *usrPt if (!engine->init(fid, antialias, format) || engine->invalid()) { delete engine; engine = 0; + } else { + setHintingPreference(engine, static_cast(fontDef.hintingPreference)); } return engine; @@ -172,21 +192,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QByteArray &fontData, qreal pi } fe->updateFamilyNameAndStyle(); - - switch (hintingPreference) { - case QFont::PreferNoHinting: - fe->setDefaultHintStyle(QFontEngineFT::HintNone); - break; - case QFont::PreferFullHinting: - fe->setDefaultHintStyle(QFontEngineFT::HintFull); - break; - case QFont::PreferVerticalHinting: - fe->setDefaultHintStyle(QFontEngineFT::HintLight); - break; - default: - // Leave it as it is - break; - } + setHintingPreference(fe, hintingPreference); return fe; }