From 06f079e528bf135e5d407b15d1bd50a91ce4a888 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 25 Jul 2011 15:23:54 +0200 Subject: Reset previousGlyph once we reached a new text item The bug was introduced in fd818312. Before that, previousGlyph is only saved in the same text item. After we moved it to LineBreakHelper struct, it will cause crash if the font engine in the new text item no longer contains the sub engine required by previousGlyph. Task-number: QTBUG-20243 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 183bcea..01adecf 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1869,6 +1869,7 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); lbh.glyphs = eng->shapedGlyphs(¤t); + lbh.previousGlyph = 0; QFontEngine *fontEngine = eng->fontEngine(current); if (lbh.fontEngine != fontEngine) { lbh.fontEngine = fontEngine; -- cgit v0.12 From 292656a345e33c332316a676465261c13c9a4aba Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 25 Jul 2011 16:16:50 +0200 Subject: Fix typo in QFontDialog docs Reviewed-by: TrustMe --- src/gui/dialogs/qfontdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index 6a646ff..34b6317 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -160,7 +160,7 @@ QFontDialog::QFontDialog(QWidget *parent) \since 4.5 Constructs a standard font dialog with the given \a parent and specified - \a initial color. + \a initial font. */ QFontDialog::QFontDialog(const QFont &initial, QWidget *parent) : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) -- cgit v0.12 From 91be1263b42a0a91daf3f905661e356e31482fd3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 26 Jul 2011 13:43:48 +0200 Subject: Fix compilation under OSX 10.7 or using llvm-gcc. Use correct error codes instead of type errors. Thanks to Dylan Luke for this patch. Merge-request: 1304 Reviewed-by: Jiang Jiang --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 3e8ce4e..a2eb484 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -327,7 +327,7 @@ QT_END_NAMESPACE QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super draggingEntered:sender]; + return NSDragOperationNone; if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) return NSDragOperationNone; @@ -339,7 +339,7 @@ QT_END_NAMESPACE { QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super draggingUpdated:sender]; + return NSDragOperationNone; if (target == *currentDragTarget()) { // The drag continues to move over the widget that we have sendt @@ -363,7 +363,7 @@ QT_END_NAMESPACE { QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super draggingExited:sender]; + return; if (*currentDragTarget()) { [reinterpret_cast((*currentDragTarget())->winId()) draggingExited:sender]; @@ -375,7 +375,7 @@ QT_END_NAMESPACE { QWidget *target = [self dragTargetHitTest:sender]; if (!target) - return [super performDragOperation:sender]; + return NO; BOOL dropResult = NO; if (*currentDragTarget()) { -- cgit v0.12 From fa344b355d311fce7954e2fd1a22a87a88194783 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 25 Jul 2011 16:22:22 +0200 Subject: Symbian^3 workaround: Avoid usage of linked fonts. "Linked Fonts" are a new feature in Symbian^3, first used in SR11.1. This patch prevents Qt from using linked fonts in any way. Avkon based applications benefit from Linked Fonts because they can now transparently render multi-script text, e.g. Latin/Chinese/Japanese (Qt does that by its own and calls the feature 'font merging'). From Qt's poing of view, Linked Fonts are a severe regression in Symbian's API. 1 Font table Api for linked fonts is extremely slow 2 'cmap' tables do not seem to reflect the "linkage", causing garbled text or crashes. 3 Linked fonts appear with cryptic type face names, and are redundant since they are just compounds of the other, real fonts. This patch adds a detection of Linked Fonts using CLinkedTypefaceSpecification and prevents their inclusion into QFontDataBase. Furthermore, it detects if the Symbian System font is a Linked font and if needed tries to fall back to a classical Symbian system font, e.g. "Nokia Sans S60" or "Series 60 Sans". Fallback to "Pure" will need to be added, later on. Task-Number: QTBUG-20007 Co-authored-by: Miklos Vlasa Reviewed-by: mread --- src/gui/text/qfont_s60.cpp | 33 +++++++++++++++++++++++++-------- src/gui/text/qfontdatabase_s60.cpp | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp index a7a2547..2218617 100644 --- a/src/gui/text/qfont_s60.cpp +++ b/src/gui/text/qfont_s60.cpp @@ -55,6 +55,24 @@ Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, fontFamiliesOnFontServer, { // Therefore, we are allowed to cache the list. x->append(qt_symbian_fontFamiliesOnFontServer()); }); + +extern bool qt_symbian_isLinkedFont(const TDesC &typefaceName); // qfontdatabase_s60.cpp + +static QString classicalSymbianSystemFont() +{ + static QString font; + if (font.isEmpty()) { + static const char* const classicSymbianSystemFonts[] = { "Nokia Sans S60", "Series 60 Sans" }; + for (int i = 0; i < sizeof classicSymbianSystemFonts / sizeof classicSymbianSystemFonts[0]; ++i) { + const QString classicFont = QLatin1String(classicSymbianSystemFonts[i]); + if (fontFamiliesOnFontServer()->contains(classicFont)) { + font = classicFont; + break; + } + } + } + return font; +} #endif // QT_NO_FREETYPE QString QFont::lastResortFont() const @@ -84,6 +102,10 @@ QString QFont::lastResortFamily() const S60->screenDevice()->ReleaseFont(font); lock.relock(); + + // We must not return a Symbian Linked Font. See QTBUG-20007 + if (qt_symbian_isLinkedFont(spec.iTypeface.iName) && !classicalSymbianSystemFont().isEmpty()) + family = classicalSymbianSystemFont(); } return family; #else // QT_NO_FREETYPE @@ -103,14 +125,9 @@ QString QFont::defaultFamily() const { #ifdef QT_NO_FREETYPE switch(d->request.styleHint) { - case QFont::SansSerif: { - static const char* const preferredSansSerif[] = {"Nokia Sans S60", "Series 60 Sans"}; - for (int i = 0; i < sizeof preferredSansSerif / sizeof preferredSansSerif[0]; ++i) { - const QString sansSerif = QLatin1String(preferredSansSerif[i]); - if (fontFamiliesOnFontServer()->contains(sansSerif)) - return sansSerif; - } - } + case QFont::SansSerif: + if (!classicalSymbianSystemFont().isEmpty()) + return classicalSymbianSystemFont(); // No break. Intentional fall through. default: return lastResortFamily(); diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 1eb4242..ffecca7 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -58,8 +58,41 @@ #endif // SYMBIAN_ENABLE_SPLIT_HEADERS #endif // QT_NO_FREETYPE +#ifndef SYMBIAN_VERSION_9_4 +#define SYMBIAN_LINKEDFONTS_SUPPORTED +#endif // !SYMBIAN_VERSION_9_4 + +#ifdef SYMBIAN_LINKEDFONTS_SUPPORTED +#include +#endif // SYMBIAN_LINKEDFONTS_SUPPORTED + QT_BEGIN_NAMESPACE +#ifdef SYMBIAN_LINKEDFONTS_SUPPORTED +static bool isLinkedFontL(const TDesC &aTypefaceName) +{ + CLinkedTypefaceSpecification *linkedspec = CLinkedTypefaceSpecification::NewLC(aTypefaceName); + CFbsTypefaceStore *tfs = CFbsTypefaceStore::NewL(NULL); + CleanupStack::PushL(tfs); + linkedspec->FetchLinkedTypefaceSpecificationL(*tfs); + CleanupStack::PopAndDestroy(tfs); + CleanupStack::PopAndDestroy(linkedspec); + return true; +} +#endif // SYMBIAN_LINKEDFONTS_SUPPORTED + +bool qt_symbian_isLinkedFont(const TDesC &typefaceName) // Also used in qfont_s60.cpp +{ + bool isLinkedFont = false; +#ifdef SYMBIAN_LINKEDFONTS_SUPPORTED + if (RFbsSession::Connect() == KErrNone) { + TRAP_IGNORE(isLinkedFont = isLinkedFontL(typefaceName)); + RFbsSession::Disconnect(); + } +#endif // SYMBIAN_LINKEDFONTS_SUPPORTED + return isLinkedFont; +} + QStringList qt_symbian_fontFamiliesOnFontServer() // Also used in qfont_s60.cpp { QStringList result; @@ -468,7 +501,10 @@ static bool registerScreenDeviceFont(int screenDeviceFontIndex, const QSymbianFontDatabaseExtrasImplementation *dbExtras) { TTypefaceSupport typefaceSupport; - S60->screenDevice()->TypefaceSupport(typefaceSupport, screenDeviceFontIndex); + S60->screenDevice()->TypefaceSupport(typefaceSupport, screenDeviceFontIndex); + + if (qt_symbian_isLinkedFont(typefaceSupport.iTypeface.iName)) + return false; QString familyName((const QChar*)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length()); if (qt_symbian_fontNameHasAppFontMarker(familyName)) { -- cgit v0.12 From cc500b182e26d53ca16136f24a06a111f4374425 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 27 Jul 2011 10:42:40 +0200 Subject: Save previous font engine for right bearing adjustment In last fix I forgot that fd818312 was for saving and restoring the right bearing (of last visible glyph) when a LineSeparator was hit (which can have a different font engine but usually not visble), thus we can't reset previousGlyph in that case. To make sure we still get correct right bearing from the font engine used to shape previousGlyph, we need to save that font engine as well. It does make the code more complicated than simply saving the right bearing when a QScriptItem boundary is hit, so hopefully it's an optimization worth to be made (following e1915815). Task-number: QTBUG-20423 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 01adecf..d180f0e 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1715,6 +1715,7 @@ namespace { QFixed minimumRightBearing; QFontEngine *fontEngine; + QFontEngine *previousFontEngine; const unsigned short *logClusters; bool manualWrap; @@ -1735,12 +1736,19 @@ namespace { return glyphs.glyphs[logClusters[currentPosition - 1]]; } - inline void saveCurrentGlyph() + inline void resetPreviousGlyph() { previousGlyph = 0; + previousFontEngine = 0; + } + + inline void saveCurrentGlyph() + { + resetPreviousGlyph(); if (currentPosition > 0 && logClusters[currentPosition - 1] < glyphs.numGlyphs) { previousGlyph = currentGlyph(); // needed to calculate right bearing later + previousFontEngine = fontEngine; } } @@ -1760,8 +1768,11 @@ namespace { inline void adjustPreviousRightBearing() { - if (previousGlyph > 0) - adjustRightBearing(previousGlyph); + if (previousGlyph > 0 && previousFontEngine) { + qreal rb; + previousFontEngine->getGlyphBearings(previousGlyph, 0, &rb); + rightBearing = qMin(QFixed(), QFixed::fromReal(rb)); + } } inline void resetRightBearing() @@ -1851,7 +1862,7 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = line.from; int end = 0; lbh.logClusters = eng->layoutData->logClustersPtr; - lbh.previousGlyph = 0; + lbh.resetPreviousGlyph(); while (newItem < eng->layoutData->items.size()) { lbh.resetRightBearing(); @@ -1869,7 +1880,6 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); lbh.glyphs = eng->shapedGlyphs(¤t); - lbh.previousGlyph = 0; QFontEngine *fontEngine = eng->fontEngine(current); if (lbh.fontEngine != fontEngine) { lbh.fontEngine = fontEngine; -- cgit v0.12 From 7c499bcfbf7f9c52b3d6523fea8396bd4ab7252e Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 27 Jul 2011 15:59:02 +0200 Subject: Remove a duplicate include line Build Qt 4.7 for Symbian on Mac/gcce again. Reviewed-by: Honglei Zhang --- src/gui/painting/qgraphicssystemex_symbian.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp index dc4dd92..4469704 100644 --- a/src/gui/painting/qgraphicssystemex_symbian.cpp +++ b/src/gui/painting/qgraphicssystemex_symbian.cpp @@ -43,7 +43,6 @@ #include "private/qwidget_p.h" #include "private/qbackingstore_p.h" #include "private/qapplication_p.h" -#include "qwidget_p.h" #include -- cgit v0.12 From 22995948cd3f46780be5d8016708aeef0cd7b066 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 28 Jul 2011 14:15:28 +0200 Subject: Revert binary search in QTextEngine::findItem It's part of c9607f069f0fb98021daf0af9f1d1b2981018e0c which caused crash in certain cases. Task-number: QTBUG-17209 Reviewed-by: Gunnar Sletta --- src/gui/text/qtextengine.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 6c13eae..cff3641 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1577,19 +1577,13 @@ bool QTextEngine::isRightToLeft() const int QTextEngine::findItem(int strPos) const { itemize(); - int left = 0; - int right = layoutData->items.size()-1; - while(left <= right) { - int middle = ((right-left)/2)+left; - if (strPos > layoutData->items[middle].position) - left = middle+1; - else if(strPos < layoutData->items[middle].position) - right = middle-1; - else { - return middle; - } + + int item; + for (item = layoutData->items.size()-1; item > 0; --item) { + if (layoutData->items[item].position <= strPos) + break; } - return right; + return item; } QFixed QTextEngine::width(int from, int len) const -- cgit v0.12