From 0b87f4f6c912a508f170cd25ff5317bb77665fa9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 25 Mar 2014 10:08:05 +0100 Subject: 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 --- .../platforms/android/qandroidplatformfontdatabase.cpp | 18 ++++++++++++++---- .../platforms/android/qandroidplatformfontdatabase.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp index 7f68b44ed8..7423e6c55a 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp @@ -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_MONOSPACE")).split(";") + m_fallbacks[script]; - return QString(qgetenv("QT_ANDROID_FONTS")).split(";"); + return QString(qgetenv("QT_ANDROID_FONTS")).split(";") + m_fallbacks[script]; } diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.h b/src/plugins/platforms/android/qandroidplatformfontdatabase.h index 3cbfe95d36..cdd3cf1674 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.h +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.h @@ -53,6 +53,9 @@ public: QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; + +private: + QHash m_fallbacks; }; #endif // QANDROIDPLATFORMFONTDATABASE_H -- cgit v1.2.1