diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-08-26 04:09:09 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-22 00:47:40 +0200 |
commit | ceb9a8232ca0fe9bc823b61ee3ca8bcdc0aa01c5 (patch) | |
tree | d088f6fa8e4025b75ddd034240c74fb987fd7ebe /tests/auto/gui | |
parent | ed5fe1b95e818101d00e9415d8881ac836c505eb (diff) |
A step out from Harfbuzz (reduce dependency)
Introduce QCharAttributes and use it instead of HB_CharAttributes everywhere in Qt
(in Harfbuzz, the HB_CharAttributes is only used in the text segmentation algorithm
which has been moved from HB to Qt (well, most of it)).
Rename some members to better reflect their meaning,
remember to keep HB_CharAttributes in sync with QCharAttributes.
Also replace HB_ScriptItem with a (temporary) QUnicodeTools::ScriptItem struct
that will be replaced with a more efficient/friendly solution a bit later.
The soft hyphen and the mandatory break detection has been factored out
of the default text breaking algorithm to a higher level in order to refactor
the QCharAttributes bitfields and to optimize the implementation for the common case.
Change-Id: Ieb365623ae954430f1c8b2dfcd65c82973143eec
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 1190736357..6b5edc53eb 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -97,7 +97,7 @@ private slots: void charWordStopOnLineSeparator(); void xToCursorAtEndOfLine(); void boundingRectTopLeft(); - void charStopForSurrogatePairs(); + void graphemeBoundaryForSurrogatePairs(); void tabStops(); void integerOverflow(); void testDefaultTabs(); @@ -274,14 +274,14 @@ void tst_QTextLayout::lineBreaking() while (b->utf8) { QString str = QString::fromUtf8(b->utf8); QTextEngine engine(str, QFont()); - const HB_CharAttributes *attrs = engine.attributes(); - QVERIFY(attrs[0].lineBreakType == HB_NoBreak); + const QCharAttributes *attrs = engine.attributes(); + QVERIFY(!attrs[0].lineBreak); int i; for (i = 0; i < (int)str.length() - 1; ++i) { QVERIFY(b->breaks[i] != 0xff); - if ( (attrs[i + 1].lineBreakType != HB_NoBreak) != (bool)b->breaks[i] ) { - qDebug("test case \"%s\" failed at char %d; break type: %d", b->utf8, i, attrs[i + 1].lineBreakType); - QCOMPARE( (attrs[i + 1].lineBreakType != HB_NoBreak), (bool)b->breaks[i] ); + if ( attrs[i + 1].lineBreak != (bool)b->breaks[i] ) { + qDebug("test case \"%s\" failed at char %d; break type: %d", b->utf8, i, attrs[i + 1].lineBreak); + QCOMPARE( attrs[i + 1].lineBreak, (bool)b->breaks[i] ); } } QCOMPARE(b->breaks[i], (uchar)0xff); @@ -1041,9 +1041,9 @@ void tst_QTextLayout::charWordStopOnLineSeparator() txt.append(lineSeparator); QTextLayout layout(txt, testFont); QTextEngine *engine = layout.engine(); - const HB_CharAttributes *attrs = engine->attributes(); + const QCharAttributes *attrs = engine->attributes(); QVERIFY(attrs); - QVERIFY(attrs[1].charStop); + QVERIFY(attrs[1].graphemeBoundary); } void tst_QTextLayout::xToCursorAtEndOfLine() @@ -1093,7 +1093,7 @@ void tst_QTextLayout::boundingRectTopLeft() QCOMPARE(layout.boundingRect().topLeft(), firstLine.position()); } -void tst_QTextLayout::charStopForSurrogatePairs() +void tst_QTextLayout::graphemeBoundaryForSurrogatePairs() { QString txt; txt.append("a"); @@ -1102,12 +1102,12 @@ void tst_QTextLayout::charStopForSurrogatePairs() txt.append("b"); QTextLayout layout(txt, testFont); QTextEngine *engine = layout.engine(); - const HB_CharAttributes *attrs = engine->attributes(); + const QCharAttributes *attrs = engine->attributes(); QVERIFY(attrs); - QVERIFY(attrs[0].charStop); - QVERIFY(attrs[1].charStop); - QVERIFY(!attrs[2].charStop); - QVERIFY(attrs[3].charStop); + QVERIFY(attrs[0].graphemeBoundary); + QVERIFY(attrs[1].graphemeBoundary); + QVERIFY(!attrs[2].graphemeBoundary); + QVERIFY(attrs[3].graphemeBoundary); } void tst_QTextLayout::tabStops() |