Make pixel size a qreal in QRawFont
The pixel size in the font engines is already a floating point value. For maximum flexibility, we should expose this in the public API. Task-number: QTBUG-18817 Reviewed-by: Jiang Jiang (cherry picked from commit ac9e63b58533a3215106ed9da82cff3a3e3dda3a)
This commit is contained in:
parent
f26c4ba80d
commit
ac4af55972
@ -308,10 +308,10 @@ qreal QRawFont::descent() const
|
||||
|
||||
\sa setPixelSize()
|
||||
*/
|
||||
int QRawFont::pixelSize() const
|
||||
qreal QRawFont::pixelSize() const
|
||||
{
|
||||
if (!isValid())
|
||||
return -1;
|
||||
return 0.0;
|
||||
|
||||
return d->fontEngine->fontDef.pixelSize;
|
||||
}
|
||||
@ -577,7 +577,7 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
|
||||
/*!
|
||||
Sets the pixel size with which this font should be rendered to \a pixelSize.
|
||||
*/
|
||||
void QRawFont::setPixelSize(int pixelSize)
|
||||
void QRawFont::setPixelSize(qreal pixelSize)
|
||||
{
|
||||
if (d->fontEngine == 0)
|
||||
return;
|
||||
|
@ -96,8 +96,8 @@ public:
|
||||
const QTransform &transform = QTransform()) const;
|
||||
QPainterPath pathForGlyph(quint32 glyphIndex) const;
|
||||
|
||||
void setPixelSize(int pixelSize);
|
||||
int pixelSize() const;
|
||||
void setPixelSize(qreal pixelSize);
|
||||
qreal pixelSize() const;
|
||||
|
||||
QFont::HintingPreference hintingPreference() const;
|
||||
|
||||
|
@ -104,7 +104,7 @@ void tst_QRawFont::invalidRawFont()
|
||||
{
|
||||
QRawFont font;
|
||||
QVERIFY(!font.isValid());
|
||||
QCOMPARE(font.pixelSize(), -1);
|
||||
QCOMPARE(font.pixelSize(), 0.0);
|
||||
QVERIFY(font.familyName().isEmpty());
|
||||
QCOMPARE(font.style(), QFont::StyleNormal);
|
||||
QCOMPARE(font.weight(), -1);
|
||||
@ -165,7 +165,7 @@ void tst_QRawFont::correctFontData_data()
|
||||
QTest::addColumn<QFont::Weight>("weight");
|
||||
QTest::addColumn<QFont::HintingPreference>("hintingPreference");
|
||||
QTest::addColumn<qreal>("unitsPerEm");
|
||||
QTest::addColumn<int>("pixelSize");
|
||||
QTest::addColumn<qreal>("pixelSize");
|
||||
|
||||
int hintingPreferences[] = {
|
||||
int(QFont::PreferDefaultHinting),
|
||||
@ -189,7 +189,7 @@ void tst_QRawFont::correctFontData_data()
|
||||
<< QFont::Normal
|
||||
<< QFont::HintingPreference(*hintingPreference)
|
||||
<< 1000.0
|
||||
<< 10;
|
||||
<< 10.0;
|
||||
|
||||
fileName = QLatin1String(SRCDIR "testfont_bold_italic.ttf");
|
||||
title = fileName
|
||||
@ -203,7 +203,7 @@ void tst_QRawFont::correctFontData_data()
|
||||
<< QFont::Bold
|
||||
<< QFont::HintingPreference(*hintingPreference)
|
||||
<< 1000.0
|
||||
<< 10;
|
||||
<< 10.0;
|
||||
|
||||
++hintingPreference;
|
||||
}
|
||||
@ -217,7 +217,7 @@ void tst_QRawFont::correctFontData()
|
||||
QFETCH(QFont::Weight, weight);
|
||||
QFETCH(QFont::HintingPreference, hintingPreference);
|
||||
QFETCH(qreal, unitsPerEm);
|
||||
QFETCH(int, pixelSize);
|
||||
QFETCH(qreal, pixelSize);
|
||||
|
||||
QRawFont font(fileName, 10, hintingPreference);
|
||||
QVERIFY(font.isValid());
|
||||
@ -284,7 +284,7 @@ void tst_QRawFont::textLayout()
|
||||
|
||||
QString familyName = QString::fromLatin1("QtBidiTestFont");
|
||||
QFont font(familyName);
|
||||
font.setPixelSize(18);
|
||||
font.setPixelSize(18.0);
|
||||
QCOMPARE(QFontInfo(font).family(), familyName);
|
||||
|
||||
QTextLayout layout(QLatin1String("Foobar"));
|
||||
@ -301,7 +301,7 @@ void tst_QRawFont::textLayout()
|
||||
QRawFont rawFont = glyphs.font();
|
||||
QVERIFY(rawFont.isValid());
|
||||
QCOMPARE(rawFont.familyName(), familyName);
|
||||
QCOMPARE(rawFont.pixelSize(), 18);
|
||||
QCOMPARE(rawFont.pixelSize(), 18.0);
|
||||
|
||||
QVector<quint32> expectedGlyphIndices;
|
||||
expectedGlyphIndices << 44 << 83 << 83 << 70 << 69 << 86;
|
||||
@ -597,12 +597,12 @@ void tst_QRawFont::fromFont()
|
||||
|
||||
QFont font(familyName);
|
||||
font.setHintingPreference(hintingPreference);
|
||||
font.setPixelSize(26);
|
||||
font.setPixelSize(26.0);
|
||||
|
||||
QRawFont rawFont = QRawFont::fromFont(font, writingSystem);
|
||||
QVERIFY(rawFont.isValid());
|
||||
QCOMPARE(rawFont.familyName(), familyName);
|
||||
QCOMPARE(rawFont.pixelSize(), 26);
|
||||
QCOMPARE(rawFont.pixelSize(), 26.0);
|
||||
|
||||
QVERIFY(fontDatabase.removeApplicationFont(id));
|
||||
}
|
||||
@ -623,7 +623,7 @@ void tst_QRawFont::copyConstructor()
|
||||
|
||||
{
|
||||
QString rawFontFamilyName;
|
||||
int rawFontPixelSize;
|
||||
qreal rawFontPixelSize;
|
||||
qreal rawFontAscent;
|
||||
qreal rawFontDescent;
|
||||
int rawFontTableSize;
|
||||
@ -691,7 +691,7 @@ void tst_QRawFont::detach()
|
||||
|
||||
{
|
||||
QString rawFontFamilyName;
|
||||
int rawFontPixelSize;
|
||||
qreal rawFontPixelSize;
|
||||
qreal rawFontAscent;
|
||||
qreal rawFontDescent;
|
||||
int rawFontTableSize;
|
||||
@ -773,15 +773,15 @@ void tst_QRawFont::unsupportedWritingSystem()
|
||||
|
||||
QFont font("QtBidiTestFont");
|
||||
font.setHintingPreference(hintingPreference);
|
||||
font.setPixelSize(12);
|
||||
font.setPixelSize(12.0);
|
||||
|
||||
QRawFont rawFont = QRawFont::fromFont(font, QFontDatabase::Any);
|
||||
QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
|
||||
QCOMPARE(rawFont.pixelSize(), 12);
|
||||
QCOMPARE(rawFont.pixelSize(), 12.0);
|
||||
|
||||
rawFont = QRawFont::fromFont(font, QFontDatabase::Hebrew);
|
||||
QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
|
||||
QCOMPARE(rawFont.pixelSize(), 12);
|
||||
QCOMPARE(rawFont.pixelSize(), 12.0);
|
||||
|
||||
QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic);
|
||||
|
||||
@ -798,11 +798,11 @@ void tst_QRawFont::unsupportedWritingSystem()
|
||||
QGlyphs glyphs = glyphss.at(0);
|
||||
QRawFont layoutFont = glyphs.font();
|
||||
QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont"));
|
||||
QCOMPARE(layoutFont.pixelSize(), 12);
|
||||
QCOMPARE(layoutFont.pixelSize(), 12.0);
|
||||
|
||||
rawFont = QRawFont::fromFont(font, QFontDatabase::Arabic);
|
||||
QCOMPARE(rawFont.familyName(), layoutFont.familyName());
|
||||
QCOMPARE(rawFont.pixelSize(), 12);
|
||||
QCOMPARE(rawFont.pixelSize(), 12.0);
|
||||
|
||||
fontDatabase.removeApplicationFont(id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user