diff options
author | Iikka Eklund <iikka.eklund@digia.com> | 2014-04-01 11:44:26 +0300 |
---|---|---|
committer | Iikka Eklund <iikka.eklund@digia.com> | 2014-04-01 11:44:27 +0300 |
commit | 0ab63b035a649dc1982c867cd37d466d249004b9 (patch) | |
tree | 6de22edcd3957aae3eee698136a000e52ab7f8fe /tests/auto/gui/text | |
parent | a6f8aa0ae1d5a1d1099df1891ea60b14b6eb6065 (diff) | |
parent | 0cb2c760c219514849ab0f6be8e5368f92dfa5d9 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I2a6eb9dd7724931bc89f28bcc156e77c4e26d069
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r-- | tests/auto/gui/text/qfont/tst_qfont.cpp | 34 | ||||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/FreeMono.ttf | bin | 267400 -> 0 bytes | |||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/LED_REAL.TTF | bin | 0 -> 4708 bytes | |||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt | 34 | ||||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp | 287 |
6 files changed, 201 insertions, 156 deletions
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 8406e843cf..6f75a1f8bb 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -74,7 +74,6 @@ private slots: void resetFont(); #endif void isCopyOf(); - void setFontRaw(); void italicOblique(); void insertAndRemoveSubstitutions(); void serialize_data(); @@ -418,15 +417,6 @@ void tst_QFont::compare() QVERIFY(font == font2); QVERIFY(!(font < font2)); } - -#if defined(Q_WS_X11) - { - QFont font1, font2; - font1.setRawName("-Adobe-Helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1"); - font2.setRawName("-Adobe-Helvetica-medium-r-normal--24-240-75-75-p-130-iso8859-1"); - QVERIFY(font1 != font2); - } -#endif } void tst_QFont::resolve() @@ -520,30 +510,6 @@ void tst_QFont::isCopyOf() QVERIFY(!font3.isCopyOf(font)); } -void tst_QFont::setFontRaw() -{ -#ifndef Q_WS_X11 - QSKIP("Only tested on X11"); -#else - QFont f; - f.setRawName("-*-fixed-bold-r-normal--0-0-*-*-*-0-iso8859-1"); -// qDebug("font family: %s", f.family().utf8()); - QFontDatabase fdb; - QStringList families = fdb.families(); - bool found = false; - for (int i = 0; i < families.size(); ++i) { - QString str = families.at(i); - if (str.contains('[')) - str = str.left(str.indexOf('[')-1); - if (str.toLower() == "fixed") - found = true; - } - if (!found) - QSKIP("Fixed font not available."); - QCOMPARE(QFontInfo(f).family().left(5).toLower(), QString("fixed")); -#endif -} - void tst_QFont::insertAndRemoveSubstitutions() { QFont::removeSubstitution("BogusFontFamily"); diff --git a/tests/auto/gui/text/qfontdatabase/FreeMono.ttf b/tests/auto/gui/text/qfontdatabase/FreeMono.ttf Binary files differdeleted file mode 100644 index d7ce52ddc7..0000000000 --- a/tests/auto/gui/text/qfontdatabase/FreeMono.ttf +++ /dev/null diff --git a/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF b/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF Binary files differnew file mode 100644 index 0000000000..f87ea95e0e --- /dev/null +++ b/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF diff --git a/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt b/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt new file mode 100644 index 0000000000..06a5b40313 --- /dev/null +++ b/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt @@ -0,0 +1,34 @@ +Font: LED Real (led_real.ttf) +Created By: Matthew Welch +E-Mail: daffy-duck@worldnet.att.net +Web Address: http://home.att.net/~daffy-duck + (PGP public key available here) + +LED Real, like all of my fonts, is free. You can use it for most +personal or business uses you'd like, and I ask for no money. I +would, however, like to hear from you. If you use my fonts for +something please send me a postcard or e-mail letting me know how +you used it. Send me a copy if you can or let me know where I can +find your work. + +You may use this font for graphical or printed work, but you may not +sell it or include it in a collection of fonts (on CD or otherwise) +being sold. You can redistribute this font as long as you charge +nothing to receive it. If you redistribute it include this text file +with it as is (without modifications). + +If you use this font for commercial purposes please credit me in +at least some little way. + +About the font: + +Unlike most LED/LCD style fonts mine could be recreated with an +actual LED. I created this font working from memories of the good +old Speak and Spell display. Since I don't have an actual Speak +and Spell to work from I had to just do as well as I could in its +spirit. Be warned that some characters look just like others. The +( and the <, for instance. Also C and [. Most of these will be +pretty clear in context. To see all the sections of the LED "lit +up" at once use character 127 (hold down alt and type 0127 on the +numeric keypad). This font is, of course, monospaced. + diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index fa5c81a2f0..28db0ba291 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -83,7 +83,7 @@ private: }; tst_QFontDatabase::tst_QFontDatabase() - : m_testFont(QFINDTESTDATA("FreeMono.ttf")) + : m_testFont(QFINDTESTDATA("LED_REAL.TTF")) { } diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 74802c3217..c4db669695 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -86,12 +86,13 @@ private slots: void greek_data(); void greek(); - void controlInSyllable_qtbug14204(); - void combiningMarks_qtbug15675(); - void mirroredChars_data(); void mirroredChars(); + void controlInSyllable_qtbug14204(); + void combiningMarks_qtbug15675_data(); + void combiningMarks_qtbug15675(); + void thaiIsolatedSaraAm(); void thaiWithZWJ(); void thaiMultipleVowels(); @@ -1051,87 +1052,18 @@ void tst_QTextScriptEngine::greek() doShapingTests(); } -void tst_QTextScriptEngine::controlInSyllable_qtbug14204() -{ -#if 0 && defined(Q_OS_UNIX) - // ### the test is incorrect -> disable for now - QString s; - s.append(QChar(0x0915)); - s.append(QChar(0x094d)); - s.append(QChar(0x200d)); - s.append(QChar(0x0915)); - - QTextLayout layout(s); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); - QVERIFY(e->layoutData->glyphLayout.advances[1].toInt() != 0); -#endif -} - -void tst_QTextScriptEngine::combiningMarks_qtbug15675() -{ -#if defined(Q_OS_MAC) - QString s; - s.append(QChar(0x0061)); - s.append(QChar(0x0062)); - s.append(QChar(0x0300)); - s.append(QChar(0x0063)); - - QFont font("Monaco"); - QTextLayout layout(s, font); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(4)); - QCOMPARE(e->layoutData->glyphLayout.advances[2].toInt(), 0); -#else - QFontDatabase db; - - if (!db.families().contains("DejaVu Sans Mono")) - QSKIP("Required font (DejaVu Sans Mono) doesn't exist, skip test."); - - QString s; - s.append(QChar(0x0062)); - s.append(QChar(0x0332)); - s.append(QChar(0x0063)); - - QTextLayout layout(s, QFont("DejaVu Sans Mono")); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3)); - QCOMPARE(e->layoutData->glyphLayout.advances[1].toInt(), 0); -#endif -} - void tst_QTextScriptEngine::mirroredChars_data() { - QTest::addColumn<int>("hintingPreference"); + QTest::addColumn<QString>("s"); - QTest::newRow("Default hinting") << int(QFont::PreferDefaultHinting); - QTest::newRow("No hinting") << int(QFont::PreferNoHinting); - QTest::newRow("Vertical hinting") << int(QFont::PreferVerticalHinting); - QTest::newRow("Full hinting") << int(QFont::PreferFullHinting); + QTest::newRow("()") << QStringLiteral("()"); + QTest::newRow("[]") << QStringLiteral("[]"); + QTest::newRow("{}") << QStringLiteral("{}"); } void tst_QTextScriptEngine::mirroredChars() { -#if defined(Q_OS_MAC) - QSKIP("Not supported on Mac"); -#endif - QFETCH(int, hintingPreference); - - QFont font; - font.setHintingPreference(QFont::HintingPreference(hintingPreference)); - - QString s; - s.append(QLatin1Char('(')); - s.append(QLatin1Char(')')); + QFETCH(QString, s); glyph_t leftParenthesis; glyph_t rightParenthesis; @@ -1144,10 +1076,12 @@ void tst_QTextScriptEngine::mirroredChars() QTextEngine *e = layout.engine(); e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + e->shape(0); QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); - const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout; + const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]); leftParenthesis = glyphLayout.glyphs[0]; rightParenthesis = glyphLayout.glyphs[1]; } @@ -1158,61 +1092,170 @@ void tst_QTextScriptEngine::mirroredChars() QTextEngine *e = layout.engine(); e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + e->shape(0); QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); - const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout; + const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]); QCOMPARE(glyphLayout.glyphs[0], rightParenthesis); QCOMPARE(glyphLayout.glyphs[1], leftParenthesis); } } +void tst_QTextScriptEngine::controlInSyllable_qtbug14204() +{ + QFontDatabase db; + if (!db.families().contains(QStringLiteral("Aparajita"))) + QSKIP("couldn't find 'Aparajita' font"); + + QFont font(QStringLiteral("Aparajita")); + font.setStyleStrategy(QFont::NoFontMerging); + + QString s; + s.append(QChar(0x0915)); + s.append(QChar(0x094d)); + s.append(QChar(0x200d)); + s.append(QChar(0x0915)); + + QTextLayout layout(s, font); + QTextEngine *e = layout.engine(); + e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + + QFontEngine *fe = e->fontEngine(e->layoutData->items[0]); + if (fe->type() == QFontEngine::Box) + QSKIP("OpenType support missing for script"); + QCOMPARE(fe->fontDef.family, font.family()); + + e->shape(0); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); + + const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); + QCOMPARE(log_clusters[0], ushort(0)); + QCOMPARE(log_clusters[1], ushort(0)); + QCOMPARE(log_clusters[2], ushort(0)); + QCOMPARE(log_clusters[3], ushort(0)); +} + +void tst_QTextScriptEngine::combiningMarks_qtbug15675_data() +{ + QTest::addColumn<QFont>("font"); + QTest::addColumn<QString>("string"); + + bool hasTests = false; + + QStringList families; + families << QStringLiteral("Monaco"); + families << QStringLiteral("DejaVu Sans Mono"); + + foreach (const QString &family, families) { + QFont font(family); + font.setStyleStrategy(QFont::NoFontMerging); + if (QFontInfo(font).family() != family) + continue; + + hasTests = true; + + QString s(QStringLiteral("ab cd")); + for (ushort uc = 0x0300; uc < 0x0370; ++uc) { + s[2] = QChar(uc); + QByteArray testName = family.toLatin1() + ": ab<U+" + QByteArray::number(uc, 16).rightJustified(4, '0') + ">cd"; + QTest::newRow(testName.constData()) << font << s; + } + } + + if (!hasTests) + QSKIP("Couldn't find required fonts, skip test."); +} + +void tst_QTextScriptEngine::combiningMarks_qtbug15675() +{ + QFETCH(QFont, font); + QFETCH(QString, string); + + QTextLayout layout(string, font); + QTextEngine *e = layout.engine(); + e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + + QFontEngine *fe = e->fontEngine(e->layoutData->items[0]); + if (fe->type() == QFontEngine::Box) + QSKIP("OpenType support missing for script"); + QCOMPARE(fe->fontDef.family, font.family()); + + e->shape(0); + const int diff = e->layoutData->items[0].num_glyphs - string.size(); + QVERIFY(diff >= -1 && diff <= 1); // could compose or decompose exactly one character + + const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); + QCOMPARE(log_clusters[0], ushort(0)); + QCOMPARE(log_clusters[1], ushort(1)); + QCOMPARE(log_clusters[2], ushort(1)); + QCOMPARE(log_clusters[3], ushort(3 + diff)); + QCOMPARE(log_clusters[4], ushort(4 + diff)); + + const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]); + for (int i = 0; i < glyphLayout.numGlyphs; ++i) { + if ((diff >= 0 && i == 2) || (diff > 0 && i == 2 + diff)) + QCOMPARE(glyphLayout.advances[i].toInt(), 0); + else + QVERIFY(glyphLayout.advances[i].toInt() != 0); + } +} + void tst_QTextScriptEngine::thaiIsolatedSaraAm() { - if (QFontDatabase().families(QFontDatabase::Any).contains("Waree")) { - QString s; - s.append(QChar(0x0e33)); + QFontDatabase db; + if (!db.families().contains("Waree")) + QSKIP("couldn't find 'Waree' font"); - QTextLayout layout(s, QFont("Waree")); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + QFont font(QStringLiteral("Waree")); + font.setStyleStrategy(QFont::NoFontMerging); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3)); + QString s; + s.append(QChar(0x0e33)); - unsigned short *logClusters = e->logClusters(&e->layoutData->items[0]); - QCOMPARE(logClusters[0], ushort(0)); - } else - QSKIP("Cannot find Waree."); + QTextLayout layout(s, font); + QTextEngine *e = layout.engine(); + e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + + QFontEngine *fe = e->fontEngine(e->layoutData->items[0]); + if (fe->type() == QFontEngine::Box) + QSKIP("OpenType support missing for script"); + QCOMPARE(fe->fontDef.family, font.family()); + + e->shape(0); + QVERIFY(e->layoutData->items[0].num_glyphs > 0); + + const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); + QCOMPARE(log_clusters[0], ushort(0)); } void tst_QTextScriptEngine::thaiWithZWJ() { -#ifdef Q_OS_WIN - QSKIP("This test currently fails on Windows - QTBUG-24565"); -#endif + QFontDatabase db; + if (!db.families().contains("Waree")) + QSKIP("couldn't find 'Waree' font"); + + QFont font(QStringLiteral("Waree")); + font.setStyleStrategy(QFont::NoFontMerging); + QString s(QString::fromUtf8("\xe0\xb8\xa3\xe2\x80\x8d\xe0\xb8\xa3\xe2\x80" "\x8c\x2e\xe0\xb8\xa3\x2e\xe2\x80\x9c\xe0\xb8" "\xa3\xe2\x80\xa6\xe0\xb8\xa3\xe2\x80\x9d\xe0" "\xb8\xa3\xa0\xe0\xb8\xa3\xe6\x9c\xac\xe0\xb8\xa3") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); - QTextLayout layout(s); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + QTextLayout layout(s, font); QTextEngine *e = layout.engine(); - e->width(0, s.length()); //force itemize and shape - - // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. - // The current implementation hides them, so we test for that. - // But make sure that we don't hide anything else + e->itemize(); QCOMPARE(e->layoutData->items.size(), 11); + + for (int item = 0; item < e->layoutData->items.size(); ++item) + e->shape(item); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a separate item QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character @@ -1231,15 +1274,18 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 10; i++) QCOMPARE(logClusters[i+7], ushort(0)); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23064", Abort); -#endif QCOMPARE(logClusters[17], ushort(1)); - // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 - // and 3. - for (int i = 0; i < 18; i++) - QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. + // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 and 3. + const QGlyphLayout glyphLayout = e->layoutData->glyphLayout; + for (int i = 0; i < 18; i++) { + if (i == 1 || i == 3) + QCOMPARE(glyphLayout.advances[i].toInt(), 0); + else + QVERIFY(glyphLayout.advances[i].toInt() != 0); + } } void tst_QTextScriptEngine::thaiMultipleVowels() @@ -1253,14 +1299,13 @@ void tst_QTextScriptEngine::thaiMultipleVowels() for (int i = 0; i < 10; i++) s += s; //Repeat the string to make it more likely to crash if we have a buffer overflow - QTextLayout layout(s); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + QTextLayout layout(s); QTextEngine *e = layout.engine(); - e->width(0, s.length()); //force itemize and shape + e->itemize(); + + for (int item = 0; item < e->layoutData->items.size(); ++item) + e->shape(item); // If we haven't crashed at this point, then the test has passed. } |