Fix capitalization with newline bug
We only want to change the capitalization if the QScriptAnalysis flag was Lowercase, Uppercase or SmallCaps. Task-number: QTBUG-17485 Change-Id: Icbecb09b06a9153866ae81d592b3f6779c2dafb5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
f9c73f0785
commit
2ff6086e06
@ -110,7 +110,7 @@ private:
|
||||
QScriptItemArray::Iterator iter = m_items.end();
|
||||
do {
|
||||
iter--;
|
||||
if (iter->analysis.flags < QScriptAnalysis::TabOrObject)
|
||||
if (iter->analysis.flags < QScriptAnalysis::LineOrParagraphSeparator)
|
||||
iter->analysis.flags = flags;
|
||||
} while (iter->position > start);
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ private slots:
|
||||
void tabsForRtl();
|
||||
void tabHeight();
|
||||
void capitalization_allUpperCase();
|
||||
void capitalization_allUpperCase_newline();
|
||||
void capitalization_allLowerCase();
|
||||
void capitalization_smallCaps();
|
||||
void capitalization_capitalize();
|
||||
@ -1670,6 +1671,28 @@ void tst_QTextLayout::capitalization_allUpperCase()
|
||||
QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase);
|
||||
}
|
||||
|
||||
void tst_QTextLayout::capitalization_allUpperCase_newline()
|
||||
{
|
||||
QFont font(testFont);
|
||||
font.setCapitalization(QFont::AllUppercase);
|
||||
|
||||
QString tmp = "hello\nworld!";
|
||||
tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
||||
|
||||
QTextLayout layout(tmp, font);
|
||||
layout.setCacheEnabled(true);
|
||||
layout.beginLayout();
|
||||
layout.createLine();
|
||||
layout.endLayout();
|
||||
|
||||
QTextEngine *engine = layout.engine();
|
||||
engine->itemize();
|
||||
QCOMPARE(engine->layoutData->items.count(), 3);
|
||||
QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase);
|
||||
QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::LineOrParagraphSeparator);
|
||||
QVERIFY(engine->layoutData->items.at(2).analysis.flags == QScriptAnalysis::Uppercase);
|
||||
}
|
||||
|
||||
void tst_QTextLayout::capitalization_allLowerCase()
|
||||
{
|
||||
QFont font(testFont);
|
||||
|
Loading…
Reference in New Issue
Block a user