summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWater-Team <water@pad.test.qt.nokia.com>2011-11-15 00:00:13 (GMT)
committerWater-Team <water@pad.test.qt.nokia.com>2011-11-15 00:00:13 (GMT)
commit301ec400cf5257d0ce5aec7ac4a9e7a0edf77ca3 (patch)
treea8ff2355bddcc7dbecfbf4f95fa70cdc7d174b1b /src
parentf8ca22cbd388c29dd507b74d3b409284df0ddd48 (diff)
parentf37db56dda632d4a7e2e0301756331697f72b65a (diff)
downloadQt-301ec400cf5257d0ce5aec7ac4a9e7a0edf77ca3.zip
Qt-301ec400cf5257d0ce5aec7ac4a9e7a0edf77ca3.tar.gz
Qt-301ec400cf5257d0ce5aec7ac4a9e7a0edf77ca3.tar.bz2
Merge branch '4.8-upstream' into master-water
Diffstat (limited to 'src')
-rw-r--r--src/gui/dialogs/qmessagebox.cpp2
-rw-r--r--src/gui/text/qfontdatabase.cpp32
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp26
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp1
4 files changed, 35 insertions, 26 deletions
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index 149e267..ba00cd8 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -153,7 +153,7 @@ public:
expandedTo(QApplication::globalStrut());
opt.text = label(HideLabel);
sz = fm.size(Qt::TextShowMnemonic, opt.text);
- ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
+ ret = ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
expandedTo(QApplication::globalStrut()));
return ret;
}
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 796c455..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,32 +360,20 @@ 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;
-// qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos);
+ // qDebug("adding key (weight=%d, style=%d, stretch=%d) at %d", key.weight, key.style, key.stretch, pos);
if (!(count % 8)) {
QtFontStyle **newStyles = (QtFontStyle **)
realloc(styles, (((count+8) >> 3) << 3) * sizeof(QtFontStyle *));
@@ -393,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 {
@@ -1132,7 +1120,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
#endif
QT_END_INCLUDE_NAMESPACE
-#if !defined(Q_WS_X11)
+#if !defined(Q_WS_X11) && !defined(Q_WS_MAC)
QString QFontDatabase::resolveFontFamilyAlias(const QString &family)
{
return family;
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index 9a8e8af..81500c7 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -104,9 +104,8 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
const int numFonts = CFArrayGetCount(fonts);
for(int i = 0; i < numFonts; ++i) {
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
-
- QCFString family_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
- QCFString style_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
+ QCFString family_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL);
+ QCFString style_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL);
QtFontFamily *family = db->family(family_name, true);
for(int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws)
family->writingSystems[ws] = QtFontFamily::Supported;
@@ -489,4 +488,25 @@ bool QFontDatabase::supportsThreadedFontRendering()
return true;
}
+QString QFontDatabase::resolveFontFamilyAlias(const QString &family)
+{
+ QCFString expectedFamily = QCFString(family);
+
+ QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(NULL, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, expectedFamily);
+ QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(attributes);
+
+ QCFType<CFMutableSetRef> mandatoryAttributes = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
+ CFSetAddValue(mandatoryAttributes, kCTFontFamilyNameAttribute);
+
+ QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(descriptor, 0.0, NULL);
+ QCFType<CTFontDescriptorRef> matched = CTFontDescriptorCreateMatchingFontDescriptor(descriptor, mandatoryAttributes);
+ if (!matched)
+ return family;
+
+ QCFString familyName = (CFStringRef) CTFontDescriptorCopyLocalizedAttribute(matched, kCTFontFamilyNameAttribute, NULL);
+ return familyName;
+}
+
QT_END_NAMESPACE
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);