summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp2
-rw-r--r--src/gui/text/qfontdatabase.cpp34
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp31
-rw-r--r--src/gui/text/qfontengine.cpp3
-rw-r--r--src/gui/text/qfontengine_p.h2
5 files changed, 38 insertions, 34 deletions
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
index e2306050dd..ce913a98af 100644
--- a/src/gui/kernel/qoffscreensurface.cpp
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -160,6 +160,8 @@ void QOffscreenSurface::create()
d->platformOffscreenSurface = QGuiApplicationPrivate::platformIntegration()->createPlatformOffscreenSurface(this);
// No platform offscreen surface, fallback to an invisible window
if (!d->platformOffscreenSurface) {
+ if (QThread::currentThread() != qGuiApp->thread())
+ qWarning("Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures.");
d->offscreenWindow = new QWindow(d->screen);
d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface);
d->offscreenWindow->setFormat(d->requestedFormat);
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index ff050d1758..61c93dc2ac 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -499,6 +499,8 @@ static const int scriptForWritingSystem[] = {
QChar::Script_Nko // Nko
};
+Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount);
+
int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
{
return scriptForWritingSystem[writingSystem];
@@ -562,9 +564,9 @@ struct QtFontDesc
int familyIndex;
};
-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>());
+static int match(int script, const QFontDef &request,
+ const QString &family_name, const QString &foundry_name, int force_encoding_id,
+ QtFontDesc *desc, const QList<int> &blacklisted);
static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi)
{
@@ -846,11 +848,12 @@ static bool matchFamilyName(const QString &familyName, QtFontFamily *f)
Tries to find the best match for a given request and family/foundry
*/
-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)
+static int match(int script, const QFontDef &request,
+ const QString &family_name, const QString &foundry_name, int force_encoding_id,
+ QtFontDesc *desc, const QList<int> &blacklistedFamilies)
{
Q_UNUSED(force_encoding_id);
+ int result = -1;
QtFontStyle::Key styleKey;
styleKey.style = request.style;
@@ -881,6 +884,8 @@ static void match(int script, const QFontDef &request,
load(family_name, script);
+ const size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem + QFontDatabase::WritingSystemsCount, script) - scriptForWritingSystem;
+
QFontDatabasePrivate *db = privateDb();
for (int x = 0; x < db->count; ++x) {
if (blacklistedFamilies.contains(x))
@@ -895,19 +900,9 @@ static void match(int script, const QFontDef &request,
if (family_name.isEmpty())
load(test.family->name, script);
- uint score_adjust = 0;
-
- bool supported = (script == QChar::Script_Common);
- for (int ws = 1; !supported && ws < QFontDatabase::WritingSystemsCount; ++ws) {
- if (scriptForWritingSystem[ws] != script)
- continue;
- if (test.family->writingSystems[ws] & QtFontFamily::Supported)
- supported = true;
- }
- if (!supported) {
- // family not supported in the script we want
+ // Check if family is supported in the script we want
+ if (script != QChar::Script_Common && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported))
continue;
- }
// as we know the script is supported, we can be sure
// to find a matching font here.
@@ -922,15 +917,16 @@ static void match(int script, const QFontDef &request,
QString(), styleKey, request.pixelSize,
pitch, &test, force_encoding_id);
}
- newscore += score_adjust;
if (newscore < score) {
+ result = x;
score = newscore;
*desc = test;
}
if (newscore < 10) // xlfd instead of FT... just accept it
break;
}
+ return result;
}
static QString styleStringHelper(int weight, QFont::Style style)
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index fddbb11122..6f4971e267 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -184,7 +184,6 @@ QFontEngine *loadSingleEngine(int script,
if (!engine) {
engine = pfdb->fontEngine(def, QChar::Script(script), size->handle);
if (engine) {
- engine->smoothScalable = style->smoothScalable;
QFontCache::Key key(def,script);
QFontCache::instance()->instance()->insertEngine(key,engine);
}
@@ -306,9 +305,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 +334,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 +344,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);
}
}
}
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 7d1afbbfb6..303c85ce75 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -208,8 +208,7 @@ Q_AUTOTEST_EXPORT QList<QFontEngine *> QFontEngine_stopCollectingEngines()
QFontEngine::QFontEngine()
: ref(0),
font_(0), font_destroy_func(0),
- face_(0), face_destroy_func(0),
- smoothScalable(false)
+ face_(0), face_destroy_func(0)
{
cache_cost = 0;
fsType = 0;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 07be498764..c181d61d73 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -302,8 +302,6 @@ public:
inline QVariant userData() const { return m_userData; }
- bool smoothScalable;
-
protected:
QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false);