From ef77c16cb00ef3788e58da8b35cb91eaf2eaa591 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 10 Apr 2014 13:50:01 +0300 Subject: Make HarfBuzz-NG the default shaper on Mac For AAT shaping support, we need either the pre-QPA shaping trick or the new HarfBuzz on Mac; prefer the latter. Disable some test cases aimed to test the HB-old behavior; enable ones that should guarantee shaping-unaware behavior. [ChangeLog][OS X] Use CoreText text shaping engine for support of complex scripts. If required, the shaping engine used in previous versions can be preferred by configuring Qt with -no-harfbuzz. Alternatively, the QT_HARFBUZZ environment variable could be set to "old". Task-number: QTBUG-18980 (relates) Task-number: QTBUG-38246 Change-Id: Iee6fe4f5bc047e77259182b8585385c5febd02b3 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 44 +++++++--------------- .../qtextscriptengine/tst_qtextscriptengine.cpp | 16 ++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 56d6711dc6..d0482d77e2 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -309,9 +309,6 @@ void tst_QTextLayout::simpleBoundingRect() void tst_QTextLayout::threeLineBoundingRect() { -#if defined(Q_OS_MAC) - QSKIP("QTestFontEngine on the mac does not support logclusters at the moment"); -#endif /* stricter check. break text into three lines */ QString firstWord("hello"); @@ -430,9 +427,6 @@ void tst_QTextLayout::forcedBreaks() void tst_QTextLayout::breakAny() { -#if defined(Q_OS_MAC) - QSKIP("QTestFontEngine on the mac does not support logclusters at the moment"); -#endif QString text = "ABCD"; QTextLayout layout(text, testFont); @@ -473,9 +467,6 @@ void tst_QTextLayout::breakAny() void tst_QTextLayout::noWrap() { -#if defined(Q_OS_MAC) - QSKIP("QTestFontEngine on the mac does not support logclusters at the moment"); -#endif QString text = "AB CD"; QTextLayout layout(text, testFont); @@ -1048,9 +1039,6 @@ void tst_QTextLayout::charWordStopOnLineSeparator() void tst_QTextLayout::xToCursorAtEndOfLine() { -#if defined(Q_OS_MAC) - QSKIP("QTestFontEngine on the mac does not support logclusters at the moment"); -#endif QString text = "FirstLine SecondLine"; text.replace('\n', QChar::LineSeparator); @@ -1112,9 +1100,6 @@ void tst_QTextLayout::graphemeBoundaryForSurrogatePairs() void tst_QTextLayout::tabStops() { -#if defined(Q_OS_MAC) - QSKIP("QTestFontEngine on the mac does not support logclusters at the moment"); -#endif QString txt("Hello there\tworld"); QTextLayout layout(txt, testFont); layout.beginLayout(); @@ -1931,13 +1916,16 @@ void tst_QTextLayout::textWithSurrogates_qtbug15679() void tst_QTextLayout::textWidthWithStackedTextEngine() { QString text = QString::fromUtf8("คลิก ถัดไป เพื่อดำเนินการต่อ"); + QTextLayout layout(text); layout.setCacheEnabled(true); layout.beginLayout(); QTextLine line = layout.createLine(); layout.endLayout(); - QFontMetricsF fm(layout.font()); - QCOMPARE(line.naturalTextWidth(), fm.width(text)); + + QStackTextEngine layout2(text, layout.font()); + + QVERIFY(layout2.width(0, text.size()).toReal() >= line.naturalTextWidth()); } void tst_QTextLayout::textWidthWithLineSeparator() @@ -1958,27 +1946,24 @@ void tst_QTextLayout::textWidthWithLineSeparator() void tst_QTextLayout::cursorInLigatureWithMultipleLines() { -#if !defined(Q_OS_MAC) - QSKIP("This test can only be run on Mac"); -#endif QTextLayout layout("first line finish", QFont("Times", 20)); layout.setCacheEnabled(true); layout.beginLayout(); QTextLine line = layout.createLine(); - line.setLineWidth(70); - line = layout.createLine(); + line.setNumColumns(10); + QTextLine line2 = layout.createLine(); layout.endLayout(); - // The second line will be "finish", with "fi" as a ligature - QEXPECT_FAIL("", "QTBUG-26403", Abort); - QVERIFY(line.cursorToX(0) != line.cursorToX(1)); + // The second line will be "finish" + QCOMPARE(layout.text().mid(line2.textStart(), line2.textLength()), QString::fromLatin1("finish")); + + QVERIFY(line.cursorToX(1) != line.cursorToX(0)); + QCOMPARE(line2.cursorToX(line2.textStart()), line.cursorToX(0)); + QCOMPARE(line2.cursorToX(line2.textStart() + 1), line.cursorToX(1)); } void tst_QTextLayout::xToCursorForLigatures() { -#if !defined(Q_OS_MAC) - QSKIP("This test can only be run on Mac"); -#endif QTextLayout layout("fi", QFont("Times", 20)); layout.setCacheEnabled(true); layout.beginLayout(); @@ -2001,9 +1986,6 @@ void tst_QTextLayout::xToCursorForLigatures() void tst_QTextLayout::cursorInNonStopChars() { -#if defined(Q_OS_MAC) - QSKIP("This test can not be run on Mac"); -#endif QTextLayout layout(QString::fromUtf8("\xE0\xA4\xA4\xE0\xA5\x8D\xE0\xA4\xA8")); layout.setCacheEnabled(true); layout.beginLayout(); diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index c4db669695..5dfb025510 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1105,6 +1105,9 @@ void tst_QTextScriptEngine::mirroredChars() void tst_QTextScriptEngine::controlInSyllable_qtbug14204() { +#ifdef Q_OS_MAC + QSKIP("Result differs for HarfBuzz-NG, skip test."); +#endif QFontDatabase db; if (!db.families().contains(QStringLiteral("Aparajita"))) QSKIP("couldn't find 'Aparajita' font"); @@ -1143,6 +1146,10 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675_data() QTest::addColumn("font"); QTest::addColumn("string"); +#ifdef Q_OS_MAC + QSKIP("Result differs for HarfBuzz-NG, skip test."); +#endif + bool hasTests = false; QStringList families; @@ -1274,13 +1281,22 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 10; i++) QCOMPARE(logClusters[i+7], ushort(0)); +#ifndef Q_OS_MAC + // ### Result differs for HarfBuzz-NG QCOMPARE(logClusters[17], ushort(1)); +#endif // 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++) { +#ifdef Q_OS_MAC + // ### Result differs for HarfBuzz-NG + if (i == 17) + QCOMPARE(glyphLayout.advances[i].toInt(), 0); + else +#endif if (i == 1 || i == 3) QCOMPARE(glyphLayout.advances[i].toInt(), 0); else -- cgit v1.2.3 From 0ec07b68ad34e135451dd5291732bf73d297ba0c Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 10 Apr 2014 13:50:53 +0300 Subject: Improve the Unicode script itemization implementation Make it closer to the Unicode specs (UAX#24): * Common now inherits the preceding character's script, if any; * In a combining character sequence, if the base character is of Common script, the entire sequence is treated like if it were of the first non-Inherited, non-Common script in the sequence. See http://www.unicode.org/reports/tr24/tr24-21.html for more details. [ChangeLog][QtGui] Fixed regression in arabic text rendering. Task-number: QTBUG-28813 Task-number: QTBUG-29930 (related) Task-number: QTBUG-35836 Change-Id: Id85761965b08ca94c674d5f3613fe58b82b2ce9c Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Ahmed Saidi --- .../qtextscriptengine/tst_qtextscriptengine.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 5dfb025510..74eb58670b 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1258,29 +1258,21 @@ void tst_QTextScriptEngine::thaiWithZWJ() QTextLayout layout(s, font); QTextEngine *e = layout.engine(); e->itemize(); - QCOMPARE(e->layoutData->items.size(), 11); + QCOMPARE(e->layoutData->items.size(), 3); 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 - QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis - QCOMPARE(e->layoutData->items[4].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[5].num_glyphs, ushort(1)); // Common: Smart quote - QCOMPARE(e->layoutData->items[6].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[7].num_glyphs, ushort(1)); // Common: \xA0 = non-breaking space. Could be useful to have in thai, but not currently implemented - QCOMPARE(e->layoutData->items[8].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[9].num_glyphs, ushort(1)); // Japanese: Kanji for tree - QCOMPARE(e->layoutData->items[10].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(15)); // 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)); // Han: Kanji for tree + QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type //A quick sanity check - check all the characters are individual clusters unsigned short *logClusters = e->layoutData->logClustersPtr; - for (int i = 0; i < 7; i++) + for (int i = 0; i <= 14; i++) QCOMPARE(logClusters[i], ushort(i)); - for (int i = 0; i < 10; i++) - QCOMPARE(logClusters[i+7], ushort(0)); + QCOMPARE(logClusters[15], ushort(0)); + QCOMPARE(logClusters[16], ushort(0)); #ifndef Q_OS_MAC // ### Result differs for HarfBuzz-NG QCOMPARE(logClusters[17], ushort(1)); -- cgit v1.2.3 From 4dbef58c3d2a63f59c5ae32ba9dc47a2a9157474 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 15 Apr 2014 18:14:08 +0200 Subject: Restore Qt 4 behavior in default double click handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert 3bb902495291c50a2f06e8e03a62a647db3e5cd4. That fix was an attempt to handle the issue that has been fixed in 5.3 by 9063edef796ad10eb9ac2229627f36d60168f0e2 and should have been reverted when the new approach, that restores Qt 4 behavior for widgets, was introduced. Task-number: QTBUG-38242 Task-number: QTBUG-36423 Change-Id: I8f8a82da22605fac90543492e9b2cd2b568544e7 Reviewed-by: Jørgen Lind Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp | 6 ++++-- tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp index 345b8d82ad..06dd623368 100644 --- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp @@ -679,7 +679,8 @@ void tst_QTabBar::tabBarClicked() QCOMPARE(doubleClickSpy.count(), 0); QTest::mouseDClick(&tabBar, button, 0, tabPos); - QCOMPARE(clickSpy.count(), 0); + QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0); QCOMPARE(doubleClickSpy.count(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), 0); @@ -691,7 +692,8 @@ void tst_QTabBar::tabBarClicked() QCOMPARE(doubleClickSpy.count(), 0); QTest::mouseDClick(&tabBar, button, 0, barPos); - QCOMPARE(clickSpy.count(), 0); + QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1); QCOMPARE(doubleClickSpy.count(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), -1); diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index df11ea9b14..90af617e87 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -690,7 +690,8 @@ void tst_QTabWidget::tabBarClicked() QCOMPARE(doubleClickSpy.count(), 0); QTest::mouseDClick(&tabBar, button, 0, tabPos); - QCOMPARE(clickSpy.count(), 0); + QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0); QCOMPARE(doubleClickSpy.count(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), 0); @@ -702,7 +703,8 @@ void tst_QTabWidget::tabBarClicked() QCOMPARE(doubleClickSpy.count(), 0); QTest::mouseDClick(&tabBar, button, 0, barPos); - QCOMPARE(clickSpy.count(), 0); + QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1); QCOMPARE(doubleClickSpy.count(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), -1); -- cgit v1.2.3