From 1dd9a0af4f577ccb5578cea562a98686c8e290e6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 9 Jul 2014 09:49:59 +0200 Subject: Fix fallbacks for adapted common script When the platform plugin gives us specific fallbacks for a specific script, we need to respect this, and load the correct font family regardless of which writing systems it supports. This is especially important since the common script is adapted to match surrounding, proper scripts, so characters such as digits next to e.g. Hebrew text will be marked as Hebrew. On stock Android, there is a single Hebrew font, and this would previously be put in all fallback slots for Hebrew regardless of what fallback fonts were dictated by the platform plugin. Since this font does not support the digits, they would show up as boxes. [ChangeLog][Android] Fixed common characters like digits and punctuation showing as boxes when positioned next to non-latin scripts. Task-number: QTBUG-39377 Change-Id: I1555e208a8ddc587c0bbdbfff1600cafdd9442e9 Reviewed-by: Konstantin Ritt --- .../auto/gui/text/qfontdatabase/qfontdatabase.pro | 5 +++++ tests/auto/gui/text/qfontdatabase/testdata.qrc | 5 +++++ .../gui/text/qfontdatabase/tst_qfontdatabase.cpp | 24 ++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 tests/auto/gui/text/qfontdatabase/testdata.qrc (limited to 'tests') diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 6975c4088b..831ed1f572 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -9,3 +9,8 @@ wince* { additionalFiles.path = . DEPLOYMENT += additionalFiles } + +android { + RESOURCES += testdata.qrc +} + diff --git a/tests/auto/gui/text/qfontdatabase/testdata.qrc b/tests/auto/gui/text/qfontdatabase/testdata.qrc new file mode 100644 index 0000000000..8a8670bf17 --- /dev/null +++ b/tests/auto/gui/text/qfontdatabase/testdata.qrc @@ -0,0 +1,5 @@ + + + LED_REAL.TTF + + diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 28db0ba291..2ae12ec246 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include class tst_QFontDatabase : public QObject @@ -77,6 +79,7 @@ private slots: void addAppFont(); void aliases(); + void fallbackFonts(); private: const QString m_testFont; @@ -285,5 +288,26 @@ void tst_QFontDatabase::aliases() QVERIFY(db.hasFamily(alias)); } +void tst_QFontDatabase::fallbackFonts() +{ + QTextLayout layout; + QString s; + s.append(QChar(0x31)); + s.append(QChar(0x05D0)); + layout.setText(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList runs = layout.glyphRuns(0, 1); + foreach (QGlyphRun run, runs) { + QRawFont rawFont = run.rawFont(); + QVERIFY(rawFont.isValid()); + + QCOMPARE(run.glyphIndexes().size(), 1); + QVERIFY(run.glyphIndexes().at(0) != 0); + } +} + QTEST_MAIN(tst_QFontDatabase) #include "tst_qfontdatabase.moc" -- cgit v1.2.3 From 0cbebb21cc4406059eac19f026e67549a195d089 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 10 Jul 2014 16:09:42 +0200 Subject: Android: Prefer "Droid Serif" as default serif font I've also updated the qfont test so it passes on Android now. Note that there are no suitable cursive/fantasy fonts on Android, so the regular default "Roboto" (or "Droid Sans" on older devices) will be picked here instead. [ChangeLog][Android] Fixed font selection to prefer "Droid Serif" when Serif style hint is set on QFont. Change-Id: I294eebcc4d79410e435bdddce552acc6044753b2 Reviewed-by: Christian Stromme --- tests/auto/gui/text/qfont/tst_qfont.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 4c88212c72..995f7a0378 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -624,11 +624,11 @@ void tst_QFont::defaultFamily_data() QTest::addColumn("styleHint"); QTest::addColumn("acceptableFamilies"); - QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << getPlatformGenericFont("serif")); - QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << getPlatformGenericFont("monospace")); - QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << getPlatformGenericFont("cursive")); - QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << getPlatformGenericFont("fantasy")); - QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << getPlatformGenericFont("sans-serif")); + QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << "Droid Serif" << getPlatformGenericFont("serif")); + QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace")); + QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive")); + QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy")); + QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << getPlatformGenericFont("sans-serif")); } void tst_QFont::defaultFamily() -- cgit v1.2.3