Streamline font match() function.
Determine writing system before executing the loop. Change-Id: I6c462bdef4d70860e76c7cc9d939e3e92983b173 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
cb6c51f026
commit
6aa496c366
@ -499,6 +499,8 @@ static const int scriptForWritingSystem[] = {
|
|||||||
QChar::Script_Nko // Nko
|
QChar::Script_Nko // Nko
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount);
|
||||||
|
|
||||||
int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
|
int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
|
||||||
{
|
{
|
||||||
return scriptForWritingSystem[writingSystem];
|
return scriptForWritingSystem[writingSystem];
|
||||||
@ -882,6 +884,8 @@ static int match(int script, const QFontDef &request,
|
|||||||
|
|
||||||
load(family_name, script);
|
load(family_name, script);
|
||||||
|
|
||||||
|
const size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem + QFontDatabase::WritingSystemsCount, script) - scriptForWritingSystem;
|
||||||
|
|
||||||
QFontDatabasePrivate *db = privateDb();
|
QFontDatabasePrivate *db = privateDb();
|
||||||
for (int x = 0; x < db->count; ++x) {
|
for (int x = 0; x < db->count; ++x) {
|
||||||
if (blacklistedFamilies.contains(x))
|
if (blacklistedFamilies.contains(x))
|
||||||
@ -896,17 +900,9 @@ static int match(int script, const QFontDef &request,
|
|||||||
if (family_name.isEmpty())
|
if (family_name.isEmpty())
|
||||||
load(test.family->name, script);
|
load(test.family->name, script);
|
||||||
|
|
||||||
bool supported = (script == QChar::Script_Common);
|
// Check if family is supported in the script we want
|
||||||
for (int ws = 1; !supported && ws < QFontDatabase::WritingSystemsCount; ++ws) {
|
if (script != QChar::Script_Common && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported))
|
||||||
if (scriptForWritingSystem[ws] != script)
|
|
||||||
continue;
|
|
||||||
if (test.family->writingSystems[ws] & QtFontFamily::Supported)
|
|
||||||
supported = true;
|
|
||||||
}
|
|
||||||
if (!supported) {
|
|
||||||
// family not supported in the script we want
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
// as we know the script is supported, we can be sure
|
// as we know the script is supported, we can be sure
|
||||||
// to find a matching font here.
|
// to find a matching font here.
|
||||||
|
Loading…
Reference in New Issue
Block a user