Android: Fix font merging
Our fallback fonts would contain a minimal list of hardcoded fallback fonts, which is neither sufficient for displaying all text, nor portable to different vendors which can supply different font sets. [ChangeLog][Android] Fixed font merging problem which caused e.g. missing glyphs for Arabic numerals. Task-number: QTBUG-37738 Change-Id: Ic971343a1cd5610c79a81f6f6152c637937b5626 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
d668f1be22
commit
0b87f4f6c9
@ -531,7 +531,7 @@ static const int scriptForWritingSystem[] = {
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount);
|
||||
|
||||
int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
|
||||
Q_GUI_EXPORT int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
|
||||
{
|
||||
return scriptForWritingSystem[writingSystem];
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ void QBasicFontDatabase::releaseHandle(void *handle)
|
||||
|
||||
extern FT_Library qt_getFreetype();
|
||||
|
||||
QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file)
|
||||
QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file, QSupportedWritingSystems *supportedWritingSystems)
|
||||
{
|
||||
FT_Library library = qt_getFreetype();
|
||||
|
||||
@ -259,6 +259,8 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
|
||||
if (cm->encoding == FT_ENCODING_ADOBE_CUSTOM
|
||||
|| cm->encoding == FT_ENCODING_MS_SYMBOL) {
|
||||
writingSystems.setSupported(QFontDatabase::Symbol);
|
||||
if (supportedWritingSystems)
|
||||
supportedWritingSystems->setSupported(QFontDatabase::Symbol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -277,6 +279,8 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
|
||||
};
|
||||
|
||||
writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
|
||||
if (supportedWritingSystems)
|
||||
*supportedWritingSystems = writingSystems;
|
||||
|
||||
if (os2->usWeightClass == 0)
|
||||
;
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
|
||||
void releaseHandle(void *handle);
|
||||
|
||||
static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file);
|
||||
static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QSupportedWritingSystems *supportedWritingSystems = 0);
|
||||
static QString fontNameFromTTFile(const QString &filename);
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,17 @@ void QAndroidPlatformFontDatabase::populateFontDatabase()
|
||||
QDir dir(fontpath, QLatin1String("*.ttf"));
|
||||
for (int i = 0; i < int(dir.count()); ++i) {
|
||||
const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
|
||||
addTTFile(QByteArray(), file);
|
||||
|
||||
QSupportedWritingSystems supportedWritingSystems;
|
||||
QStringList families = addTTFile(QByteArray(), file, &supportedWritingSystems);
|
||||
|
||||
extern int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem);
|
||||
for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
|
||||
if (i == QFontDatabase::Any || supportedWritingSystems.supported(QFontDatabase::WritingSystem(i))) {
|
||||
QChar::Script script = QChar::Script(qt_script_for_writing_system(QFontDatabase::WritingSystem(i)));
|
||||
m_fallbacks[script] += families;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,9 +81,9 @@ QStringList QAndroidPlatformFontDatabase::fallbacksForFamily(const QString &fami
|
||||
{
|
||||
Q_UNUSED(family);
|
||||
Q_UNUSED(style);
|
||||
Q_UNUSED(script);
|
||||
if (styleHint == QFont::Monospace)
|
||||
return QString(qgetenv("QT_ANDROID_FONTS_MONOSPACE")).split(";");
|
||||
|
||||
return QString(qgetenv("QT_ANDROID_FONTS")).split(";");
|
||||
if (styleHint == QFont::Monospace)
|
||||
return QString(qgetenv("QT_ANDROID_FONTS_MONOSPACE")).split(";") + m_fallbacks[script];
|
||||
|
||||
return QString(qgetenv("QT_ANDROID_FONTS")).split(";") + m_fallbacks[script];
|
||||
}
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
QFont::Style style,
|
||||
QFont::StyleHint styleHint,
|
||||
QChar::Script script) const;
|
||||
|
||||
private:
|
||||
QHash<QChar::Script, QStringList> m_fallbacks;
|
||||
};
|
||||
|
||||
#endif // QANDROIDPLATFORMFONTDATABASE_H
|
||||
|
Loading…
Reference in New Issue
Block a user