Don't expose qt_setQtEnableTestFont(bool) by default
Build it only in -developer-build mode for tests that might depend on exact-matching font behavior. Return earlier to avoid doing any useless job. Change-Id: I966ee5689f03403e45f4c957b63e3113f0467803 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
parent
073f4f9bb2
commit
c57c89b3c1
@ -72,12 +72,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
#define SMOOTH_SCALABLE 0xffff
|
#define SMOOTH_SCALABLE 0xffff
|
||||||
|
|
||||||
|
#if defined(QT_BUILD_INTERNAL)
|
||||||
bool qt_enable_test_font = false;
|
bool qt_enable_test_font = false;
|
||||||
|
|
||||||
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value)
|
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value)
|
||||||
{
|
{
|
||||||
qt_enable_test_font = value;
|
qt_enable_test_font = value;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int getFontWeight(const QString &weightString)
|
static int getFontWeight(const QString &weightString)
|
||||||
{
|
{
|
||||||
@ -2561,6 +2563,15 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
|
|||||||
|
|
||||||
QFontEngine *engine;
|
QFontEngine *engine;
|
||||||
|
|
||||||
|
#if defined(QT_BUILD_INTERNAL)
|
||||||
|
// For testing purpose only, emulates an exact-matching monospace font
|
||||||
|
if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
|
||||||
|
engine = new QTestFontEngine(request.pixelSize);
|
||||||
|
engine->fontDef = request;
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Until we specifically asked not to, try looking for Multi font engine
|
// Until we specifically asked not to, try looking for Multi font engine
|
||||||
// first, the last '1' indicates that we want Multi font engine instead
|
// first, the last '1' indicates that we want Multi font engine instead
|
||||||
// of single ones
|
// of single ones
|
||||||
@ -2576,12 +2587,6 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
|
|||||||
|
|
||||||
parseFontName(request.family, foundry_name, family_name);
|
parseFontName(request.family, foundry_name, family_name);
|
||||||
|
|
||||||
if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
|
|
||||||
engine =new QTestFontEngine(request.pixelSize);
|
|
||||||
engine->fontDef = request;
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
QtFontDesc desc;
|
QtFontDesc desc;
|
||||||
QList<int> blackListed;
|
QList<int> blackListed;
|
||||||
int index = match(script, request, family_name, foundry_name, &desc, blackListed);
|
int index = match(script, request, family_name, foundry_name, &desc, blackListed);
|
||||||
|
@ -51,15 +51,15 @@ private slots:
|
|||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
extern void qt_setQtEnableTestFont(bool value); // qfontdatabase.cpp
|
|
||||||
|
|
||||||
#ifdef QT_BUILD_INTERNAL
|
#ifdef QT_BUILD_INTERNAL
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
// qfontdatabase.cpp
|
||||||
|
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value);
|
||||||
// qfontengine.cpp
|
// qfontengine.cpp
|
||||||
extern void QFontEngine_startCollectingEngines();
|
Q_AUTOTEST_EXPORT void QFontEngine_startCollectingEngines();
|
||||||
extern QList<QFontEngine *> QFontEngine_stopCollectingEngines();
|
Q_AUTOTEST_EXPORT QList<QFontEngine *> QFontEngine_stopCollectingEngines();
|
||||||
#endif
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
#endif
|
||||||
|
|
||||||
tst_QFontCache::tst_QFontCache()
|
tst_QFontCache::tst_QFontCache()
|
||||||
{
|
{
|
||||||
@ -79,6 +79,7 @@ void tst_QFontCache::clear()
|
|||||||
|
|
||||||
QFontEngine *fontEngine = 0;
|
QFontEngine *fontEngine = 0;
|
||||||
|
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
{
|
{
|
||||||
// we're never caching the box (and the "test") font engines
|
// we're never caching the box (and the "test") font engines
|
||||||
// let's ensure we're not leaking them as well as the cached ones
|
// let's ensure we're not leaking them as well as the cached ones
|
||||||
@ -88,6 +89,7 @@ void tst_QFontCache::clear()
|
|||||||
f.setFamily("__Qt__Box__Engine__");
|
f.setFamily("__Qt__Box__Engine__");
|
||||||
f.exactMatch(); // loads engine
|
f.exactMatch(); // loads engine
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QFontDatabase db;
|
QFontDatabase db;
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void getSetCheck();
|
void getSetCheck();
|
||||||
void lineBreaking();
|
void lineBreaking();
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void simpleBoundingRect();
|
void simpleBoundingRect();
|
||||||
void threeLineBoundingRect();
|
void threeLineBoundingRect();
|
||||||
void boundingRectWithLongLineAndNoWrap();
|
void boundingRectWithLongLineAndNoWrap();
|
||||||
@ -83,16 +84,20 @@ private slots:
|
|||||||
void horizontalAlignment();
|
void horizontalAlignment();
|
||||||
void horizontalAlignmentMultiline_data();
|
void horizontalAlignmentMultiline_data();
|
||||||
void horizontalAlignmentMultiline();
|
void horizontalAlignmentMultiline();
|
||||||
|
#endif
|
||||||
void defaultWordSeparators_data();
|
void defaultWordSeparators_data();
|
||||||
void defaultWordSeparators();
|
void defaultWordSeparators();
|
||||||
void cursorMovementFromInvalidPositions();
|
void cursorMovementFromInvalidPositions();
|
||||||
void cursorMovementInsideSpaces();
|
void cursorMovementInsideSpaces();
|
||||||
void charWordStopOnLineSeparator();
|
void charWordStopOnLineSeparator();
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void xToCursorAtEndOfLine();
|
void xToCursorAtEndOfLine();
|
||||||
|
#endif
|
||||||
void boundingRectTopLeft();
|
void boundingRectTopLeft();
|
||||||
void graphemeBoundaryForSurrogatePairs();
|
void graphemeBoundaryForSurrogatePairs();
|
||||||
void tabStops();
|
void tabStops();
|
||||||
void integerOverflow();
|
void integerOverflow();
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void testDefaultTabs();
|
void testDefaultTabs();
|
||||||
void testTabs();
|
void testTabs();
|
||||||
void testMultilineTab();
|
void testMultilineTab();
|
||||||
@ -103,6 +108,7 @@ private slots:
|
|||||||
void testMultiTab();
|
void testMultiTab();
|
||||||
void testTabDPIScale();
|
void testTabDPIScale();
|
||||||
void tabsForRtl();
|
void tabsForRtl();
|
||||||
|
#endif
|
||||||
void tabHeight();
|
void tabHeight();
|
||||||
void capitalization_allUpperCase();
|
void capitalization_allUpperCase();
|
||||||
void capitalization_allUpperCase_newline();
|
void capitalization_allUpperCase_newline();
|
||||||
@ -119,12 +125,14 @@ private slots:
|
|||||||
void layoutWithCustomTabStops();
|
void layoutWithCustomTabStops();
|
||||||
|
|
||||||
// QTextLine stuff
|
// QTextLine stuff
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
|
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
|
||||||
void setNumColumnsWordWrap();
|
void setNumColumnsWordWrap();
|
||||||
void smallTextLengthNoWrap();
|
void smallTextLengthNoWrap();
|
||||||
void smallTextLengthWordWrap();
|
void smallTextLengthWordWrap();
|
||||||
void smallTextLengthWrapAtWordBoundaryOrAnywhere();
|
void smallTextLengthWrapAtWordBoundaryOrAnywhere();
|
||||||
void testLineBreakingAllSpaces();
|
void testLineBreakingAllSpaces();
|
||||||
|
#endif
|
||||||
void lineWidthFromBOM();
|
void lineWidthFromBOM();
|
||||||
void textWidthVsWIdth();
|
void textWidthVsWIdth();
|
||||||
void textWithSurrogates_qtbug15679();
|
void textWithSurrogates_qtbug15679();
|
||||||
@ -143,7 +151,7 @@ private:
|
|||||||
void tst_QTextLayout::getSetCheck()
|
void tst_QTextLayout::getSetCheck()
|
||||||
{
|
{
|
||||||
QString str("Bogus text");
|
QString str("Bogus text");
|
||||||
QTextLayout layout(str, testFont);
|
QTextLayout layout(str);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
QTextEngine *engine = layout.engine();
|
QTextEngine *engine = layout.engine();
|
||||||
QTextInlineObject obj1(0, engine);
|
QTextInlineObject obj1(0, engine);
|
||||||
@ -177,13 +185,18 @@ void tst_QTextLayout::getSetCheck()
|
|||||||
QCOMPARE(true, obj2.cacheEnabled());
|
QCOMPARE(true, obj2.cacheEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
extern void qt_setQtEnableTestFont(bool value);
|
// qfontdatabase.cpp
|
||||||
|
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value);
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
#endif
|
||||||
|
|
||||||
tst_QTextLayout::tst_QTextLayout()
|
tst_QTextLayout::tst_QTextLayout()
|
||||||
{
|
{
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
qt_setQtEnableTestFont(true);
|
qt_setQtEnableTestFont(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
tst_QTextLayout::~tst_QTextLayout()
|
tst_QTextLayout::~tst_QTextLayout()
|
||||||
@ -193,10 +206,14 @@ tst_QTextLayout::~tst_QTextLayout()
|
|||||||
void tst_QTextLayout::init()
|
void tst_QTextLayout::init()
|
||||||
{
|
{
|
||||||
testFont = QFont();
|
testFont = QFont();
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
testFont.setFamily("__Qt__Box__Engine__");
|
testFont.setFamily("__Qt__Box__Engine__");
|
||||||
|
#endif
|
||||||
testFont.setPixelSize(TESTFONT_SIZE);
|
testFont.setPixelSize(TESTFONT_SIZE);
|
||||||
testFont.setWeight(QFont::Normal);
|
testFont.setWeight(QFont::Normal);
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
QCOMPARE(QFontMetrics(testFont).width('a'), testFont.pixelSize());
|
QCOMPARE(QFontMetrics(testFont).width('a'), testFont.pixelSize());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTextLayout::cleanup()
|
void tst_QTextLayout::cleanup()
|
||||||
@ -286,6 +303,7 @@ void tst_QTextLayout::lineBreaking()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void tst_QTextLayout::simpleBoundingRect()
|
void tst_QTextLayout::simpleBoundingRect()
|
||||||
{
|
{
|
||||||
/* just check if boundingRect() gives sane values. The text is not broken. */
|
/* just check if boundingRect() gives sane values. The text is not broken. */
|
||||||
@ -972,6 +990,7 @@ void tst_QTextLayout::horizontalAlignmentMultiline()
|
|||||||
QCOMPARE(rect.left(), lastLeft);
|
QCOMPARE(rect.left(), lastLeft);
|
||||||
QCOMPARE(rect.right(), lastRight);
|
QCOMPARE(rect.right(), lastRight);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tst_QTextLayout::defaultWordSeparators_data()
|
void tst_QTextLayout::defaultWordSeparators_data()
|
||||||
{
|
{
|
||||||
@ -1009,7 +1028,7 @@ void tst_QTextLayout::defaultWordSeparators()
|
|||||||
QFETCH(QString, text);
|
QFETCH(QString, text);
|
||||||
QFETCH(int, startPos);
|
QFETCH(int, startPos);
|
||||||
QFETCH(int, endPos);
|
QFETCH(int, endPos);
|
||||||
QTextLayout layout(text, testFont);
|
QTextLayout layout(text);
|
||||||
|
|
||||||
QCOMPARE(layout.nextCursorPosition(startPos, QTextLayout::SkipWords), endPos);
|
QCOMPARE(layout.nextCursorPosition(startPos, QTextLayout::SkipWords), endPos);
|
||||||
QCOMPARE(layout.previousCursorPosition(endPos, QTextLayout::SkipWords), startPos);
|
QCOMPARE(layout.previousCursorPosition(endPos, QTextLayout::SkipWords), startPos);
|
||||||
@ -1019,7 +1038,7 @@ void tst_QTextLayout::cursorMovementFromInvalidPositions()
|
|||||||
{
|
{
|
||||||
int badpos = 10000;
|
int badpos = 10000;
|
||||||
|
|
||||||
QTextLayout layout("ABC", testFont);
|
QTextLayout layout("ABC");
|
||||||
|
|
||||||
QCOMPARE(layout.previousCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos);
|
QCOMPARE(layout.previousCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos);
|
||||||
QCOMPARE(layout.nextCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos);
|
QCOMPARE(layout.nextCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos);
|
||||||
@ -1030,13 +1049,13 @@ void tst_QTextLayout::cursorMovementFromInvalidPositions()
|
|||||||
|
|
||||||
void tst_QTextLayout::cursorMovementInsideSpaces()
|
void tst_QTextLayout::cursorMovementInsideSpaces()
|
||||||
{
|
{
|
||||||
QTextLayout layout("ABC DEF", testFont);
|
QTextLayout layout("ABC DEF");
|
||||||
|
|
||||||
QCOMPARE(layout.previousCursorPosition(6, QTextLayout::SkipWords), 0);
|
QCOMPARE(layout.previousCursorPosition(6, QTextLayout::SkipWords), 0);
|
||||||
QCOMPARE(layout.nextCursorPosition(6, QTextLayout::SkipWords), 15);
|
QCOMPARE(layout.nextCursorPosition(6, QTextLayout::SkipWords), 15);
|
||||||
|
|
||||||
|
|
||||||
QTextLayout layout2("ABC\t\t\t\t\t\t\t\t\t\t\t\tDEF", testFont);
|
QTextLayout layout2("ABC\t\t\t\t\t\t\t\t\t\t\t\tDEF");
|
||||||
|
|
||||||
QCOMPARE(layout2.previousCursorPosition(6, QTextLayout::SkipWords), 0);
|
QCOMPARE(layout2.previousCursorPosition(6, QTextLayout::SkipWords), 0);
|
||||||
QCOMPARE(layout2.nextCursorPosition(6, QTextLayout::SkipWords), 15);
|
QCOMPARE(layout2.nextCursorPosition(6, QTextLayout::SkipWords), 15);
|
||||||
@ -1048,13 +1067,14 @@ void tst_QTextLayout::charWordStopOnLineSeparator()
|
|||||||
QString txt;
|
QString txt;
|
||||||
txt.append(lineSeparator);
|
txt.append(lineSeparator);
|
||||||
txt.append(lineSeparator);
|
txt.append(lineSeparator);
|
||||||
QTextLayout layout(txt, testFont);
|
QTextLayout layout(txt);
|
||||||
QTextEngine *engine = layout.engine();
|
QTextEngine *engine = layout.engine();
|
||||||
const QCharAttributes *attrs = engine->attributes();
|
const QCharAttributes *attrs = engine->attributes();
|
||||||
QVERIFY(attrs);
|
QVERIFY(attrs);
|
||||||
QVERIFY(attrs[1].graphemeBoundary);
|
QVERIFY(attrs[1].graphemeBoundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void tst_QTextLayout::xToCursorAtEndOfLine()
|
void tst_QTextLayout::xToCursorAtEndOfLine()
|
||||||
{
|
{
|
||||||
QString text = "FirstLine SecondLine";
|
QString text = "FirstLine SecondLine";
|
||||||
@ -1078,13 +1098,14 @@ void tst_QTextLayout::xToCursorAtEndOfLine()
|
|||||||
line = layout.lineAt(1);
|
line = layout.lineAt(1);
|
||||||
QCOMPARE(line.xToCursor(100000), 20);
|
QCOMPARE(line.xToCursor(100000), 20);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tst_QTextLayout::boundingRectTopLeft()
|
void tst_QTextLayout::boundingRectTopLeft()
|
||||||
{
|
{
|
||||||
QString text = "FirstLine\nSecondLine";
|
QString text = "FirstLine\nSecondLine";
|
||||||
text.replace('\n', QChar::LineSeparator);
|
text.replace('\n', QChar::LineSeparator);
|
||||||
|
|
||||||
QTextLayout layout(text, testFont);
|
QTextLayout layout(text);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
|
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
@ -1106,7 +1127,7 @@ void tst_QTextLayout::graphemeBoundaryForSurrogatePairs()
|
|||||||
txt.append(0xd87e);
|
txt.append(0xd87e);
|
||||||
txt.append(0xdc25);
|
txt.append(0xdc25);
|
||||||
txt.append("b");
|
txt.append("b");
|
||||||
QTextLayout layout(txt, testFont);
|
QTextLayout layout(txt);
|
||||||
QTextEngine *engine = layout.engine();
|
QTextEngine *engine = layout.engine();
|
||||||
const QCharAttributes *attrs = engine->attributes();
|
const QCharAttributes *attrs = engine->attributes();
|
||||||
QVERIFY(attrs);
|
QVERIFY(attrs);
|
||||||
@ -1119,13 +1140,13 @@ void tst_QTextLayout::graphemeBoundaryForSurrogatePairs()
|
|||||||
void tst_QTextLayout::tabStops()
|
void tst_QTextLayout::tabStops()
|
||||||
{
|
{
|
||||||
QString txt("Hello there\tworld");
|
QString txt("Hello there\tworld");
|
||||||
QTextLayout layout(txt, testFont);
|
QTextLayout layout(txt);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
QTextLine line = layout.createLine();
|
QTextLine line = layout.createLine();
|
||||||
|
|
||||||
QVERIFY(line.isValid());
|
QVERIFY(line.isValid());
|
||||||
line.setNumColumns(11);
|
line.setNumColumns(11);
|
||||||
QCOMPARE(line.textLength(), TESTFONT_SIZE);
|
QCOMPARE(line.textLength(), 12);
|
||||||
|
|
||||||
line = layout.createLine();
|
line = layout.createLine();
|
||||||
QVERIFY(line.isValid());
|
QVERIFY(line.isValid());
|
||||||
@ -1142,7 +1163,7 @@ void tst_QTextLayout::integerOverflow()
|
|||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
txt += txt;
|
txt += txt;
|
||||||
|
|
||||||
QTextLayout layout(txt, testFont);
|
QTextLayout layout(txt);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
QTextLine line = layout.createLine();
|
QTextLine line = layout.createLine();
|
||||||
|
|
||||||
@ -1155,6 +1176,7 @@ void tst_QTextLayout::integerOverflow()
|
|||||||
layout.endLayout();
|
layout.endLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void tst_QTextLayout::setNumColumnsWrapAtWordBoundaryOrAnywhere()
|
void tst_QTextLayout::setNumColumnsWrapAtWordBoundaryOrAnywhere()
|
||||||
{
|
{
|
||||||
QString txt("This is a small test text");
|
QString txt("This is a small test text");
|
||||||
@ -1695,22 +1717,23 @@ void tst_QTextLayout::testTabDPIScale()
|
|||||||
QCOMPARE(line.cursorToX(12), tabs.at(1).position * scale - TESTFONT_SIZE * 5);
|
QCOMPARE(line.cursorToX(12), tabs.at(1).position * scale - TESTFONT_SIZE * 5);
|
||||||
QCOMPARE(line.cursorToX(18), tabs.at(2).position * scale - TESTFONT_SIZE * 3 / 2.0);
|
QCOMPARE(line.cursorToX(18), tabs.at(2).position * scale - TESTFONT_SIZE * 3 / 2.0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tst_QTextLayout::tabHeight()
|
void tst_QTextLayout::tabHeight()
|
||||||
{
|
{
|
||||||
QTextLayout layout("\t", testFont);
|
QTextLayout layout("\t");
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
QTextLine line = layout.createLine();
|
QTextLine line = layout.createLine();
|
||||||
layout.endLayout();
|
layout.endLayout();
|
||||||
|
|
||||||
QCOMPARE(qRound(line.ascent()), QFontMetrics(testFont).ascent());
|
QCOMPARE(qRound(line.ascent()), QFontMetrics(layout.font()).ascent());
|
||||||
QCOMPARE(qRound(line.descent()), QFontMetrics(testFont).descent());
|
QCOMPARE(qRound(line.descent()), QFontMetrics(layout.font()).descent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTextLayout::capitalization_allUpperCase()
|
void tst_QTextLayout::capitalization_allUpperCase()
|
||||||
{
|
{
|
||||||
QFont font(testFont);
|
QFont font;
|
||||||
font.setCapitalization(QFont::AllUppercase);
|
font.setCapitalization(QFont::AllUppercase);
|
||||||
QTextLayout layout("Test", font);
|
QTextLayout layout("Test", font);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
@ -1726,7 +1749,7 @@ void tst_QTextLayout::capitalization_allUpperCase()
|
|||||||
|
|
||||||
void tst_QTextLayout::capitalization_allUpperCase_newline()
|
void tst_QTextLayout::capitalization_allUpperCase_newline()
|
||||||
{
|
{
|
||||||
QFont font(testFont);
|
QFont font;
|
||||||
font.setCapitalization(QFont::AllUppercase);
|
font.setCapitalization(QFont::AllUppercase);
|
||||||
|
|
||||||
QString tmp = "hello\nworld!";
|
QString tmp = "hello\nworld!";
|
||||||
@ -1748,7 +1771,7 @@ void tst_QTextLayout::capitalization_allUpperCase_newline()
|
|||||||
|
|
||||||
void tst_QTextLayout::capitalization_allLowerCase()
|
void tst_QTextLayout::capitalization_allLowerCase()
|
||||||
{
|
{
|
||||||
QFont font(testFont);
|
QFont font;
|
||||||
font.setCapitalization(QFont::AllLowercase);
|
font.setCapitalization(QFont::AllLowercase);
|
||||||
QTextLayout layout("Test", font);
|
QTextLayout layout("Test", font);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
@ -1764,7 +1787,7 @@ void tst_QTextLayout::capitalization_allLowerCase()
|
|||||||
|
|
||||||
void tst_QTextLayout::capitalization_smallCaps()
|
void tst_QTextLayout::capitalization_smallCaps()
|
||||||
{
|
{
|
||||||
QFont font(testFont);
|
QFont font;
|
||||||
font.setCapitalization(QFont::SmallCaps);
|
font.setCapitalization(QFont::SmallCaps);
|
||||||
QTextLayout layout("Test", font);
|
QTextLayout layout("Test", font);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
@ -1781,7 +1804,7 @@ void tst_QTextLayout::capitalization_smallCaps()
|
|||||||
|
|
||||||
void tst_QTextLayout::capitalization_capitalize()
|
void tst_QTextLayout::capitalization_capitalize()
|
||||||
{
|
{
|
||||||
QFont font(testFont);
|
QFont font;
|
||||||
font.setCapitalization(QFont::Capitalize);
|
font.setCapitalization(QFont::Capitalize);
|
||||||
QTextLayout layout("hello\tworld", font);
|
QTextLayout layout("hello\tworld", font);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
@ -1804,7 +1827,7 @@ void tst_QTextLayout::longText()
|
|||||||
QString longText(128000, 'a');
|
QString longText(128000, 'a');
|
||||||
|
|
||||||
{
|
{
|
||||||
QTextLayout layout(longText, testFont);
|
QTextLayout layout(longText);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
QTextLine line = layout.createLine();
|
QTextLine line = layout.createLine();
|
||||||
@ -1814,7 +1837,7 @@ void tst_QTextLayout::longText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int cap = QFont::MixedCase; cap < QFont::Capitalize + 1; ++cap) {
|
for (int cap = QFont::MixedCase; cap < QFont::Capitalize + 1; ++cap) {
|
||||||
QFont f(testFont);
|
QFont f;
|
||||||
f.setCapitalization(QFont::Capitalization(cap));
|
f.setCapitalization(QFont::Capitalization(cap));
|
||||||
QTextLayout layout(longText, f);
|
QTextLayout layout(longText, f);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
@ -1826,7 +1849,7 @@ void tst_QTextLayout::longText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QTextLayout layout(longText, testFont);
|
QTextLayout layout(longText);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
layout.setFlags(Qt::TextForceLeftToRight);
|
layout.setFlags(Qt::TextForceLeftToRight);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
@ -1837,7 +1860,7 @@ void tst_QTextLayout::longText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QTextLayout layout(longText, testFont);
|
QTextLayout layout(longText);
|
||||||
layout.setCacheEnabled(true);
|
layout.setCacheEnabled(true);
|
||||||
layout.setFlags(Qt::TextForceRightToLeft);
|
layout.setFlags(Qt::TextForceRightToLeft);
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
@ -1850,7 +1873,8 @@ void tst_QTextLayout::longText()
|
|||||||
|
|
||||||
void tst_QTextLayout::widthOfTabs()
|
void tst_QTextLayout::widthOfTabs()
|
||||||
{
|
{
|
||||||
QTextEngine engine("ddd\t\t", testFont);
|
QTextEngine engine;
|
||||||
|
engine.text = "ddd\t\t";
|
||||||
engine.ignoreBidi = true;
|
engine.ignoreBidi = true;
|
||||||
engine.itemize();
|
engine.itemize();
|
||||||
QCOMPARE(qRound(engine.width(0, 5)), qRound(engine.boundingBox(0, 5).width));
|
QCOMPARE(qRound(engine.width(0, 5)), qRound(engine.boundingBox(0, 5).width));
|
||||||
@ -2078,7 +2102,7 @@ void tst_QTextLayout::cursorInNonStopChars()
|
|||||||
|
|
||||||
void tst_QTextLayout::justifyTrailingSpaces()
|
void tst_QTextLayout::justifyTrailingSpaces()
|
||||||
{
|
{
|
||||||
QTextLayout layout(QStringLiteral(" t"), testFont);
|
QTextLayout layout(QStringLiteral(" t"));
|
||||||
layout.setTextOption(QTextOption(Qt::AlignJustify));
|
layout.setTextOption(QTextOption(Qt::AlignJustify));
|
||||||
layout.beginLayout();
|
layout.beginLayout();
|
||||||
|
|
||||||
|
@ -1907,9 +1907,12 @@ void tst_QTextEdit::setText()
|
|||||||
QCOMPARE(browser.toPlainText(), QLatin1String("with space"));
|
QCOMPARE(browser.toPlainText(), QLatin1String("with space"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QT_BUILD_INTERNAL
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
extern void qt_setQtEnableTestFont(bool value);
|
// qfontdatabase.cpp
|
||||||
|
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value);
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef QT_BUILD_INTERNAL
|
#ifdef QT_BUILD_INTERNAL
|
||||||
void tst_QTextEdit::fullWidthSelection_data()
|
void tst_QTextEdit::fullWidthSelection_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user