diff options
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qdistancefield.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qdistancefield_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qfont.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qstatictext.h | 2 | ||||
-rw-r--r-- | src/gui/text/qstatictext_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentfragment.cpp | 9 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 85 | ||||
-rw-r--r-- | src/gui/text/qtextodfwriter.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtexttable.cpp | 12 |
13 files changed, 79 insertions, 53 deletions
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index e7ca00b3a9..82bb617733 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index 27ab84332c..31cdf7edd2 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 82e03b6df9..d54fa22990 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2215,7 +2215,10 @@ QString QFont::defaultFamily() const */ QString QFont::lastResortFont() const { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED return lastResortFamily(); +QT_WARNING_POP } #endif diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index cab4ca0047..c363807e5e 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1842,7 +1842,8 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) { QFontDef request(fontDef); request.styleStrategy |= QFont::NoFontMerging; - request.families = QStringList(fallbackFamilyAt(at - 1)); + request.family = fallbackFamilyAt(at - 1); + request.families = QStringList(request.family); // At this point, the main script of the text has already been considered // when fetching the list of fallback families from the database, and the diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 0026e3edfb..dd894f4d32 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index e6a196d865..ada0456b8f 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -3,7 +3,7 @@ ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index c4023488ff..4ec09297c5 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 4f187c6701..fd3473b32e 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2663,10 +2663,10 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) bool closeAnchor = false; if (format.isAnchor()) { - const QString name = format.anchorName(); - if (!name.isEmpty()) { + const auto names = format.anchorNames(); + if (!names.isEmpty()) { html += QLatin1String("<a name=\""); - html += name.toHtmlEscaped(); + html += names.constFirst().toHtmlEscaped(); html += QLatin1String("\"></a>"); } const QString href = format.anchorHref(); diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 66e038122c..c0a0c1a177 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -275,7 +275,7 @@ void QTextDocumentPrivate::clear() init(); cursors = oldCursors; inContentsChange = true; - q->contentsChange(0, len, 0); + emit q->contentsChange(0, len, 0); inContentsChange = false; if (lout) lout->documentChanged(0, len, 0); diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index e7eaa54a45..aef4ea1522 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -542,8 +542,10 @@ void QTextHtmlImporter::import() } } - if (currentNode->charFormat.isAnchor() && !currentNode->charFormat.anchorName().isEmpty()) { - namedAnchors.append(currentNode->charFormat.anchorName()); + if (currentNode->charFormat.isAnchor()) { + const auto names = currentNode->charFormat.anchorNames(); + if (!names.isEmpty()) + namedAnchors.append(names.constFirst()); } if (appendNodeText()) @@ -1139,7 +1141,8 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() // #################### // block.setFloatPosition(node->cssFloat); - if (wsm == QTextHtmlParserNode::WhiteSpacePre) { + if (wsm == QTextHtmlParserNode::WhiteSpacePre + || wsm == QTextHtmlParserNode::WhiteSpaceNoWrap) { block.setNonBreakableLines(true); modifiedBlockFormat = true; } diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 506df0664d..a83ef95c79 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -252,8 +252,6 @@ struct QBidiAlgorithm { void initScriptAnalysisAndIsolatePairs(Vector<IsolatePair> &isolatePairs) { - isolatePairs.append({ -1, length }); // treat the whole string as one isolate - int isolateStack[128]; int isolateLevel = 0; // load directions of string, and determine isolate pairs @@ -304,6 +302,14 @@ struct QBidiAlgorithm { case QChar::DirS: case QChar::DirB: analysis[pos].bidiFlags = QScriptAnalysis::BidiResetToParagraphLevel; + if (uc == QChar::ParagraphSeparator) { + // close all open isolates as we start a new paragraph + while (isolateLevel > 0) { + --isolateLevel; + if (isolateLevel < 128) + isolatePairs[isolateStack[isolateLevel]].end = pos; + } + } break; default: break; @@ -434,21 +440,21 @@ struct QBidiAlgorithm { doEmbed(true, true, false); break; case QChar::DirLRI: - ++isolatePairPosition; Q_ASSERT(isolatePairs.at(isolatePairPosition).start == i); doEmbed(false, false, true); + ++isolatePairPosition; break; case QChar::DirRLI: - ++isolatePairPosition; Q_ASSERT(isolatePairs.at(isolatePairPosition).start == i); doEmbed(true, false, true); + ++isolatePairPosition; break; case QChar::DirFSI: { - ++isolatePairPosition; const auto &pair = isolatePairs.at(isolatePairPosition); Q_ASSERT(pair.start == i); bool isRtl = QStringView(text + pair.start + 1, pair.end - pair.start - 1).isRightToLeft(); doEmbed(isRtl, false, true); + ++isolatePairPosition; break; } @@ -492,16 +498,24 @@ struct QBidiAlgorithm { analysis[i].bidiDirection = (level & 1) ? QChar::DirR : QChar::DirL; break; case QChar::DirB: - // paragraph separator, go down to base direction - appendRun(i - 1); - while (stack.counter > 1) { - // there might be remaining isolates on the stack that are missing a PDI. Those need to get - // a continuation indicating to take the eos from the end of the string (ie. the paragraph level) - const auto &t = stack.top(); - if (t.isIsolate) { - runs[t.runBeforeIsolate].continuation = -2; + // paragraph separator, go down to base direction, reset all state + if (text[i].unicode() == QChar::ParagraphSeparator) { + appendRun(i - 1); + while (stack.counter > 1) { + // there might be remaining isolates on the stack that are missing a PDI. Those need to get + // a continuation indicating to take the eos from the end of the string (ie. the paragraph level) + const auto &t = stack.top(); + if (t.isIsolate) { + runs[t.runBeforeIsolate].continuation = -2; + } + --stack.counter; } - --stack.counter; + continuationFrom = -1; + lastRunWithContent = -1; + validIsolateCount = 0; + overflowIsolateCount = 0; + overflowEmbeddingCount = 0; + level = baseLevel; } break; default: @@ -1094,6 +1108,22 @@ struct QBidiAlgorithm { resolveImplicitLevels(runs); } + BIDI_DEBUG() << "Rule L1:"; + // Rule L1: + bool resetLevel = true; + for (int i = length - 1; i >= 0; --i) { + if (analysis[i].bidiFlags & QScriptAnalysis::BidiResetToParagraphLevel) { + BIDI_DEBUG() << "resetting pos" << i << "to baselevel"; + analysis[i].bidiLevel = baseLevel; + resetLevel = true; + } else if (resetLevel && analysis[i].bidiFlags & QScriptAnalysis::BidiMaybeResetToParagraphLevel) { + BIDI_DEBUG() << "resetting pos" << i << "to baselevel (maybereset flag)"; + analysis[i].bidiLevel = baseLevel; + } else { + resetLevel = false; + } + } + // set directions for BN to the minimum of adjacent chars // This makes is possible to be conformant with the Bidi algorithm even though we don't // remove BN and explicit embedding chars from the stream of characters to reorder @@ -1125,22 +1155,6 @@ struct QBidiAlgorithm { } } - BIDI_DEBUG() << "Rule L1:"; - // Rule L1: - bool resetLevel = true; - for (int i = length - 1; i >= 0; --i) { - if (analysis[i].bidiFlags & QScriptAnalysis::BidiResetToParagraphLevel) { - BIDI_DEBUG() << "resetting pos" << i << "to baselevel"; - analysis[i].bidiLevel = baseLevel; - resetLevel = true; - } else if (resetLevel && analysis[i].bidiFlags & QScriptAnalysis::BidiMaybeResetToParagraphLevel) { - BIDI_DEBUG() << "resetting pos" << i << "to baselevel (maybereset flag)"; - analysis[i].bidiLevel = baseLevel; - } else { - resetLevel = false; - } - } - if (BidiDebugEnabled) { BIDI_DEBUG() << "final resolved levels:"; for (int i = 0; i < length; ++i) @@ -1398,11 +1412,12 @@ void QTextEngine::shapeText(int item) const #ifndef QT_NO_RAWFONT if (useRawFont) { QTextCharFormat f = format(&si); - kerningEnabled = f.fontKerning(); + QFont font = f.font(); + kerningEnabled = font.kerning(); shapingEnabled = QFontEngine::scriptRequiresOpenType(QChar::Script(si.analysis.script)) - || (f.fontStyleStrategy() & QFont::PreferNoShaping) == 0; - wordSpacing = QFixed::fromReal(f.fontWordSpacing()); - letterSpacing = QFixed::fromReal(f.fontLetterSpacing()); + || (font.styleStrategy() & QFont::PreferNoShaping) == 0; + wordSpacing = QFixed::fromReal(font.wordSpacing()); + letterSpacing = QFixed::fromReal(font.letterSpacing()); letterSpacingIsAbsolute = true; } else #endif @@ -2072,8 +2087,6 @@ void QTextEngine::itemize() const analysis->flags = QScriptAnalysis::Object; break; case QChar::LineSeparator: - if (analysis->bidiLevel % 2) - --analysis->bidiLevel; analysis->flags = QScriptAnalysis::LineOrParagraphSeparator; if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) { const int offset = uc - string; diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 1a3f5309ae..c8fa5306c3 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -496,10 +496,12 @@ void QTextOdfWriter::writeFormats(QXmlStreamWriter &writer, const QSet<int> &for else writeFrameFormat(writer, textFormat.toFrameFormat(), formatIndex); break; +#if QT_DEPRECATED_SINCE(5, 3) case QTextFormat::TableFormat: // this case never happens, because TableFormat is a FrameFormat Q_UNREACHABLE(); break; +#endif } } diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 9639c18d2b..39f26d5d42 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -696,18 +696,22 @@ void QTextTable::insertRows(int pos, int num) int extended = 0; int insert_before = 0; if (pos > 0 && pos < d->nRows) { + int lastCell = -1; for (int i = 0; i < d->nCols; ++i) { int cell = d->grid[pos*d->nCols + i]; if (cell == d->grid[(pos-1)*d->nCols+i]) { // cell spans the insertion place, extend it - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); - fmt.setTableCellRowSpan(fmt.tableCellRowSpan() + num); - p->setCharFormat(it.position(), 1, fmt); + if (cell != lastCell) { + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); + fmt.setTableCellRowSpan(fmt.tableCellRowSpan() + num); + p->setCharFormat(it.position(), 1, fmt); + } extended++; } else if (!insert_before) { insert_before = cell; } + lastCell = cell; } } else { insert_before = (pos == 0 ? d->grid[0] : d->fragment_end); |