summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2016-04-26 12:09:17 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2016-04-27 00:40:02 +0000
commitc003a18ee332abf2387172eb0856a176a32a6c8f (patch)
tree7f1da9eb2f3027d8286bdb011849be1a9aaaf540
parent6e306e8d942464d969c3792e6299aa014a2d2b8f (diff)
Fix font fallback for an overridden Common script cases
Always prefer the requested font, even if it doesn't support the script of interest, and fallback to a font that *does* support that script, so that the best-matching font always takes a precedence. The result looks much closer to what CT and GDI/DW does. Task-number: QTBUG-35836 Task-number: QTBUG-39377 Task-number: QTBUG-43408 Change-Id: I6a89593565683f318f7292ec5ecf271dadc4142a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--src/gui/text/qfontdatabase.cpp4
-rw-r--r--src/gui/text/qfontdatabase.h1
-rw-r--r--src/gui/text/qrawfont.cpp14
3 files changed, 17 insertions, 2 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 629a098fb7..e4c9b45dc2 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2669,7 +2669,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
QtFontDesc desc;
QList<int> blackListed;
- int index = match(script, request, family_name, foundry_name, &desc, blackListed);
+ int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed);
if (index >= 0) {
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
if (engine)
@@ -2702,7 +2702,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
if (!engine) {
QtFontDesc desc;
do {
- index = match(script, def, def.family, QLatin1String(""), &desc, blackListed);
+ index = match(multi ? QChar::Script_Common : script, def, def.family, QLatin1String(""), &desc, blackListed);
if (index >= 0) {
QFontDef loadDef = def;
if (loadDef.family.isEmpty())
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 36e5677b92..67cf671304 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -167,6 +167,7 @@ private:
friend class QFontDialog;
friend class QFontDialogPrivate;
friend class QFontEngineMulti;
+ friend class QRawFont;
QFontDatabasePrivate *d;
};
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 2a53b8869d..19ac4f1dbc 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -700,6 +700,20 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
if (fe != 0 && fe->type() == QFontEngine::Multi) {
QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(fe);
fe = multiEngine->engine(0);
+
+ if (script > QChar::Script_Latin) {
+ // keep in sync with QFontEngineMulti::loadEngine()
+ QFontDef request(multiEngine->fontDef);
+ request.styleStrategy |= QFont::NoFontMerging;
+
+ if (QFontEngine *engine = QFontDatabase::findFont(request, script)) {
+ if (request.weight > QFont::Normal)
+ engine->fontDef.weight = request.weight;
+ if (request.style > QFont::StyleNormal)
+ engine->fontDef.style = request.style;
+ fe = engine;
+ }
+ }
Q_ASSERT(fe);
}