summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-07-05 11:40:57 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-07-05 11:46:03 (GMT)
commit83e93784a2da9e1898790e4455225da220f44d81 (patch)
tree7be38b23de981dc854faf20adb285e3dd6bfd385
parentf51b5fe09c63e4b3c2ab5a4d06e162c43d38207d (diff)
downloadQt-83e93784a2da9e1898790e4455225da220f44d81.zip
Qt-83e93784a2da9e1898790e4455225da220f44d81.tar.gz
Qt-83e93784a2da9e1898790e4455225da220f44d81.tar.bz2
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
-rw-r--r--src/gui/text/qfontdatabase.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 8b5e443..5f50c40 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;
}