Preserve weight and style request for multi font engines
authorJiang Jiang <jiang.jiang@nokia.com>
Wed, 8 Feb 2012 16:28:13 +0000 (17:28 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 9 Feb 2012 11:54:29 +0000 (12:54 +0100)
So that fallback fonts can pickup the weight/style requested instead
of using the weight and style of the primary font.

Change-Id: Ia592e079cad61334f21e0453412b198a900bb6b6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
src/gui/text/qfontdatabase.cpp
src/gui/text/qfontdatabase_qpa.cpp

index 3ef28b8..e9b7d1a 100644 (file)
@@ -724,7 +724,7 @@ static void match(int script, const QFontDef &request,
                   const QString &family_name, const QString &foundry_name, int force_encoding_id,
                   QtFontDesc *desc, const QList<int> &blacklistedFamilies = QList<int>(), bool forceXLFD=false);
 
-static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef)
+static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi)
 {
     fontDef->family = desc.family->name;
     if (! desc.foundry->name.isEmpty() && desc.family->count > 1) {
@@ -743,8 +743,10 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
     fontDef->styleHint     = request.styleHint;
     fontDef->styleStrategy = request.styleStrategy;
 
-    fontDef->weight        = desc.style->key.weight;
-    fontDef->style         = desc.style->key.style;
+    if (!multi)
+        fontDef->weight    = desc.style->key.weight;
+    if (!multi)
+        fontDef->style     = desc.style->key.style;
     fontDef->fixedPitch    = desc.family->fixedPitch;
     fontDef->stretch       = desc.style->key.stretch;
     fontDef->ignorePitch   = false;
index c57fe4b..266ad4d 100644 (file)
@@ -278,7 +278,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
     }
 
     if (engine && engine->type() != QFontEngine::TestFontEngine) {
-        initFontDef(desc, request, &engine->fontDef);
+        initFontDef(desc, request, &engine->fontDef, engine->type() == QFontEngine::Multi);
 
         if (fp) {
             QFontDef def = request;
@@ -305,7 +305,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
                     }
                     engine = loadEngine(script, def, desc.family, desc.foundry, desc.style, desc.size);
                     if (engine) {
-                        initFontDef(desc, def, &engine->fontDef);
+                        initFontDef(desc, def, &engine->fontDef, engine->type() == QFontEngine::Multi);
                     }
                 }
             }