summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfontdatabase.cpp25
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp5
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp10
-rw-r--r--src/gui/text/qplatformfontdatabase.h3
4 files changed, 17 insertions, 26 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];
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index 22aacf1dcd..2ecab9ebf9 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -52,7 +52,8 @@
QT_BEGIN_NAMESPACE
-Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &foundryname, int weight,
+Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &stylename,
+ const QString &foundryname, int weight,
QFont::Style style, int stretch, bool antialiased,
bool scalable, int pixelSize, bool fixedPitch,
const QSupportedWritingSystems &writingSystems, void *handle)
@@ -75,7 +76,7 @@ Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &fou
}
QtFontFoundry *foundry = f->foundry(foundryname, true);
- QtFontStyle *fontStyle = foundry->style(styleKey, QString(), true);
+ QtFontStyle *fontStyle = foundry->style(styleKey, stylename, true);
fontStyle->smoothScalable = scalable;
fontStyle->antialiased = antialiased;
QtFontSize *size = fontStyle->pixelSize(pixelSize ? pixelSize : SMOOTH_SCALABLE, true);
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 6fd145d921..972e0b1a09 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -47,7 +47,8 @@
QT_BEGIN_NAMESPACE
-extern void qt_registerFont(const QString &familyname, const QString &foundryname, int weight,
+extern void qt_registerFont(const QString &familyname, const QString &stylename,
+ const QString &foundryname, int weight,
QFont::Style style, int stretch, bool antialiased,
bool scalable, int pixelSize, bool fixedPitch,
const QSupportedWritingSystems &writingSystems, void *hanlde);
@@ -89,7 +90,7 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *
}
}
QFont::Stretch stretch = QFont::Unstretched;
- registerFont(fontName,QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle);
+ registerFont(fontName,QString(),QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle);
}
} else {
qDebug() << "header verification of QPF2 font failed. maybe it is corrupt?";
@@ -117,7 +118,8 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *
\sa registerQPF2Font()
*/
-void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &foundryname, QFont::Weight weight,
+void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &stylename,
+ const QString &foundryname, QFont::Weight weight,
QFont::Style style, QFont::Stretch stretch, bool antialiased,
bool scalable, int pixelSize, bool fixedPitch,
const QSupportedWritingSystems &writingSystems, void *usrPtr)
@@ -125,7 +127,7 @@ void QPlatformFontDatabase::registerFont(const QString &familyname, const QStrin
if (scalable)
pixelSize = 0;
- qt_registerFont(familyname, foundryname, weight, style,
+ qt_registerFont(familyname, stylename, foundryname, weight, style,
stretch, antialiased, scalable, pixelSize,
fixedPitch, writingSystems, usrPtr);
}
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index 8c2e4cf5f7..5ff2542982 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -116,7 +116,8 @@ public:
//callback
static void registerQPF2Font(const QByteArray &dataArray, void *handle);
- static void registerFont(const QString &familyname, const QString &foundryname, QFont::Weight weight,
+ static void registerFont(const QString &familyname, const QString &stylename,
+ const QString &foundryname, QFont::Weight weight,
QFont::Style style, QFont::Stretch stretch, bool antialiased,
bool scalable, int pixelSize, bool fixedPitch,
const QSupportedWritingSystems &writingSystems, void *handle);