summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-11-14 17:42:13 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-11-14 17:42:13 (GMT)
commitf37db56dda632d4a7e2e0301756331697f72b65a (patch)
treef78b189d8c1b3414ad4da383681b6b0062b1cc37 /src/gui
parent0b90bb86d2ef0b925158a9cf185981eaea1776c2 (diff)
parenta5df9f7e42d4d940e47f56d522b370b4876fa622 (diff)
downloadQt-f37db56dda632d4a7e2e0301756331697f72b65a.zip
Qt-f37db56dda632d4a7e2e0301756331697f72b65a.tar.gz
Qt-f37db56dda632d4a7e2e0301756331697f72b65a.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging: Remove font that may not exists in some OS X systems Fix regression in styleName searching Fix styleName listing with the same QtFontStyle::Key value Fix localized font family access in OS X
Diffstat (limited to 'src/gui')
-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
3 files changed, 34 insertions, 25 deletions
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);