summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp')
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp142
1 files changed, 93 insertions, 49 deletions
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
index 9fbc2bebc0..8c0c0324c9 100644
--- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
+++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -42,6 +42,7 @@ private slots:
void stringIndexes();
void retrievalFlags_data();
void retrievalFlags();
+ void objectReplacementCharacter();
private:
int m_testFontId;
@@ -407,7 +408,7 @@ void tst_QGlyphRun::drawMultiScriptText1()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
+ const QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 1);
{
@@ -417,8 +418,7 @@ void tst_QGlyphRun::drawMultiScriptText1()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphRun glyphs, glyphsList)
- p.drawGlyphRun(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphsList.first());
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -448,7 +448,7 @@ void tst_QGlyphRun::drawMultiScriptText2()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
+ const QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 2);
{
@@ -458,7 +458,7 @@ void tst_QGlyphRun::drawMultiScriptText2()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphRun glyphs, glyphsList)
+ for (const QGlyphRun &glyphs : glyphsList)
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
@@ -563,6 +563,9 @@ void tst_QGlyphRun::boundingRect()
void tst_QGlyphRun::mixedScripts()
{
+ if (QFontDatabase::families(QFontDatabase::Korean).isEmpty())
+ QSKIP("This test requires support for Hangul text");
+
QString s;
s += QChar(0x31); // The character '1'
s += QChar(0xbc14); // Hangul character
@@ -608,17 +611,43 @@ void tst_QGlyphRun::multiLineBoundingRect()
void tst_QGlyphRun::defaultIgnorables()
{
- QTextLayout layout;
- layout.setFont(QFont("QtsSpecialTestFont"));
- layout.setText(QChar(0x200D));
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
+ {
+ QTextLayout layout;
+ layout.setFont(QFont("QtsSpecialTestFont"));
+ layout.setText(QChar(0x200D));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> runs = layout.glyphRuns();
+ QCOMPARE(runs.size(), 0);
+ }
+
+ {
+ QTextLayout layout;
+ layout.setFont(QFont("QtsSpecialTestFont"));
+ layout.setText(QStringLiteral("AAA") + QChar(0xFE0F) + QStringLiteral("111"));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
- QList<QGlyphRun> runs = layout.glyphRuns();
- QCOMPARE(runs.size(), 1);
- QCOMPARE(runs.at(0).glyphIndexes().size(), 1);
- QCOMPARE(runs.at(0).glyphIndexes()[0], uint(0));
+ QList<QGlyphRun> runs = layout.glyphRuns();
+ QVERIFY(!runs.isEmpty());
+
+ bool hasFullMainFontRun = false;
+ for (const QGlyphRun &run : runs) {
+ // QtsSpecialFont will be used for at least five characters: AA[...]111
+ // Depending on the font selected for the 0xFE0F variant selector, the
+ // third 'A' may be in QtsSpecialFont or in the fallback. This is platform-specific,
+ // so we accept either.
+ if (run.rawFont().familyName() == QStringLiteral("QtsSpecialTestFont")
+ && run.glyphIndexes().size() >= 5) {
+ hasFullMainFontRun = true;
+ break;
+ }
+ }
+ QVERIFY(hasFullMainFontRun);
+ }
}
void tst_QGlyphRun::stringIndexes()
@@ -676,7 +705,7 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 1);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 233);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(233));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 1);
@@ -688,7 +717,7 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 1);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 233);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(233));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 1);
@@ -710,15 +739,15 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 3);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 71);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 233);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), 74);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(71));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(233));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), uint(74));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 3);
- QCOMPARE(stringIndexes.at(0), 0);
- QCOMPARE(stringIndexes.at(1), 1);
- QCOMPARE(stringIndexes.at(2), 3);
+ QCOMPARE(stringIndexes.at(0), uint(0));
+ QCOMPARE(stringIndexes.at(1), uint(1));
+ QCOMPARE(stringIndexes.at(2), uint(3));
}
{
@@ -726,11 +755,11 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 1);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 233);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(233));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 1);
- QCOMPARE(stringIndexes.at(0), 1);
+ QCOMPARE(stringIndexes.at(0), uint(1));
}
{
@@ -738,11 +767,11 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 1);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 233);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(233));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 1);
- QCOMPARE(stringIndexes.at(0), 1);
+ QCOMPARE(stringIndexes.at(0), uint(1));
}
{
@@ -750,8 +779,8 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 2);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 233);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 74);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(233));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(74));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 2);
@@ -774,13 +803,13 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 2);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 66);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 70);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(66));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(70));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 2);
- QCOMPARE(stringIndexes.at(0), 0);
- QCOMPARE(stringIndexes.at(1), 0);
+ QCOMPARE(stringIndexes.at(0), uint(0));
+ QCOMPARE(stringIndexes.at(1), uint(0));
}
// Three characters -> four glyphs
@@ -797,10 +826,10 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 4);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 71);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 66);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), 70);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(3), 74);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(71));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(66));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), uint(70));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(3), uint(74));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 4);
@@ -815,9 +844,9 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 3);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 66);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 70);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), 74);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(66));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(70));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), uint(74));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 3);
@@ -831,9 +860,9 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 3);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 71);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 66);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), 70);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(71));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(66));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), uint(70));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 3);
@@ -858,11 +887,11 @@ void tst_QGlyphRun::stringIndexes()
QCOMPARE(glyphRuns.size(), 1);
QCOMPARE(glyphRuns.at(0).glyphIndexes().size(), 5);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), 71);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), 233);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), 66);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(3), 70);
- QCOMPARE(glyphRuns.at(0).glyphIndexes().at(4), 74);
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(0), uint(71));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(1), uint(233));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(2), uint(66));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(3), uint(70));
+ QCOMPARE(glyphRuns.at(0).glyphIndexes().at(4), uint(74));
QList<qsizetype> stringIndexes = glyphRuns.at(0).stringIndexes();
QCOMPARE(stringIndexes.size(), 5);
@@ -928,6 +957,21 @@ void tst_QGlyphRun::retrievalFlags()
QCOMPARE(firstGlyphRun.positions().isEmpty(), !expectedGlyphPositions);
}
+void tst_QGlyphRun::objectReplacementCharacter()
+{
+ QTextLayout layout;
+ layout.setFont(m_testFont);
+ layout.setText(QStringLiteral("\uFFFC"));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 1);
+ QCOMPARE(glyphRuns.first().glyphIndexes().size(), 1);
+ QCOMPARE(glyphRuns.first().glyphIndexes().first(), uint(5));
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QGlyphRun)