diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-11-09 16:06:55 +0100 |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-11-09 16:06:59 +0100 |
commit | 68de09f538ae1103a3104e0fba1086ea93581b6e (patch) | |
tree | c60bb5e6daca3462acf248e26487b2e7291207b0 /src/gui/text/qfontdatabase.cpp | |
parent | 738b1d2d93a77283bc40e3d03f378a2db8aec97f (diff) |
Fix regression in styleName searching
1. Faked styles should have styleNames as well otherwise we couldn't
find them.
2. With a QtFontFoundry mixed with style keys and style names, there
is no way to sort them in a manner than binary search will work,
we have to use linear search instead.
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 675c292d34..d5d8a12f7c 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -91,6 +91,8 @@ QT_BEGIN_NAMESPACE bool qt_enable_test_font = false; +static QString styleStringHelper(int weight, QFont::Style style); + Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value) { qt_enable_test_font = value; @@ -358,30 +360,15 @@ struct QtFontFoundry QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &styleName, bool create) { int pos = 0; - if (count) { - int low = 0; - int high = count; + for (; pos < count; pos++) { bool hasStyleName = !styleName.isEmpty(); // search styleName first if available - pos = count / 2; - while (high > low) { - if (hasStyleName) { - if (styles[pos]->styleName == styleName) - return styles[pos]; - if (styles[pos]->styleName < styleName) - low = pos + 1; - else - high = pos; - } else { - if (styles[pos]->key == key) - return styles[pos]; - if (styles[pos]->key < key) - low = pos + 1; - else - high = pos; - } - pos = (high + low) / 2; + if (hasStyleName && !styles[pos]->styleName.isEmpty()) { + if (styles[pos]->styleName == styleName) + return styles[pos]; + } else { + if (styles[pos]->key == key) + return styles[pos]; } - pos = low; } if (!create) return 0; @@ -396,13 +383,11 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &st QtFontStyle *style = new QtFontStyle(key); style->styleName = styleName; - memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *)); styles[pos] = style; count++; return styles[pos]; } - struct QtFontFamily { enum WritingSystemStatus { |