diff options
author | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-05-13 12:42:46 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-05-13 12:42:46 +0200 |
commit | 8524853227c753b5cfa14184a086ec0acff3930a (patch) | |
tree | 808fab49e65286a4b4416a8462bb78fc188dfeac /src/gui/text | |
parent | d5a6c1613b52ebc015aa85a46c1387909d435926 (diff) | |
parent | bf06924f3ffd22747c93a720caa501d8478dcbe6 (diff) |
Merge branch 'wip/highdpi' of git://code.qt.io/qt/qtbase into dev-highdpi
Conflicts:
src/plugins/platforms/xcb/qxcbscreen.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfont.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 46 | ||||
-rw-r--r-- | src/gui/text/qplatformfontdatabase.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qplatformfontdatabase.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextcursor.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 15 | ||||
-rw-r--r-- | src/gui/text/qtextengine_p.h | 1 | ||||
-rw-r--r-- | src/gui/text/qtextformat.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qtextformat_p.h | 1 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtextobject.cpp | 2 |
12 files changed, 28 insertions, 72 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index a5fade99fd..ce39645246 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1724,10 +1724,8 @@ bool QFont::rawMode() const */ QFont QFont::resolve(const QFont &other) const { - if (*this == other - && (resolve_mask == other.resolve_mask || resolve_mask == 0) - && d->dpi == other.d->dpi) { - QFont o = other; + if (resolve_mask == 0 || (resolve_mask == other.resolve_mask && *this == other)) { + QFont o(other); o.resolve_mask = resolve_mask; return o; } diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 1a71042648..126f0bf3ec 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -172,16 +172,6 @@ static int getFontWeight(const QString &weightString) return QFont::Normal; } -struct QtFontEncoding -{ - signed int encoding : 16; - - uint xpoint : 16; - uint xres : 8; - uint yres : 8; - uint avgwidth : 16; - uchar pitch : 8; -}; struct QtFontSize { @@ -356,7 +346,6 @@ struct QtFontFamily populated(false), fixedPitch(false), name(n), count(0), foundries(0) - , bogusWritingSystems(false) , askedForFallback(false) { memset(writingSystems, 0, sizeof(writingSystems)); @@ -375,7 +364,6 @@ struct QtFontFamily int count; QtFontFoundry **foundries; - bool bogusWritingSystems; QStringList fallbackFamilies; bool askedForFallback; unsigned char writingSystems[QFontDatabase::WritingSystemsCount]; @@ -619,19 +607,13 @@ static void parseFontName(const QString &name, QString &foundry, QString &family struct QtFontDesc { - inline QtFontDesc() : family(0), foundry(0), style(0), size(0), encoding(0), familyIndex(-1) {} + inline QtFontDesc() : family(0), foundry(0), style(0), size(0) {} QtFontFamily *family; QtFontFoundry *foundry; QtFontStyle *style; QtFontSize *size; - QtFontEncoding *encoding; - int familyIndex; }; -static int match(int script, const QFontDef &request, - const QString &family_name, const QString &foundry_name, int force_encoding_id, - QtFontDesc *desc, const QList<int> &blacklisted); - static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi) { fontDef->family = desc.family->name; @@ -983,16 +965,14 @@ static unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, const QtFontFamily *family, const QString &foundry_name, QtFontStyle::Key styleKey, int pixelSize, char pitch, - QtFontDesc *desc, int force_encoding_id, const QString &styleName = QString()) + QtFontDesc *desc, const QString &styleName = QString()) { - Q_UNUSED(force_encoding_id); Q_UNUSED(script); Q_UNUSED(pitch); desc->foundry = 0; desc->style = 0; desc->size = 0; - desc->encoding = 0; FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count); @@ -1086,8 +1066,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, enum { PitchMismatch = 0x4000, StyleMismatch = 0x2000, - BitmapScaledPenalty = 0x1000, - EncodingMismatch = 0x0002 + BitmapScaledPenalty = 0x1000 }; if (pitch != '*') { if ((pitch == 'm' && !family->fixedPitch) @@ -1130,10 +1109,9 @@ static bool matchFamilyName(const QString &familyName, QtFontFamily *f) Tries to find the best match for a given request and family/foundry */ static int match(int script, const QFontDef &request, - const QString &family_name, const QString &foundry_name, int force_encoding_id, + const QString &family_name, const QString &foundry_name, QtFontDesc *desc, const QList<int> &blacklistedFamilies) { - Q_UNUSED(force_encoding_id); int result = -1; QtFontStyle::Key styleKey; @@ -1158,8 +1136,6 @@ static int match(int script, const QFontDef &request, desc->foundry = 0; desc->style = 0; desc->size = 0; - desc->encoding = 0; - desc->familyIndex = -1; unsigned int score = ~0u; @@ -1176,16 +1152,12 @@ static int match(int script, const QFontDef &request, continue; QtFontDesc test; test.family = db->families[x]; - test.familyIndex = x; if (!matchFamilyName(family_name, test.family)) continue; test.family->ensurePopulated(); - if (family_name.isEmpty()) - load(test.family->name, script); - // Check if family is supported in the script we want if (writingSystem != QFontDatabase::Any && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported)) continue; @@ -1195,13 +1167,13 @@ static int match(int script, const QFontDef &request, unsigned int newscore = bestFoundry(script, score, request.styleStrategy, test.family, foundry_name, styleKey, request.pixelSize, pitch, - &test, force_encoding_id, request.styleName); + &test, request.styleName); if (test.foundry == 0 && !foundry_name.isEmpty()) { // the specific foundry was not found, so look for // any foundry matching our requirements newscore = bestFoundry(script, score, request.styleStrategy, test.family, QString(), styleKey, request.pixelSize, - pitch, &test, force_encoding_id, request.styleName); + pitch, &test, request.styleName); } if (newscore < score) { @@ -2539,8 +2511,6 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, { QMutexLocker locker(fontDatabaseMutex()); - const int force_encoding_id = -1; - if (!privateDb()->count) initializeDb(); @@ -2563,7 +2533,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, QtFontDesc desc; QList<int> blackListed; - int index = match(script, request, family_name, foundry_name, force_encoding_id, &desc, blackListed); + int index = match(script, request, family_name, foundry_name, &desc, blackListed); if (index >= 0) { engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size); if (!engine) @@ -2606,7 +2576,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, if (!engine) { QtFontDesc desc; do { - index = match(script, def, def.family, QLatin1String(""), 0, &desc, blackListed); + index = match(script, def, def.family, QLatin1String(""), &desc, blackListed); if (index >= 0) { QFontDef loadDef = def; if (loadDef.family.isEmpty()) diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 5fa43948aa..502348a79a 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -611,7 +611,7 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q hasScript = true; //qDebug("font %s supports Korean", familyName.latin1()); } - if (codePageRange[0] & (1 << SymbolCsbBit)) { + if (codePageRange[0] & (1U << SymbolCsbBit)) { writingSystems = QSupportedWritingSystems(); hasScript = false; } diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 0615df65d6..3331d96f8b 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -47,7 +47,9 @@ #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QList> +#if QT_DEPRECATED_SINCE(5, 5) #include <QtCore/QHash> +#endif #include <QtGui/QFontDatabase> #include <QtGui/private/qfontengine_p.h> #include <QtGui/private/qfont_p.h> diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index a151c515a3..eb51447105 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -424,9 +424,9 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor // skip if already at word start QTextEngine *engine = layout->engine(); - engine->attributes(); + const QCharAttributes *attributes = engine->attributes(); if ((relativePos == blockIt.length() - 1) - && (engine->atSpace(relativePos - 1) || engine->atWordSeparator(relativePos - 1))) + && (attributes[relativePos - 1].whiteSpace || engine->atWordSeparator(relativePos - 1))) return false; if (relativePos < blockIt.length()-1) @@ -499,7 +499,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor } case QTextCursor::EndOfWord: { QTextEngine *engine = layout->engine(); - engine->attributes(); + const QCharAttributes *attributes = engine->attributes(); const int len = blockIt.length() - 1; if (relativePos >= len) return false; @@ -508,7 +508,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor while (relativePos < len && engine->atWordSeparator(relativePos)) ++relativePos; } else { - while (relativePos < len && !engine->atSpace(relativePos) && !engine->atWordSeparator(relativePos)) + while (relativePos < len && !attributes[relativePos].whiteSpace && !engine->atWordSeparator(relativePos)) ++relativePos; } newPosition = blockIt.position() + relativePos; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e8dd663354..d3b70aaf26 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1142,6 +1142,9 @@ void QTextDocument::setMetaInformation(MetaInformation info, const QString &stri Returns the plain text contained in the document. If you want formatting information use a QTextCursor instead. + \note Embedded objects, such as images, are represented by a + Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER). + \sa toHtml() */ QString QTextDocument::toPlainText() const diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 10a61d3c84..67a19804a3 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2549,21 +2549,6 @@ bool QTextEngine::atWordSeparator(int position) const return false; } -bool QTextEngine::atSpace(int position) const -{ - const QChar c = layoutData->string.at(position); - switch (c.unicode()) { - case QChar::Tabulation: - case QChar::Space: - case QChar::Nbsp: - case QChar::LineSeparator: - return true; - default: - break; - } - return false; -} - void QTextEngine::setPreeditArea(int position, const QString &preeditText) { if (preeditText.isEmpty()) { diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 8037fd5f6d..39b9e0cb5a 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -592,7 +592,6 @@ private: public: bool atWordSeparator(int position) const; - bool atSpace(int position) const; QString elidedText(Qt::TextElideMode mode, const QFixed &width, int flags = 0, int from = 0, int count = -1) const; diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index c60d0cc775..d4eb1a4b0b 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -38,7 +38,7 @@ #include <qdatastream.h> #include <qdebug.h> #include <qmap.h> -#include <qhash.h> +#include <qhashfunctions.h> QT_BEGIN_NAMESPACE @@ -3027,8 +3027,8 @@ QTextTableFormat::QTextTableFormat(const QTextFormat &fmt) \ingroup richtext-processing \ingroup shared - Inline images are represented by an object replacement character - (0xFFFC in Unicode) which has an associated QTextImageFormat. The + Inline images are represented by a Unicode value U+FFFC (OBJECT + REPLACEMENT CHARACTER) which has an associated QTextImageFormat. The image format specifies a name with setName() that is used to locate the image. The size of the rectangle that the image will occupy is specified using setWidth() and setHeight(). diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index 29656bbafe..928cef6488 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -47,7 +47,6 @@ #include "QtGui/qtextformat.h" #include "QtCore/qvector.h" -#include "QtCore/qhash.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index cab9f6ae61..7da3e84041 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -648,10 +648,10 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const while (oldPos < len && d->atWordSeparator(oldPos)) oldPos++; } else { - while (oldPos < len && !d->atSpace(oldPos) && !d->atWordSeparator(oldPos)) + while (oldPos < len && !attributes[oldPos].whiteSpace && !d->atWordSeparator(oldPos)) oldPos++; } - while (oldPos < len && d->atSpace(oldPos)) + while (oldPos < len && attributes[oldPos].whiteSpace) oldPos++; } @@ -679,7 +679,7 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const while (oldPos && !attributes[oldPos].graphemeBoundary) oldPos--; } else { - while (oldPos && d->atSpace(oldPos-1)) + while (oldPos > 0 && attributes[oldPos - 1].whiteSpace) oldPos--; if (oldPos && d->atWordSeparator(oldPos-1)) { @@ -687,7 +687,7 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const while (oldPos && d->atWordSeparator(oldPos-1)) oldPos--; } else { - while (oldPos && !d->atSpace(oldPos-1) && !d->atWordSeparator(oldPos-1)) + while (oldPos > 0 && !attributes[oldPos - 1].whiteSpace && !d->atWordSeparator(oldPos-1)) oldPos--; } } diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 425126d474..df7c8b9c71 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -1561,7 +1561,7 @@ QTextBlock QTextBlock::next() const Returns the text block in the document before this block, or an empty text block if this is the first one. - Note that the next block may be in a different frame or table to this block. + Note that the previous block may be in a different frame or table to this block. \sa next(), begin(), end() */ |