summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2012-07-11 14:39:54 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-14 08:56:02 +0100
commitfa7661d8b25fa338649a301010e1b5a2b63da731 (patch)
treeabcc7217685ddb3175dcbf2589727448d72c9a28 /src/gui/text/qfontdatabase.cpp
parent3c09f6bc9aee0c97427fe8da6efdc73b4ac473aa (diff)
Fix styleName support in QPA font database
Font styleName support was disconnected since Qt switched to QPA fontdatabase. Now add the code from Qt 4.8 back to enable this in QPA. Change-Id: Iab2cbfd5468f87542183348c2123ca4b2c270692 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r--src/gui/text/qfontdatabase.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index a560b41570..d06bf217cb 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -274,27 +274,15 @@ struct QtFontFoundry
QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &styleName, bool create)
{
int pos = 0;
- if (count) {
- // if styleName for searching first if possible
- if (!styleName.isEmpty()) {
- for (; pos < count; pos++) {
- if (styles[pos]->styleName == styleName)
- return styles[pos];
- }
- }
- int low = 0;
- int high = count;
- pos = count / 2;
- while (high > low) {
+ for (; pos < count; pos++) {
+ bool hasStyleName = !styleName.isEmpty(); // search styleName first if available
+ if (hasStyleName && !styles[pos]->styleName.isEmpty()) {
+ if (styles[pos]->styleName == styleName)
+ return styles[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;
}
- pos = low;
}
if (!create)
return 0;
@@ -309,7 +297,6 @@ 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];