summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase_qpa.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-11-27 16:32:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-28 11:21:44 +0100
commitf29e38f9a433ce7e47eb9ec88927b184c856dd6d (patch)
treeb2be62f6c85f5578032f4a5f276aa38c0d29fcb6 /src/gui/text/qfontdatabase_qpa.cpp
parentdc80838a378268a13ccbe74b481528f1ad631918 (diff)
Fix font lookup.
Change match() to return an index and use that to reintroduce the blacklist bookkeeping for fonts for which font engine creation fails (for example, due to missing open type support). Change the algorithm to retry search if that happens. Add empty string as fallback for non-common scripts indicating 'try to find any font matching the script' as is done in Qt 4. Task-number: QTBUG-34908 Change-Id: I9ac81ff1c275ebb635675dc26b52394789fca60c Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/text/qfontdatabase_qpa.cpp')
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index fddbb11122..98e89a8327 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -306,9 +306,12 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
}
QtFontDesc desc;
- match(script, request, family_name, foundry_name, force_encoding_id, &desc);
- if (desc.family != 0 && desc.foundry != 0 && desc.style != 0) {
+ QList<int> blackListed;
+ int index = match(script, request, family_name, foundry_name, force_encoding_id, &desc, blackListed);
+ if (index >= 0) {
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
+ if (!engine)
+ blackListed.append(index);
} else {
FM_DEBUG(" NO MATCH FOUND\n");
}
@@ -332,6 +335,8 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
QFont::Style(request.style),
QFont::StyleHint(request.styleHint),
QChar::Script(script));
+ if (script > QChar::Script_Common)
+ fallbacks += QString(); // Find the first font matching the specified script.
for (int i = 0; !engine && i < fallbacks.size(); i++) {
QFontDef def = request;
@@ -340,14 +345,19 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
engine = QFontCache::instance()->findEngine(key);
if (!engine) {
QtFontDesc desc;
- match(script, def, def.family, QLatin1String(""), 0, &desc);
- if (desc.family == 0 && desc.foundry == 0 && desc.style == 0) {
- continue;
- }
- engine = loadEngine(script, def, desc.family, desc.foundry, desc.style, desc.size);
- if (engine) {
- initFontDef(desc, def, &engine->fontDef, engine->type() == QFontEngine::Multi);
- }
+ do {
+ index = match(script, def, def.family, QLatin1String(""), 0, &desc, blackListed);
+ if (index >= 0) {
+ QFontDef loadDef = def;
+ if (loadDef.family.isEmpty())
+ loadDef.family = desc.family->name;
+ engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size);
+ if (engine)
+ initFontDef(desc, loadDef, &engine->fontDef, engine->type() == QFontEngine::Multi);
+ else
+ blackListed.append(index);
+ }
+ } while (index >= 0 && !engine);
}
}
}