From d014bb648f3e8499a87c180274af5cc7e16e72de Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 1 Dec 2011 12:42:47 +0100 Subject: Backport writingSystems support code for Cocoa from Qt 5 Mark writingSystems support based on languages from Core Text. Task-number: QTBUG-20996 Reviewed-by: Morten Sorvig --- src/gui/text/qfontdatabase_mac.cpp | 54 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 81500c7..a96224c 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -84,6 +84,46 @@ qDebug() << "first char" << hex << unicodeRange[0]; for (int i = 0; i < systems.count(); ++i) family->writingSystems[systems.at(i)] = QtFontFamily::Supported; } +#else +// this could become a list of all languages used for each writing +// system, instead of using the single most common language. +static const char *languageForWritingSystem[] = { + 0, // Any + "en", // Latin + "el", // Greek + "ru", // Cyrillic + "hy", // Armenian + "he", // Hebrew + "ar", // Arabic + "syr", // Syriac + "div", // Thaana + "hi", // Devanagari + "bn", // Bengali + "pa", // Gurmukhi + "gu", // Gujarati + "or", // Oriya + "ta", // Tamil + "te", // Telugu + "kn", // Kannada + "ml", // Malayalam + "si", // Sinhala + "th", // Thai + "lo", // Lao + "bo", // Tibetan + "my", // Myanmar + "ka", // Georgian + "km", // Khmer + "zh-cn", // SimplifiedChinese + "zh-tw", // TraditionalChinese + "ja", // Japanese + "ko", // Korean + "vi", // Vietnamese + 0, // Symbol + 0, // Ogham + 0, // Runic + 0 // N'Ko +}; +enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; #endif static void initializeDb() @@ -107,8 +147,18 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { 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; + + if (QCFType languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) { + CFIndex length = CFArrayGetCount(languages); + for (int i = 1; i < LanguageCount; ++i) { + if (!languageForWritingSystem[i]) + continue; + QCFString lang = CFStringCreateWithCString(NULL, languageForWritingSystem[i], kCFStringEncodingASCII); + if (CFArrayContainsValue(languages, CFRangeMake(0, length), lang)) + family->writingSystems[i] = QtFontFamily::Supported; + } + } + QtFontFoundry *foundry = family->foundry(foundry_name, true); QtFontStyle::Key styleKey; -- cgit v0.12 From bc25cfdd65452efa226cbd544c9ae9803eb6748a Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 1 Dec 2011 14:15:00 +0100 Subject: Fix stretched font positions in Lion In Mac OS X 10.7 and up, According to http://lists.apple.com/archives/Coretext-dev/2011/Nov/msg00006.html we need to manually apply transform matrix to advances if text matrix as been applied, CTRunGetPositions won't apply it. Task-number: QTBUG-22825 Reviewed-by: Eskil --- src/gui/text/qfontengine_coretext.mm | 10 ++++++++-- src/gui/text/qfontengine_coretext_p.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 153451e..154c44f 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -97,6 +97,7 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const if (fontDef.stretch != 100) { transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1); } + transformAdvances = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7; QCFType descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize); QCFType baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform); @@ -225,6 +226,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl); CFRange stringRange = CTRunGetStringRange(run); + CGAffineTransform textMatrix = CTRunGetTextMatrix(run); int prepend = 0; #if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5 UniChar beginGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location); @@ -319,9 +321,13 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay for (CFIndex i = 0; i < glyphCount - 1; ++i) { int idx = rtlOffset + rtlSign * i; outGlyphs[idx] = tmpGlyphs[i] | fontIndex; - outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x); + CGSize advance = CGSizeMake(tmpPoints[i + 1].x - tmpPoints[i].x, tmpPoints[i].y - tmpPoints[i + 1].y); + if (transformAdvances) + advance = CGSizeApplyAffineTransform(advance, textMatrix); + + outAdvances_x[idx] = QFixed::fromReal(advance.width); // Use negative y advance for flipped coordinate system - outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i].y - tmpPoints[i + 1].y); + outAdvances_y[idx] = QFixed::fromReal(advance.height); if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { outAdvances_x[idx] = outAdvances_x[idx].round(); diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h index 4bd80be..495e638 100644 --- a/src/gui/text/qfontengine_coretext_p.h +++ b/src/gui/text/qfontengine_coretext_p.h @@ -146,6 +146,7 @@ private: mutable QCFType attributeDict; CGAffineTransform transform; friend class QFontDialogPrivate; + bool transformAdvances; }; CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); -- cgit v0.12 From 8ed37d9bba6e2899724d13bd3ba8911c505b1c8c Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 8 Dec 2011 14:00:46 +0000 Subject: Symbian: improving diagnostics for QWaitCondition If a QWaitCondition was deleted while it was waiting, it would crash in the wait() function while trying to use its internal mutex. This crash is not particularly obvious in its cause. QWaitCondition can detect this delete-while-waiting case, issue appropriate warnings and avoid a crash in its internal state. In the app crash case where this problem was found, there is a further crash after this one due to an externally deleted mutex. The app is clearly at fault. But at least there's now more debug info about what the app is doing wrong. Task-number: ou1cimx1#946509 partial fix Reviewed-by: Shane Kearns --- src/corelib/thread/qwaitcondition_symbian.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/thread/qwaitcondition_symbian.cpp b/src/corelib/thread/qwaitcondition_symbian.cpp index c6414e8..ed1011c 100644 --- a/src/corelib/thread/qwaitcondition_symbian.cpp +++ b/src/corelib/thread/qwaitcondition_symbian.cpp @@ -112,7 +112,10 @@ public: --wakeups; } - mutex.Signal(); + // if err is KErrGeneral it signals that the RCondVar is closed along with the mutex and that this has been deleted + // we must not access any member variables in this case + if (err != KErrGeneral) + mutex.Signal(); if (err && err != KErrTimedOut) report_error(err, "QWaitCondition::wait()", "cv wait"); -- cgit v0.12 From 5382ea19ed0d35f889f7cae6b3f63d659f3cc894 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 31 May 2011 10:11:16 +1000 Subject: tests: fixed compile of qscriptextensionplugin test with high -jN Dependencies between this test and some helper projects were not declared, so aggressively parallel builds would fail semi-randomly. Reviewed-by: Jason McDonald (cherry picked from commit f567467a3ac4182a4c6bb592e4ec596ec458c11b) Change-Id: If5b1998e18009ffac58637f6723c0a2ddd49c85d --- tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro b/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro index d4671c8..48f0eb9 100644 --- a/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro +++ b/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro @@ -1,3 +1,4 @@ TEMPLATE = subdirs CONFIG -= app_bundle +test.depends = simpleplugin staticplugin SUBDIRS = simpleplugin staticplugin test -- cgit v0.12