diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-07-05 13:40:57 +0200 |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-07-05 13:46:03 +0200 |
commit | 83e93784a2da9e1898790e4455225da220f44d81 (patch) | |
tree | 7be38b23de981dc854faf20adb285e3dd6bfd385 /src/gui/text/qfontdatabase.cpp | |
parent | f51b5fe09c63e4b3c2ab5a4d06e162c43d38207d (diff) |
Fix regressions in previous QFontDatabase patch
1. QtFontStyle::Key comparison should either use styleName or
style, etc., but not both.
2. When initializing a QFont from QFontDatabase::font(), style
and weight parameters should always be set even when we found
a match styleName, in case these parameters will be used for
comparison later.
Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 8b5e4438be..5f50c4099f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -226,9 +226,9 @@ struct QtFontStyle signed int stretch : 12; bool operator==(const Key & other) { - return styleName == other.styleName && style == other.style && - weight == other.weight && - (stretch == 0 || other.stretch == 0 || stretch == other.stretch); + return (!styleName.isEmpty() && !other.styleName.isEmpty() && styleName == other.styleName) || + (style == other.style && weight == other.weight && + (stretch == 0 || other.stretch == 0 || stretch == other.stretch)); } bool operator!=(const Key &other) { return !operator==(other); @@ -2030,16 +2030,12 @@ QFont QFontDatabase::font(const QString &family, const QString &style, if (!s) // no styles found? return QApplication::font(); - if (s->key.styleName.isEmpty()) { - QFont fnt(family, pointSize, s->key.weight); - fnt.setStyle((QFont::Style)s->key.style); - return fnt; - } else { - // found a perfect match - QFont fnt(family, pointSize); + + QFont fnt(family, pointSize, s->key.weight); + fnt.setStyle((QFont::Style)s->key.style); + if (!s->key.styleName.isEmpty()) fnt.setStyleName(s->key.styleName); - return fnt; - } + return fnt; } |