From fa7661d8b25fa338649a301010e1b5a2b63da731 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 11 Jul 2012 14:39:54 +0200 Subject: 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 --- src/gui/text/qfontdatabase.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/gui/text/qfontdatabase.cpp') 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]; -- cgit v1.2.3