diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-11-09 15:06:55 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-11-09 15:06:59 (GMT) |
commit | 68de09f538ae1103a3104e0fba1086ea93581b6e (patch) | |
tree | c60bb5e6daca3462acf248e26487b2e7291207b0 /src | |
parent | 738b1d2d93a77283bc40e3d03f378a2db8aec97f (diff) | |
download | Qt-68de09f538ae1103a3104e0fba1086ea93581b6e.zip Qt-68de09f538ae1103a3104e0fba1086ea93581b6e.tar.gz Qt-68de09f538ae1103a3104e0fba1086ea93581b6e.tar.bz2 |
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')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 33 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase_x11.cpp | 1 |
2 files changed, 10 insertions, 24 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 675c292..d5d8a12 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 { diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index 922a97f..df25aa6 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1361,6 +1361,7 @@ static void initializeDb() // let's fake one... equiv = foundry->style(key, QString(), true); + equiv->styleName = styleStringHelper(key.weight, QFont::Style(key.style)); equiv->smoothScalable = true; QtFontSize *equiv_size = equiv->pixelSize(SMOOTH_SCALABLE, true); |