Windows: Don't claim bitmap fonts support all standard sizes

We were throwing away important information by claiming that all
fonts support all the standard sizes in QFontDatabase on Windows
This caused the font dialog to list unsupported sizes for bitmap
fonts, unlike the native font dialog.

We would also claim to support creating bitmap fonts at
unsupported sizes, which would lead to
1. QFontInfo(font).pointSize() would return the requested size,
not the actual rendered size.
2. Bitmap fonts created at 64 pixels and higher would be invisible.

On Mac, there are no system bitmap fonts, and the use is not very
common, but installing some bitmap fonts on the system, it does
seem to ignore the sizes supported in the font and just displays
the standard list instead, so we keep the current behavior there.

[ChangeLog][QtGui][Text] Fixed list of supported sizes for
bitmap fonts on Windows.

Task-number: QTBUG-56672
Change-Id: Idbec2db9eb3381ab5ddf6259bd2befcba9b93564
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2016-10-24 15:53:06 +02:00
parent c5f1828424
commit 95d1273548
2 changed files with 29 additions and 1 deletions

View File

@ -1583,7 +1583,7 @@ QString QWindowsFontDatabase::fontDir() const
bool QWindowsFontDatabase::fontsAlwaysScalable() const bool QWindowsFontDatabase::fontsAlwaysScalable() const
{ {
return true; return false;
} }
void QWindowsFontDatabase::derefUniqueFont(const QString &uniqueFont) void QWindowsFontDatabase::derefUniqueFont(const QString &uniqueFont)

View File

@ -67,6 +67,9 @@ private slots:
void condensedFontWidth(); void condensedFontWidth();
void condensedFontMatching(); void condensedFontMatching();
void rasterFonts();
void smoothFonts();
private: private:
QString m_ledFont; QString m_ledFont;
QString m_testFont; QString m_testFont;
@ -334,5 +337,30 @@ void tst_QFontDatabase::condensedFontMatching()
QFontMetrics(tfcBySubfamilyName).width(testString())); QFontMetrics(tfcBySubfamilyName).width(testString()));
} }
void tst_QFontDatabase::rasterFonts()
{
QFont font(QLatin1String("Fixedsys"), 1000);
QFontInfo fontInfo(font);
if (fontInfo.family() != font.family())
QSKIP("Fixedsys font not available.");
QVERIFY(!QFontDatabase().isSmoothlyScalable(font.family()));
QVERIFY(fontInfo.pointSize() != font.pointSize());
}
void tst_QFontDatabase::smoothFonts()
{
QFont font(QLatin1String("Arial"), 1000);
QFontInfo fontInfo(font);
if (fontInfo.family() != font.family())
QSKIP("Arial font not available.");
// Smooth and bitmap scaling are mutually exclusive
QVERIFY(QFontDatabase().isSmoothlyScalable(font.family()));
QVERIFY(!QFontDatabase().isBitmapScalable(font.family()));
}
QTEST_MAIN(tst_QFontDatabase) QTEST_MAIN(tst_QFontDatabase)
#include "tst_qfontdatabase.moc" #include "tst_qfontdatabase.moc"