QFont::exactMatch() should return false for aliases

This is a partial revert of 992f233c in Qt 4 repo. The rest of the
change cannot be reverted, since it added public API, but that
API might be useful anyway.

The patch was wrong, basically. QFont::exactMatch() should not claim
that you can get an exact match for a typeface alias. It also introduced
some weird inconsistencies: For instance, if the first font the alias
resolved to in FontConfig did not exist, then exactMatch() would return
false, even if it then resolved to the next one which existed. This
caused a test failure on OpenSuse, where the preferred font for "sans"
is Arial, which doesn't exist, so Roboto will be used instead.

[ChangeLog][QtGui][Important Behavior Changes] QFont::exactMatch() now
returns false when the provided typeface is an alias.

Task-number: QTBUG-46054
Change-Id: I7532d2879b492544620aa0d1d87dd493a4923af9
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
bb10
Eskil Abrahamsen Blomfeldt 2016-05-11 15:10:50 +03:00
parent 9ef59b586d
commit 78eeb6b066
2 changed files with 4 additions and 10 deletions

View File

@ -118,9 +118,6 @@ bool QFontDef::exactMatch(const QFontDef &other) const
QFontDatabase::parseFontName(family, this_foundry, this_family);
QFontDatabase::parseFontName(other.family, other_foundry, other_family);
this_family = QFontDatabase::resolveFontFamilyAlias(this_family);
other_family = QFontDatabase::resolveFontFamilyAlias(other_family);
return (styleHint == other.styleHint
&& styleStrategy == other.styleStrategy
&& weight == other.weight

View File

@ -115,13 +115,10 @@ void tst_QFont::exactMatch()
QSKIP("Exact matching on windows misses a lot because of the sample chars");
#endif
if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) {
QVERIFY(QFont("sans").exactMatch());
QVERIFY(QFont("sans-serif").exactMatch());
QVERIFY(QFont("serif").exactMatch());
QVERIFY(QFont("monospace").exactMatch());
}
QVERIFY(!QFont("sans").exactMatch());
QVERIFY(!QFont("sans-serif").exactMatch());
QVERIFY(!QFont("serif").exactMatch());
QVERIFY(!QFont("monospace").exactMatch());
QSKIP("This test is bogus on Unix with support for font aliases in fontconfig");