Fix QRawFont::setPixelSize() on Mac
When refactoring the setPixelSize() code of QRawFont, it was broken on Mac. To avoid making the same mistake again, I've added a simple autotest to check that the pixel size is actually set. Reviewed-by: Jiang Jiang (cherry picked from commit 821b8b540af491ce60d35bd84d3c91399ecc0d16)
This commit is contained in:
parent
61e6639c82
commit
4135b6b323
@ -871,7 +871,7 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
|
|||||||
newFontDef.pixelSize = pixelSize;
|
newFontDef.pixelSize = pixelSize;
|
||||||
newFontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi();
|
newFontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi();
|
||||||
|
|
||||||
return new QCoreTextFontEngine(cgFont, fontDef);
|
return new QCoreTextFontEngine(cgFont, newFontDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -91,6 +91,9 @@ private slots:
|
|||||||
|
|
||||||
void unsupportedWritingSystem_data();
|
void unsupportedWritingSystem_data();
|
||||||
void unsupportedWritingSystem();
|
void unsupportedWritingSystem();
|
||||||
|
|
||||||
|
void rawFontSetPixelSize_data();
|
||||||
|
void rawFontSetPixelSize();
|
||||||
#endif // QT_NO_RAWFONT
|
#endif // QT_NO_RAWFONT
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -807,6 +810,39 @@ void tst_QRawFont::unsupportedWritingSystem()
|
|||||||
fontDatabase.removeApplicationFont(id);
|
fontDatabase.removeApplicationFont(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QRawFont::rawFontSetPixelSize_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QFont::HintingPreference>("hintingPreference");
|
||||||
|
|
||||||
|
QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
|
||||||
|
QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
|
||||||
|
QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
|
||||||
|
QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QRawFont::rawFontSetPixelSize()
|
||||||
|
{
|
||||||
|
QFETCH(QFont::HintingPreference, hintingPreference);
|
||||||
|
|
||||||
|
QTextLayout layout("Foobar");
|
||||||
|
|
||||||
|
QFont font = layout.font();
|
||||||
|
font.setHintingPreference(hintingPreference);
|
||||||
|
font.setPixelSize(12);
|
||||||
|
layout.setFont(font);
|
||||||
|
|
||||||
|
layout.beginLayout();
|
||||||
|
layout.createLine();
|
||||||
|
layout.endLayout();
|
||||||
|
|
||||||
|
QGlyphs glyphs = layout.glyphs().at(0);
|
||||||
|
QRawFont rawFont = glyphs.font();
|
||||||
|
QCOMPARE(rawFont.pixelSize(), 12.0);
|
||||||
|
|
||||||
|
rawFont.setPixelSize(24);
|
||||||
|
QCOMPARE(rawFont.pixelSize(), 24.0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QT_NO_RAWFONT
|
#endif // QT_NO_RAWFONT
|
||||||
|
|
||||||
QTEST_MAIN(tst_QRawFont)
|
QTEST_MAIN(tst_QRawFont)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user