diff options
author | aavit <qt-info@nokia.com> | 2011-09-10 14:43:04 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2011-09-10 14:43:04 (GMT) |
commit | b318fc0800c3081af16a38614b95dd50a82b6bbb (patch) | |
tree | 9057e35b5d03ce2b223167b5bc98af681fcb0065 /src/gui/text | |
parent | e78edf97db002d5d8efcfd0c2df283f980d3a432 (diff) | |
parent | 2fafbf51d6cd61d073c9f77dffd71864e9686de6 (diff) | |
download | Qt-b318fc0800c3081af16a38614b95dd50a82b6bbb.zip Qt-b318fc0800c3081af16a38614b95dd50a82b6bbb.tar.gz Qt-b318fc0800c3081af16a38614b95dd50a82b6bbb.tar.bz2 |
Merge remote-tracking branch 'qt-fire-review/master'
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase_s60.cpp | 30 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qfontengine_coretext_p.h | 8 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qfontengine_p.h | 3 | ||||
-rw-r--r-- | src/gui/text/qrawfont.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qrawfont_ft.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qrawfont_win.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qtextengine_p.h | 3 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 7 |
11 files changed, 54 insertions, 25 deletions
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 8400feb..ffa4e59 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -166,7 +166,6 @@ public: COpenFontRasterizer *m_rasterizer; mutable QList<const QSymbianTypeFaceExtras *> m_extras; - mutable QHash<QString, const QSymbianTypeFaceExtras *> m_extrasHash; mutable QSet<QString> m_applicationFontFamilies; }; @@ -269,8 +268,9 @@ void QSymbianFontDatabaseExtrasImplementation::clear() static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); if (!dbExtras) return; // initializeDb() has never been called + QSymbianTypeFaceExtrasHash &extrasHash = S60->fontData(); if (QSymbianTypeFaceExtras::symbianFontTableApiAvailable()) { - qDeleteAll(dbExtras->m_extrasHash); + qDeleteAll(extrasHash); } else { typedef QList<const QSymbianTypeFaceExtras *>::iterator iterator; for (iterator p = dbExtras->m_extras.begin(); p != dbExtras->m_extras.end(); ++p) { @@ -279,11 +279,16 @@ void QSymbianFontDatabaseExtrasImplementation::clear() } dbExtras->m_extras.clear(); } - dbExtras->m_extrasHash.clear(); + extrasHash.clear(); } void qt_cleanup_symbianFontDatabase() { + static bool cleanupDone = false; + if (cleanupDone) + return; + cleanupDone = true; + QFontDatabasePrivate *db = privateDb(); if (!db) return; @@ -334,9 +339,12 @@ COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont) const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &aTypeface, bool bold, bool italic) const { + QSymbianTypeFaceExtrasHash &extrasHash = S60->fontData(); + if (extrasHash.isEmpty() && QThread::currentThread() != QApplication::instance()->thread()) + S60->addThreadLocalReleaseFunc(clear); const QString typeface = qt_symbian_fontNameWithAppFontMarker(aTypeface); const QString searchKey = typeface + QString::number(int(bold)) + QString::number(int(italic)); - if (!m_extrasHash.contains(searchKey)) { + if (!extrasHash.contains(searchKey)) { TFontSpec searchSpec(qt_QString2TPtrC(typeface), 1); if (bold) searchSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); @@ -350,7 +358,7 @@ const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(c QScopedPointer<CFont, CFontFromScreenDeviceReleaser> sFont(font); QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font); sFont.take(); - m_extrasHash.insert(searchKey, extras); + extrasHash.insert(searchKey, extras); } else { const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, searchSpec); Q_ASSERT(err == KErrNone && font); @@ -364,20 +372,20 @@ const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(c const TOpenFontFaceAttrib* const attrib = openFont->FaceAttrib(); const QString foundKey = QString((const QChar*)attrib->FullName().Ptr(), attrib->FullName().Length()); - if (!m_extrasHash.contains(foundKey)) { + if (!extrasHash.contains(foundKey)) { QScopedPointer<CFont, CFontFromFontStoreReleaser> sFont(font); QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font, openFont); sFont.take(); m_extras.append(extras); - m_extrasHash.insert(searchKey, extras); - m_extrasHash.insert(foundKey, extras); + extrasHash.insert(searchKey, extras); + extrasHash.insert(foundKey, extras); } else { m_store->ReleaseFont(font); - m_extrasHash.insert(searchKey, m_extrasHash.value(foundKey)); + extrasHash.insert(searchKey, extrasHash.value(foundKey)); } } } - return m_extrasHash.value(searchKey); + return extrasHash.value(searchKey); } void QSymbianFontDatabaseExtrasImplementation::removeAppFontData( @@ -973,7 +981,7 @@ bool QFontDatabase::removeAllApplicationFonts() bool QFontDatabase::supportsThreadedFontRendering() { - return false; + return QSymbianTypeFaceExtras::symbianFontTableApiAvailable(); } static diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index dec0982..7056861 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -280,6 +280,8 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform int i = glyphs.numGlyphs; int totalKashidas = 0; while(i--) { + if (glyphs.attributes[i].dontPrint) + continue; xpos += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6); ypos += glyphs.advances_y[i]; totalKashidas += glyphs.justifications[i].nKashidas; diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h index 0a2ae1f..4bd80be 100644 --- a/src/gui/text/qfontengine_coretext_p.h +++ b/src/gui/text/qfontengine_coretext_p.h @@ -52,6 +52,10 @@ #if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + class QRawFontPrivate; class QCoreTextFontEngineMulti; class QCoreTextFontEngine : public QFontEngine @@ -146,6 +150,10 @@ private: CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); +QT_END_NAMESPACE + +QT_END_HEADER + #endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) #endif // QFONTENGINE_CORETEXT_P_H diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 9a5d9d6..e3ab655 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -78,6 +78,10 @@ #include FT_ERRORS_H #endif +#if !defined(QT_MAX_CACHED_GLYPH_SIZE) +# define QT_MAX_CACHED_GLYPH_SIZE 64 +#endif + QT_BEGIN_NAMESPACE /* @@ -373,7 +377,7 @@ void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, *xsize = *ysize = 0; } } else { - *outline_drawing = (*xsize > (64<<6) || *ysize > (64<<6)); + *outline_drawing = (*xsize > (QT_MAX_CACHED_GLYPH_SIZE<<6) || *ysize > (QT_MAX_CACHED_GLYPH_SIZE<<6)); } } @@ -1317,7 +1321,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor if (!gs) { // don't try to load huge fonts - bool draw_as_outline = fontDef.pixelSize * qSqrt(qAbs(matrix.det())) >= 64; + bool draw_as_outline = fontDef.pixelSize * qSqrt(qAbs(matrix.det())) >= QT_MAX_CACHED_GLYPH_SIZE; if (draw_as_outline) return 0; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index a70aec1..8d81acb 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -155,6 +155,7 @@ public: struct FaceId { FaceId() : index(0), encoding(0) {} QByteArray filename; + QByteArray uuid; int index; int encoding; }; @@ -295,7 +296,7 @@ inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId inline uint qHash(const QFontEngine::FaceId &f) { - return qHash((f.index << 16) + f.encoding) + qHash(f.filename); + return qHash((f.index << 16) + f.encoding) + qHash(f.filename + f.uuid); } diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index c477a6a..61bc63e 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -637,9 +637,9 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ // Pick the one matches the family name we originally requested, // if none of them match, just pick the first one for (int i = 0; i < list.size(); i++) { - rawfont = list.at(i).rawFont(); - if (rawfont.familyName() == font.family()) - return rawfont; + rawFont = list.at(i).rawFont(); + if (rawFont.familyName() == font.family()) + return rawFont; } return list.at(0).rawFont(); } diff --git a/src/gui/text/qrawfont_ft.cpp b/src/gui/text/qrawfont_ft.cpp index 5bba221..1666df3 100644 --- a/src/gui/text/qrawfont_ft.cpp +++ b/src/gui/text/qrawfont_ft.cpp @@ -45,6 +45,7 @@ #include "qrawfont_p.h" #include "qfontengine_ft_p.h" +#include "quuid.h" #if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG) # include "qfontengine_x11_p.h" @@ -87,6 +88,7 @@ public: FaceId faceId; faceId.filename = ""; faceId.index = 0; + faceId.uuid = QUuid::createUuid().toByteArray(); return init(faceId, true, Format_None, fontData); } diff --git a/src/gui/text/qrawfont_win.cpp b/src/gui/text/qrawfont_win.cpp index ea1e75b..a729e31 100644 --- a/src/gui/text/qrawfont_win.cpp +++ b/src/gui/text/qrawfont_win.cpp @@ -578,7 +578,9 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, resolveGdi32(); if (ptrAddFontMemResourceEx && ptrRemoveFontMemResourceEx) { DWORD count = 0; - fontHandle = ptrAddFontMemResourceEx((void *)fontData.constData(), fontData.size(), 0, &count); + QByteArray newFontData = font.data(); + fontHandle = ptrAddFontMemResourceEx((void *)newFontData.constData(), newFontData.size(), + 0, &count); if (count == 0 && fontHandle != NULL) { ptrRemoveFontMemResourceEx(fontHandle); fontHandle = NULL; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index aa4a20d..a0e1751 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -968,7 +968,7 @@ void QTextEngine::shapeText(int item) const } for (int i = 0; i < si.num_glyphs; ++i) - si.width += glyphs.advances_x[i]; + si.width += glyphs.advances_x[i] * !glyphs.attributes[i].dontPrint; } static inline bool hasCaseChange(const QScriptItem &si) @@ -2658,7 +2658,7 @@ void QTextEngine::splitItem(int item, int pos) const QFixed w = 0; const QGlyphLayout g = shapedGlyphs(&oldItem); for(int j = 0; j < breakGlyph; ++j) - w += g.advances_x[j]; + w += g.advances_x[j] * !g.attributes[j].dontPrint; newItem.width = oldItem.width - w; oldItem.width = w; @@ -2951,7 +2951,7 @@ int QTextEngine::lineNumberForTextPosition(int pos) return lines.size() - 1; for (int i = 0; i < lines.size(); ++i) { const QScriptLine& line = lines[i]; - if (line.from + line.length > pos) + if (line.from + line.length + line.trailingSpaces > pos) return i; } return -1; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index b1bd0c3..0a86886 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -376,7 +376,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine { // created and filled in QTextLine::layout_helper QScriptLine() - : from(0), length(0), + : from(0), trailingSpaces(0), length(0), justified(0), gridfitted(0), hasTrailingSpaces(0), leadingIncluded(0) {} QFixed descent; @@ -388,6 +388,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine QFixed textWidth; QFixed textAdvance; int from; + unsigned short trailingSpaces; signed int length : 28; mutable uint justified : 1; mutable uint gridfitted : 1; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 4fd6ddf..4595ef5 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -814,7 +814,7 @@ QTextLine QTextLayout::createLine() if (l && d->lines.at(l-1).length < 0) { QTextLine(l-1, d).setNumColumns(INT_MAX); } - int from = l > 0 ? d->lines.at(l-1).from + d->lines.at(l-1).length : 0; + int from = l > 0 ? d->lines.at(l-1).from + d->lines.at(l-1).length + d->lines.at(l-1).trailingSpaces : 0; int strlen = d->layoutData->string.length(); if (l && from >= strlen) { if (!d->lines.at(l-1).length || d->layoutData->string.at(strlen - 1) != QChar::LineSeparator) @@ -1708,6 +1708,7 @@ void QTextLine::layout_helper(int maxGlyphs) { QScriptLine &line = eng->lines[i]; line.length = 0; + line.trailingSpaces = 0; line.textWidth = 0; line.hasTrailingSpaces = false; @@ -1931,7 +1932,7 @@ found: if (eng->option.flags() & QTextOption::IncludeTrailingSpaces) line.textWidth += lbh.spaceData.textWidth; if (lbh.spaceData.length) { - line.length += lbh.spaceData.length; + line.trailingSpaces = lbh.spaceData.length; line.hasTrailingSpaces = true; } @@ -1995,7 +1996,7 @@ int QTextLine::textLength() const && eng->block.isValid() && i == eng->lines.count()-1) { return eng->lines[i].length - 1; } - return eng->lines[i].length; + return eng->lines[i].length + eng->lines[i].trailingSpaces; } static void drawMenuText(QPainter *p, QFixed x, QFixed y, const QScriptItem &si, QTextItemInt &gf, QTextEngine *eng, |