Fix Japan locale not showing japanese fonts correctly
Fallback font determination did not take locale into account when Japanese locale was used. Android devices show Chinese fonts instead. Fixes the problem by prepending japanese defaut "Noto Sans Mono CJK ..." type font before other fonts. Does same for Chinese and Korean locales. Fixes: QTBUG-111528 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I70994c0059c3819eeb09dacb9bbe6634490ecf37 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
f54393ba70
commit
476e8f8aef
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include "qandroidplatformfontdatabase.h"
|
#include "qandroidplatformfontdatabase.h"
|
||||||
|
|
||||||
@ -47,6 +48,38 @@ QStringList QAndroidPlatformFontDatabase::fallbacksForFamily(const QString &fami
|
|||||||
QChar::Script script) const
|
QChar::Script script) const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
|
// Prepend CJK fonts by the locale.
|
||||||
|
QLocale locale = QLocale::system();
|
||||||
|
switch (locale.language()) {
|
||||||
|
case QLocale::Chinese: {
|
||||||
|
switch (locale.territory()) {
|
||||||
|
case QLocale::China:
|
||||||
|
case QLocale::Singapore:
|
||||||
|
result.append(QStringLiteral("Noto Sans Mono CJK SC"));
|
||||||
|
break;
|
||||||
|
case QLocale::Taiwan:
|
||||||
|
case QLocale::HongKong:
|
||||||
|
case QLocale::Macao:
|
||||||
|
result.append(QStringLiteral("Noto Sans Mono CJK TC"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// no modifications.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QLocale::Japanese:
|
||||||
|
result.append(QStringLiteral("Noto Sans Mono CJK JP"));
|
||||||
|
break;
|
||||||
|
case QLocale::Korean:
|
||||||
|
result.append(QStringLiteral("Noto Sans Mono CJK KR"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// no modifications.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (styleHint == QFont::Monospace || styleHint == QFont::Courier)
|
if (styleHint == QFont::Monospace || styleHint == QFont::Courier)
|
||||||
result.append(QString(qgetenv("QT_ANDROID_FONTS_MONOSPACE")).split(u';'));
|
result.append(QString(qgetenv("QT_ANDROID_FONTS_MONOSPACE")).split(u';'));
|
||||||
else if (styleHint == QFont::Serif)
|
else if (styleHint == QFont::Serif)
|
||||||
|
Loading…
Reference in New Issue
Block a user