Remove hardcoded font names in QFont::defaultFamily()
QFont::defaultFamily() should not use any hardcoded font names like "Helvetica" or "Times" as they might not be present in certain systems, it should rather use abstract names like "sans-serif", "serif" and "monospace" then let the platform plugin to decide which font map to them. Change-Id: I5aafb103a5238c17b10773711ad504806c6fc3ce Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
7f18dbc30c
commit
2cc5442b02
@ -77,28 +77,29 @@ QString QFont::defaultFamily() const
|
|||||||
{
|
{
|
||||||
QString familyName;
|
QString familyName;
|
||||||
switch(d->request.styleHint) {
|
switch(d->request.styleHint) {
|
||||||
case QFont::Times:
|
case QFont::SansSerif:
|
||||||
familyName = QString::fromLatin1("Times");
|
familyName = QString::fromLatin1("sans-serif");
|
||||||
break;
|
break;
|
||||||
case QFont::Courier:
|
case QFont::Serif:
|
||||||
familyName = QString::fromLatin1("Courier");
|
familyName = QString::fromLatin1("serif");
|
||||||
break;
|
break;
|
||||||
|
case QFont::TypeWriter:
|
||||||
case QFont::Monospace:
|
case QFont::Monospace:
|
||||||
familyName = QString::fromLatin1("Courier New");
|
familyName = QString::fromLatin1("monospace");
|
||||||
break;
|
break;
|
||||||
case QFont::Cursive:
|
case QFont::Cursive:
|
||||||
familyName = QString::fromLatin1("Comic Sans MS");
|
familyName = QString::fromLatin1("cursive");
|
||||||
break;
|
break;
|
||||||
case QFont::Fantasy:
|
case QFont::Fantasy:
|
||||||
familyName = QString::fromLatin1("Impact");
|
familyName = QString::fromLatin1("fantasy");
|
||||||
break;
|
break;
|
||||||
case QFont::Decorative:
|
case QFont::Decorative:
|
||||||
familyName = QString::fromLatin1("Old English");
|
familyName = QString::fromLatin1("decorative");
|
||||||
break;
|
break;
|
||||||
case QFont::Helvetica:
|
|
||||||
case QFont::System:
|
case QFont::System:
|
||||||
default:
|
default:
|
||||||
familyName = QString::fromLatin1("Helvetica");
|
familyName = QString();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->resolveFontFamilyAlias(familyName);
|
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->resolveFontFamilyAlias(familyName);
|
||||||
|
@ -630,13 +630,12 @@ void tst_QFont::defaultFamily_data()
|
|||||||
QTest::addColumn<QFont::StyleHint>("styleHint");
|
QTest::addColumn<QFont::StyleHint>("styleHint");
|
||||||
QTest::addColumn<QString>("defaultFamily");
|
QTest::addColumn<QString>("defaultFamily");
|
||||||
|
|
||||||
QTest::newRow("serif") << QFont::Times << "Times";
|
QTest::newRow("serif") << QFont::Times << "serif";
|
||||||
QTest::newRow("courier") << QFont::Courier << "Courier";
|
QTest::newRow("monospace") << QFont::Monospace << "monospace";
|
||||||
QTest::newRow("monospace") << QFont::Monospace << "Courier New";
|
QTest::newRow("sans-serif") << QFont::SansSerif << "sans-serif";
|
||||||
QTest::newRow("cursive") << QFont::Cursive << "Comic Sans MS";
|
QTest::newRow("cursive") << QFont::Cursive << "cursive";
|
||||||
QTest::newRow("fantasy") << QFont::Fantasy << "Impact";
|
QTest::newRow("fantasy") << QFont::Fantasy << "fantasy";
|
||||||
QTest::newRow("old english") << QFont::OldEnglish<< "Old English";
|
QTest::newRow("old english") << QFont::OldEnglish << "Old English";
|
||||||
QTest::newRow("sans-serif") << QFont::Helvetica << "Helvetica";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QFont::defaultFamily()
|
void tst_QFont::defaultFamily()
|
||||||
|
Loading…
Reference in New Issue
Block a user